diff options
author | Felix Buehler <account@buehler.rocks> | 2023-06-10 20:16:12 +0200 |
---|---|---|
committer | Emery Hemingway <ehmry@posteo.net> | 2023-07-12 09:36:28 +0100 |
commit | bec27fabee7ff51a4788840479b1730ed1b64427 (patch) | |
tree | 638353517b8f8eb3b5b8d4fbc7172cd1aa42d47d /nixos | |
parent | b63179691fb19cd8bb63fbb005bb3120a36deba0 (diff) | |
download | nixpkgs-bec27fabee7ff51a4788840479b1730ed1b64427.tar nixpkgs-bec27fabee7ff51a4788840479b1730ed1b64427.tar.gz nixpkgs-bec27fabee7ff51a4788840479b1730ed1b64427.tar.bz2 nixpkgs-bec27fabee7ff51a4788840479b1730ed1b64427.tar.lz nixpkgs-bec27fabee7ff51a4788840479b1730ed1b64427.tar.xz nixpkgs-bec27fabee7ff51a4788840479b1730ed1b64427.tar.zst nixpkgs-bec27fabee7ff51a4788840479b1730ed1b64427.zip |
treewide: use lib.optional instead of 'then []'
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/lib/eval-config.nix | 2 | ||||
-rw-r--r-- | nixos/modules/installer/netboot/netboot.nix | 4 | ||||
-rw-r--r-- | nixos/modules/services/misc/zoneminder.nix | 2 | ||||
-rw-r--r-- | nixos/modules/services/search/kibana.nix | 4 | ||||
-rw-r--r-- | nixos/modules/services/security/kanidm.nix | 2 | ||||
-rw-r--r-- | nixos/modules/services/web-apps/restya-board.nix | 4 | ||||
-rw-r--r-- | nixos/tests/common/resolver.nix | 2 |
7 files changed, 9 insertions, 11 deletions
diff --git a/nixos/lib/eval-config.nix b/nixos/lib/eval-config.nix index 058ab7280cc..e1242276a74 100644 --- a/nixos/lib/eval-config.nix +++ b/nixos/lib/eval-config.nix @@ -31,7 +31,7 @@ evalConfigArgs@ , prefix ? [] , lib ? import ../../lib , extraModules ? let e = builtins.getEnv "NIXOS_EXTRA_MODULE_PATH"; - in if e == "" then [] else [(import e)] + in lib.optional (e != "") (import e) }: let pkgs_ = pkgs; diff --git a/nixos/modules/installer/netboot/netboot.nix b/nixos/modules/installer/netboot/netboot.nix index a55c0ab2d65..a50f22cbe47 100644 --- a/nixos/modules/installer/netboot/netboot.nix +++ b/nixos/modules/installer/netboot/netboot.nix @@ -39,9 +39,7 @@ with lib; # !!! Hack - attributes expected by other modules. environment.systemPackages = [ pkgs.grub2_efi ] - ++ (if pkgs.stdenv.hostPlatform.system == "aarch64-linux" - then [] - else [ pkgs.grub2 pkgs.syslinux ]); + ++ (lib.optionals (pkgs.stdenv.hostPlatform.system != "aarch64-linux") [pkgs.grub2 pkgs.syslinux]); fileSystems."/" = mkImageMediaOverride { fsType = "tmpfs"; diff --git a/nixos/modules/services/misc/zoneminder.nix b/nixos/modules/services/misc/zoneminder.nix index 11722979851..616a60a123e 100644 --- a/nixos/modules/services/misc/zoneminder.nix +++ b/nixos/modules/services/misc/zoneminder.nix @@ -351,7 +351,7 @@ in { CacheDirectory = dirs cacheDirs; RuntimeDirectory = dirName; ReadWriteDirectories = lib.mkIf useCustomDir [ cfg.storageDir ]; - StateDirectory = dirs (if useCustomDir then [] else libDirs); + StateDirectory = dirs (lib.optional (!useCustomDir) libDirs); LogsDirectory = dirName; PrivateTmp = true; ProtectSystem = "strict"; diff --git a/nixos/modules/services/search/kibana.nix b/nixos/modules/services/search/kibana.nix index 5eb2381d5d3..a5e132d5c38 100644 --- a/nixos/modules/services/search/kibana.nix +++ b/nixos/modules/services/search/kibana.nix @@ -130,9 +130,9 @@ in { This defaults to the singleton list [ca] when the {option}`ca` option is defined. ''; - default = if cfg.elasticsearch.ca == null then [] else [ca]; + default = lib.optional (cfg.elasticsearch.ca != null) ca; defaultText = literalExpression '' - if config.${opt.elasticsearch.ca} == null then [ ] else [ ca ] + lib.optional (config.${opt.elasticsearch.ca} != null) ca ''; type = types.listOf types.path; }; diff --git a/nixos/modules/services/security/kanidm.nix b/nixos/modules/services/security/kanidm.nix index 71ccded7dce..cea2a56bdcd 100644 --- a/nixos/modules/services/security/kanidm.nix +++ b/nixos/modules/services/security/kanidm.nix @@ -17,7 +17,7 @@ let # If the new path is a prefix to some existing path, we need to filter it out filteredPaths = lib.filter (p: !lib.hasPrefix (builtins.toString newPath) (builtins.toString p)) merged; # If a prefix of the new path is already in the list, do not add it - filteredNew = if hasPrefixInList filteredPaths newPath then [] else [ newPath ]; + filteredNew = lib.optional (!hasPrefixInList filteredPaths newPath) newPath; in filteredPaths ++ filteredNew) []; defaultServiceConfig = { diff --git a/nixos/modules/services/web-apps/restya-board.nix b/nixos/modules/services/web-apps/restya-board.nix index 4b32f06826e..959bcbc5c9f 100644 --- a/nixos/modules/services/web-apps/restya-board.nix +++ b/nixos/modules/services/web-apps/restya-board.nix @@ -263,8 +263,8 @@ in serviceConfig.RemainAfterExit = true; wantedBy = [ "multi-user.target" ]; - requires = if cfg.database.host == null then [] else [ "postgresql.service" ]; - after = [ "network.target" ] ++ (if cfg.database.host == null then [] else [ "postgresql.service" ]); + requires = lib.optional (cfg.database.host != null) "postgresql.service"; + after = [ "network.target" ] ++ (lib.optional (cfg.database.host != null) "postgresql.service"); script = '' rm -rf "${runDir}" diff --git a/nixos/tests/common/resolver.nix b/nixos/tests/common/resolver.nix index 3ddf730668c..609058a7374 100644 --- a/nixos/tests/common/resolver.nix +++ b/nixos/tests/common/resolver.nix @@ -63,7 +63,7 @@ matched = builtins.match "[ \t]+(${reHost})(.*)" str; continue = lib.singleton (lib.head matched) ++ matchAliases (lib.last matched); - in if matched == null then [] else continue; + in lib.optional (matched != null) continue; matchLine = str: let result = builtins.match "[ \t]*(${reIp})[ \t]+(${reHost})(.*)" str; |