Merge pull request #77 from ryan4yin/use-optionals

refactor: use lib.optionals instead of if...then...else
This commit is contained in:
Ryan Yin
2024-03-08 23:18:41 +08:00
committed by GitHub
5 changed files with 129 additions and 136 deletions

View File

@@ -1,4 +1,8 @@
{pkgs, ...}: { {
lib,
pkgs,
...
}: {
home.packages = with pkgs; home.packages = with pkgs;
[ [
# general tools # general tools
@@ -26,12 +30,10 @@
aliyun-cli aliyun-cli
] ]
++ ( ++ (
if pkgs.stdenv.isLinux lib.optionals pkgs.stdenv.isLinux [
then [
# cloud tools that nix do not have cache for. # cloud tools that nix do not have cache for.
terraform terraform
terraformer # generate terraform configs from existing cloud resources terraformer # generate terraform configs from existing cloud resources
] ]
else []
); );
} }

View File

@@ -41,8 +41,7 @@
exercism exercism
] ]
++ ( ++ (
if pkgs.stdenv.isLinux lib.optionals pkgs.stdenv.isLinux [
then [
# Automatically trims your branches whose tracking remote refs are merged or gone # Automatically trims your branches whose tracking remote refs are merged or gone
# It's really useful when you work on a project for a long time. # It's really useful when you work on a project for a long time.
git-trim git-trim
@@ -57,7 +56,6 @@
wireshark # network analyzer wireshark # network analyzer
ventoy # create bootable usb ventoy # create bootable usb
] ]
else []
); );
programs = { programs = {

View File

@@ -129,9 +129,7 @@
(ripgrep.override {withPCRE2 = true;}) # recursively searches directories for a regex pattern (ripgrep.override {withPCRE2 = true;}) # recursively searches directories for a regex pattern
] ]
++ ( ++ (
if pkgs.stdenv.isDarwin lib.optionals pkgs.stdenv.isLinux [
then []
else [
#-- verilog / systemverilog #-- verilog / systemverilog
verible verible
gdb gdb

View File

@@ -18,18 +18,23 @@
# we can add wezterm as a flake input once this PR is merged: # we can add wezterm as a flake input once this PR is merged:
# https://github.com/wez/wezterm/pull/3547 # https://github.com/wez/wezterm/pull/3547
programs.wezterm = programs.wezterm = {
{ enable = true; # disable
enable = false; # disable
# TODO: Fix: https://github.com/wez/wezterm/issues/4483 # install wezterm via homebrew on macOS to avoid compilation, dummy package here.
# package = pkgs.wezterm.override { }; package =
if pkgs.stdenv.isLinux
then pkgs.wezterm
else pkgs.hello;
enableBashIntegration = pkgs.stdenv.isLinux;
enableZshIntegration = pkgs.stdenv.isLinux;
extraConfig = let extraConfig = let
fontsize = fontsize =
if pkgs.stdenv.isDarwin if pkgs.stdenv.isLinux
then "14.0" then "13.0"
else "13.0"; else "14.0";
in '' in ''
-- Pull in the wezterm API -- Pull in the wezterm API
local wezterm = require 'wezterm' local wezterm = require 'wezterm'
@@ -96,15 +101,5 @@
return config return config
''; '';
} };
// (
if pkgs.stdenv.isDarwin
then {
# install wezterm via homebrew on macOS to avoid compilation, dummy package here.
# package = pkgs.hello;
enableBashIntegration = false;
enableZshIntegration = false;
}
else {}
);
} }

View File

@@ -4,7 +4,8 @@
nur-ryan4yin, nur-ryan4yin,
... ...
}: { }: {
home.packages = with pkgs; [ home.packages = with pkgs;
[
# Misc # Misc
tldr tldr
cowsay cowsay
@@ -53,10 +54,9 @@
# productivity # productivity
caddy # A webserver with automatic HTTPS via Let's Encrypt(replacement of nginx) caddy # A webserver with automatic HTTPS via Let's Encrypt(replacement of nginx)
croc # File transfer between computers securely and easily croc # File transfer between computers securely and easily
]
# self-hosted nix cache server # self-hosted nix cache server
attic.packages.${pkgs.system}.attic-client ++ lib.optionals pkgs.stdenv.isLinux [attic.packages.${pkgs.system}.attic-client];
];
programs = { programs = {
# A modern replacement for ls # A modern replacement for ls