Commit bec27fab authored by Felix Buehler's avatar Felix Buehler Committed by Emery Hemingway
Browse files

treewide: use lib.optional instead of 'then []'

parent b6317969
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −3
Original line number Diff line number Diff line
@@ -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";
+1 −1
Original line number Diff line number Diff line
@@ -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";
+2 −2
Original line number Diff line number Diff line
@@ -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;
      };
+1 −1
Original line number Diff line number Diff line
@@ -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 = {
Loading