refactor: use lib.optionals instead of if...then...else...

This commit is contained in:
Ryan Yin
2024-03-08 22:53:49 +08:00
parent 54c2240be6
commit 3247e4a8e6
5 changed files with 129 additions and 136 deletions

View File

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

View File

@@ -41,8 +41,7 @@
exercism
]
++ (
if pkgs.stdenv.isLinux
then [
lib.optionals pkgs.stdenv.isLinux [
# 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.
git-trim
@@ -57,7 +56,6 @@
wireshark # network analyzer
ventoy # create bootable usb
]
else []
);
programs = {

View File

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

View File

@@ -18,18 +18,23 @@
# we can add wezterm as a flake input once this PR is merged:
# https://github.com/wez/wezterm/pull/3547
programs.wezterm =
{
enable = false; # disable
programs.wezterm = {
enable = true; # disable
# TODO: Fix: https://github.com/wez/wezterm/issues/4483
# package = pkgs.wezterm.override { };
# install wezterm via homebrew on macOS to avoid compilation, dummy package here.
package =
if pkgs.stdenv.isLinux
then pkgs.wezterm
else pkgs.hello;
enableBashIntegration = pkgs.stdenv.isLinux;
enableZshIntegration = pkgs.stdenv.isLinux;
extraConfig = let
fontsize =
if pkgs.stdenv.isDarwin
then "14.0"
else "13.0";
if pkgs.stdenv.isLinux
then "13.0"
else "14.0";
in ''
-- Pull in the wezterm API
local wezterm = require 'wezterm'
@@ -96,15 +101,5 @@
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,
...
}: {
home.packages = with pkgs; [
home.packages = with pkgs;
[
# Misc
tldr
cowsay
@@ -53,10 +54,9 @@
# productivity
caddy # A webserver with automatic HTTPS via Let's Encrypt(replacement of nginx)
croc # File transfer between computers securely and easily
]
# self-hosted nix cache server
attic.packages.${pkgs.system}.attic-client
];
++ lib.optionals pkgs.stdenv.isLinux [attic.packages.${pkgs.system}.attic-client];
programs = {
# A modern replacement for ls