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
+6 -4
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 []
);
}
+1 -3
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 = {
+1 -3
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
+14 -19
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 {}
);
};
}
+4 -4
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