diff options
author | Daniel Schaefer <git@danielschaefer.me> | 2019-04-24 05:48:22 +0200 |
---|---|---|
committer | Daniel Schaefer <git@danielschaefer.me> | 2019-04-29 14:05:50 +0200 |
commit | 786f02f7a45621b9f628f63649ff92546aff83b7 (patch) | |
tree | 92784e131ccac4a1a63f7dbae6c228fb9d81468b | |
parent | 5f14e83bd6b9ef1c83b035011267dd3d40278476 (diff) |
treewide: Remove usage of isNull
isNull "is deprecated; just write e == null instead" says the Nix manual
52 files changed, 89 insertions, 95 deletions
diff --git a/lib/generators.nix b/lib/generators.nix index 863ba847423e..a71654bec6c3 100644 --- a/lib/generators.nix +++ b/lib/generators.nix @@ -178,7 +178,7 @@ rec { toPlist = {}: v: let isFloat = builtins.isFloat or (x: false); expr = ind: x: with builtins; - if isNull x then "" else + if x == null then "" else if isBool x then bool ind x else if isInt x then int ind x else if isString x then str ind x else diff --git a/lib/sources.nix b/lib/sources.nix index f02ddad17c6d..0ffadea8f1bc 100644 --- a/lib/sources.nix +++ b/lib/sources.nix @@ -83,7 +83,7 @@ rec { # Sometimes git stores the commitId directly in the file but # sometimes it stores something like: «ref: refs/heads/branch-name» matchRef = match "^ref: (.*)$" fileContent; - in if isNull matchRef + in if matchRef == null then fileContent else readCommitFromFile (lib.head matchRef) path # Sometimes, the file isn't there at all and has been packed away in the @@ -92,7 +92,7 @@ rec { then let fileContent = readFile packedRefsName; matchRef = match (".*\n([^\n ]*) " + file + "\n.*") fileContent; - in if isNull matchRef + in if matchRef == null then throw ("Could not find " + file + " in " + packedRefsName) else lib.head matchRef else throw ("Not a .git directory: " + path); diff --git a/lib/trivial.nix b/lib/trivial.nix index 2d682961035f..f2710a6f0338 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -112,7 +112,7 @@ rec { # Function to call f: # Argument to check for null before passing it to `f` - a: if isNull a then a else f a; + a: if a == null then a else f a; # Pull in some builtins not included elsewhere. inherit (builtins) diff --git a/nixos/maintainers/option-usages.nix b/nixos/maintainers/option-usages.nix index 242c2a4dd442..a67a0ab960e5 100644 --- a/nixos/maintainers/option-usages.nix +++ b/nixos/maintainers/option-usages.nix @@ -145,7 +145,7 @@ let displayOptionsGraph = let checkList = - if !(isNull testOption) then [ testOption ] + if testOption != null then [ testOption ] else testOptions; checkAll = checkList == []; in diff --git a/nixos/modules/config/fonts/fontconfig-penultimate.nix b/nixos/modules/config/fonts/fontconfig-penultimate.nix index 2c18244621af..04fa8b9559a9 100644 --- a/nixos/modules/config/fonts/fontconfig-penultimate.nix +++ b/nixos/modules/config/fonts/fontconfig-penultimate.nix @@ -31,7 +31,7 @@ let # use latest when no version is passed makeCacheConf = { version ? null }: let - fcPackage = if builtins.isNull version + fcPackage = if version == null then "fontconfig" else "fontconfig_${version}"; makeCache = fontconfig: pkgs.makeFontsCache { inherit fontconfig; fontDirectories = config.fonts.fonts; }; diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index d79c43c0b5b9..724158f73821 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -46,7 +46,7 @@ let cfg = config.fonts.fontconfig; # use latest when no version is passed makeCacheConf = { version ? null }: let - fcPackage = if builtins.isNull version + fcPackage = if version == null then "fontconfig" else "fontconfig_${version}"; makeCache = fontconfig: pkgs.makeFontsCache { inherit fontconfig; fontDirectories = config.fonts.fonts; }; diff --git a/nixos/modules/config/sysctl.nix b/nixos/modules/config/sysctl.nix index 74bff602a477..0c6a7e2431aa 100644 --- a/nixos/modules/config/sysctl.nix +++ b/nixos/modules/config/sysctl.nix @@ -8,7 +8,7 @@ let name = "sysctl option value"; check = val: let - checkType = x: isBool x || isString x || isInt x || isNull x; + checkType = x: isBool x || isString x || isInt x || x == null; in checkType val || (val._type or "" == "override" && checkType val.content); merge = loc: defs: mergeOneOption loc (filterOverrides defs); diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index fd780be20825..d5c92cfc1d9e 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -198,7 +198,7 @@ let fi ${ # When there is a theme configured, use it, otherwise use the background image. - if (!isNull config.isoImage.grubTheme) then '' + if config.isoImage.grubTheme != null then '' # Sets theme. set theme=(hd0)/EFI/boot/grub-theme/theme.txt # Load theme fonts @@ -622,7 +622,7 @@ in { source = "${pkgs.memtest86plus}/memtest.bin"; target = "/boot/memtest.bin"; } - ] ++ optionals (!isNull config.isoImage.grubTheme) [ + ] ++ optionals (config.isoImage.grubTheme != null) [ { source = config.isoImage.grubTheme; target = "/EFI/boot/grub-theme"; } diff --git a/nixos/modules/programs/bash/bash.nix b/nixos/modules/programs/bash/bash.nix index 27b5f9e4b642..a7e57b8608d7 100644 --- a/nixos/modules/programs/bash/bash.nix +++ b/nixos/modules/programs/bash/bash.nix @@ -34,7 +34,7 @@ let bashAliases = concatStringsSep "\n" ( mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}") - (filterAttrs (k: v: !isNull v) cfg.shellAliases) + (filterAttrs (k: v: v != null) cfg.shellAliases) ); in diff --git a/nixos/modules/programs/fish.nix b/nixos/modules/programs/fish.nix index 622d2f96fe41..87f6816e4ac0 100644 --- a/nixos/modules/programs/fish.nix +++ b/nixos/modules/programs/fish.nix @@ -10,7 +10,7 @@ let fishAliases = concatStringsSep "\n" ( mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}") - (filterAttrs (k: v: !isNull v) cfg.shellAliases) + (filterAttrs (k: v: v != null) cfg.shellAliases) ); in diff --git a/nixos/modules/programs/ssmtp.nix b/nixos/modules/programs/ssmtp.nix index 44756171b74c..0e060e3f5226 100644 --- a/nixos/modules/programs/ssmtp.nix +++ b/nixos/modules/programs/ssmtp.nix @@ -148,7 +148,7 @@ in UseSTARTTLS=${yesNo cfg.useSTARTTLS} #Debug=YES ${optionalString (cfg.authUser != "") "AuthUser=${cfg.authUser}"} - ${optionalString (!isNull cfg.authPassFile) "AuthPassFile=${cfg.authPassFile}"} + ${optionalString (cfg.authPassFile != null) "AuthPassFile=${cfg.authPassFile}"} ''; environment.systemPackages = [pkgs.ssmtp]; diff --git a/nixos/modules/programs/zsh/zsh.nix b/nixos/modules/programs/zsh/zsh.nix index b7117e5f90d7..bdb37eae23ef 100644 --- a/nixos/modules/programs/zsh/zsh.nix +++ b/nixos/modules/programs/zsh/zsh.nix @@ -12,7 +12,7 @@ let zshAliases = concatStringsSep "\n" ( mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}") - (filterAttrs (k: v: !isNull v) cfg.shellAliases) + (filterAttrs (k: v: v != null) cfg.shellAliases) ); in diff --git a/nixos/modules/services/backup/znapzend.nix b/nixos/modules/services/backup/znapzend.nix index fc8a424190f7..f3aa5074e42f 100644 --- a/nixos/modules/services/backup/znapzend.nix +++ b/nixos/modules/services/backup/znapzend.nix @@ -255,7 +255,7 @@ let cfg = config.services.znapzend; onOff = b: if b then "on" else "off"; - nullOff = b: if isNull b then "off" else toString b; + nullOff = b: if b == null then "off" else toString b; stripSlashes = replaceStrings [ "/" ] [ "." ]; attrsToFile = config: concatStringsSep "\n" (builtins.attrValues ( @@ -263,7 +263,7 @@ let mkDestAttrs = dst: with dst; mapAttrs' (n: v: nameValuePair "dst_${label}${n}" v) ({ - "" = optionalString (! isNull host) "${host}:" + dataset; + "" = optionalString (host != null) "${host}:" + dataset; _plan = plan; } // optionalAttrs (presend != null) { _precmd = presend; diff --git a/nixos/modules/services/cluster/kubernetes/kubelet.nix b/nixos/modules/services/cluster/kubernetes/kubelet.nix index 2a4a0624555d..ccc8a16e788a 100644 --- a/nixos/modules/services/cluster/kubernetes/kubelet.nix +++ b/nixos/modules/services/cluster/kubernetes/kubelet.nix @@ -7,9 +7,9 @@ let cfg = top.kubelet; cniConfig = - if cfg.cni.config != [] && !(isNull cfg.cni.configDir) then + if cfg.cni.config != [] && cfg.cni.configDir != null then throw "Verbatim CNI-config and CNI configDir cannot both be set." - else if !(isNull cfg.cni.configDir) then + else if cfg.cni.configDir != null then cfg.cni.configDir else (pkgs.buildEnv { @@ -373,7 +373,7 @@ in boot.kernelModules = ["br_netfilter"]; services.kubernetes.kubelet.hostname = with config.networking; - mkDefault (hostName + optionalString (!isNull domain) ".${domain}"); + mkDefault (hostName + optionalString (domain != null) ".${domain}"); services.kubernetes.pki.certs = with top.lib; { kubelet = mkCert { diff --git a/nixos/modules/services/cluster/kubernetes/pki.nix b/nixos/modules/services/cluster/kubernetes/pki.nix index 32eacad9025f..e68660e8bdd4 100644 --- a/nixos/modules/services/cluster/kubernetes/pki.nix +++ b/nixos/modules/services/cluster/kubernetes/pki.nix @@ -285,7 +285,7 @@ in }; }; - environment.etc.${cfg.etcClusterAdminKubeconfig}.source = mkIf (!isNull cfg.etcClusterAdminKubeconfig) + environment.etc.${cfg.etcClusterAdminKubeconfig}.source = mkIf (cfg.etcClusterAdminKubeconfig != null) (top.lib.mkKubeConfig "cluster-admin" clusterAdminKubeconfig); environment.systemPackages = mkIf (top.kubelet.enable || top.proxy.enable) [ diff --git a/nixos/modules/services/continuous-integration/buildkite-agent.nix b/nixos/modules/services/continuous-integration/buildkite-agent.nix index 2136778aff47..12cc3d2b1ccc 100644 --- a/nixos/modules/services/continuous-integration/buildkite-agent.nix +++ b/nixos/modules/services/continuous-integration/buildkite-agent.nix @@ -236,7 +236,7 @@ in }; assertions = [ - { assertion = cfg.hooksPath == hooksDir || all isNull (attrValues cfg.hooks); + { assertion = cfg.hooksPath == hooksDir || all (v: v == null) (attrValues cfg.hooks); message = '' Options `services.buildkite-agent.hooksPath' and `services.buildkite-agent.hooks.<name>' are mutually exclusive. diff --git a/nixos/modules/services/continuous-integration/jenkins/default.nix b/nixos/modules/services/continuous-integration/jenkins/default.nix index 1eca45fbd570..ec6a36413fe7 100644 --- a/nixos/modules/services/continuous-integration/jenkins/default.nix +++ b/nixos/modules/services/continuous-integration/jenkins/default.nix @@ -189,7 +189,7 @@ in { preStart = let replacePlugins = - if isNull cfg.plugins + if cfg.plugins == null then "" else let pluginCmds = lib.attrsets.mapAttrsToList diff --git a/nixos/modules/services/databases/cassandra.nix b/nixos/modules/services/databases/cassandra.nix index d741ee48c48f..688938868020 100644 --- a/nixos/modules/services/databases/cassandra.nix +++ b/nixos/modules/services/databases/cassandra.nix @@ -22,11 +22,11 @@ let else {}) ); cassandraConfigWithAddresses = cassandraConfig // - ( if isNull cfg.listenAddress + ( if cfg.listenAddress == null then { listen_interface = cfg.listenInterface; } else { listen_address = cfg.listenAddress; } ) // ( - if isNull cfg.rpcAddress + if cfg.rpcAddress == null then { rpc_interface = cfg.rpcInterface; } else { rpc_address = cfg.rpcAddress; } ); @@ -219,19 +219,13 @@ in { config = mkIf cfg.enable { assertions = [ { assertion = - ((isNull cfg.listenAddress) - || (isNull cfg.listenInterface) - ) && !((isNull cfg.listenAddress) - && (isNull cfg.listenInterface) - ); + (cfg.listenAddress == null || cfg.listenInterface == null) + && !(cfg.listenAddress == null && cfg.listenInterface == null); message = "You have to set either listenAddress or listenInterface"; } { assertion = - ((isNull cfg.rpcAddress) - || (isNull cfg.rpcInterface) - ) && !((isNull cfg.rpcAddress) - && (isNull cfg.rpcInterface) - ); + (cfg.rpcAddress == null || cfg.rpcInterface == null) + && !(cfg.rpcAddress == null && cfg.rpcInterface == null); message = "You have to set either rpcAddress or rpcInterface"; } ]; @@ -276,7 +270,7 @@ in { }; }; systemd.timers.cassandra-full-repair = - mkIf (!isNull cfg.fullRepairInterval) { + mkIf (cfg.fullRepairInterval != null) { description = "Schedule full repairs on Cassandra"; wantedBy = [ "timers.target" ]; timerConfig = @@ -300,7 +294,7 @@ in { }; }; systemd.timers.cassandra-incremental-repair = - mkIf (!isNull cfg.incrementalRepairInterval) { + mkIf (cfg.incrementalRepairInterval != null) { description = "Schedule incremental repairs on Cassandra"; wantedBy = [ "timers.target" ]; timerConfig = diff --git a/nixos/modules/services/databases/cockroachdb.nix b/nixos/modules/services/databases/cockroachdb.nix index e977751b21ef..268fdcc819fd 100644 --- a/nixos/modules/services/databases/cockroachdb.nix +++ b/nixos/modules/services/databases/cockroachdb.nix @@ -7,7 +7,7 @@ let crdb = cfg.package; escape = builtins.replaceStrings ["%"] ["%%"]; - ifNotNull = v: s: optionalString (!isNull v) s; + ifNotNull = v: s: optionalString (v != null) s; startupCommand = lib.concatStringsSep " " [ # Basic startup @@ -164,7 +164,7 @@ in config = mkIf config.services.cockroachdb.enable { assertions = [ - { assertion = !cfg.insecure -> !(isNull cfg.certsDir); + { assertion = !cfg.insecure -> cfg.certsDir != null; message = "CockroachDB must have a set of SSL certificates (.certsDir), or run in Insecure Mode (.insecure = true)"; } ]; diff --git a/nixos/modules/services/databases/pgmanage.nix b/nixos/modules/services/databases/pgmanage.nix index 1a34c7f5ecee..1050c2dd481a 100644 --- a/nixos/modules/services/databases/pgmanage.nix +++ b/nixos/modules/services/databases/pgmanage.nix @@ -16,7 +16,7 @@ let super_only = ${builtins.toJSON cfg.superOnly} - ${optionalString (!isNull cfg.loginGroup) "login_group = ${cfg.loginGroup}"} + ${optionalString (cfg.loginGroup != null) "login_group = ${cfg.loginGroup}"} login_timeout = ${toString cfg.loginTimeout} @@ -24,7 +24,7 @@ let sql_root = ${cfg.sqlRoot} - ${optionalString (!isNull cfg.tls) '' + ${optionalString (cfg.tls != null) '' tls_cert = ${cfg.tls.cert} tls_key = ${cfg.tls.key} ''} diff --git a/nixos/modules/services/games/minecraft-server.nix b/nixos/modules/services/games/minecraft-server.nix index 7d26d1501650..39a68f4b5536 100644 --- a/nixos/modules/services/games/minecraft-server.nix +++ b/nixos/modules/services/games/minecraft-server.nix @@ -215,8 +215,8 @@ in { networking.firewall = mkIf cfg.openFirewall (if cfg.declarative then { allowedUDPPorts = [ serverPort ]; allowedTCPPorts = [ serverPort ] - ++ optional (! isNull queryPort) queryPort - ++ optional (! isNull rconPort) rconPort; + ++ optional (queryPort != null) queryPort + ++ optional (rconPort != null) rconPort; } else { allowedUDPPorts = [ defaultServerPort ]; allowedTCPPorts = [ defaultServerPort ]; diff --git a/nixos/modules/services/logging/logcheck.nix b/nixos/modules/services/logging/logcheck.nix index 9c64160e92bc..f139190a1709 100644 --- a/nixos/modules/services/logging/logcheck.nix +++ b/nixos/modules/services/logging/logcheck.nix @@ -227,7 +227,7 @@ in ''; services.cron.systemCronJobs = - let withTime = name: {timeArgs, ...}: ! (builtins.isNull timeArgs); + let withTime = name: {timeArgs, ...}: timeArgs != null; mkCron = name: {user, cmdline, timeArgs, ...}: '' ${timeArgs} ${user} ${cmdline} ''; diff --git a/nixos/modules/services/mail/dovecot.nix b/nixos/modules/services/mail/dovecot.nix index 30ad7d82fb80..139011dca23a 100644 --- a/nixos/modules/services/mail/dovecot.nix +++ b/nixos/modules/services/mail/dovecot.nix @@ -16,13 +16,13 @@ let sendmail_path = /run/wrappers/bin/sendmail '' - (if isNull cfg.sslServerCert then '' + (if cfg.sslServerCert == null then '' ssl = no disable_plaintext_auth = no '' else '' ssl_cert = <${cfg.sslServerCert} ssl_key = <${cfg.sslServerKey} - ${optionalString (!(isNull cfg.sslCACert)) ("ssl_ca = <" + cfg.sslCACert)} + ${optionalString (cfg.sslCACert != null) ("ssl_ca = <" + cfg.sslCACert)} ssl_dh = <${config.security.dhparams.params.dovecot2.path} disable_plaintext_auth = yes '') @@ -298,7 +298,7 @@ in config = mkIf cfg.enable { security.pam.services.dovecot2 = mkIf cfg.enablePAM {}; - security.dhparams = mkIf (! isNull cfg.sslServerCert) { + security.dhparams = mkIf (cfg.sslServerCert != null) { enable = true; params.dovecot2 = {}; }; @@ -384,14 +384,14 @@ in { assertion = intersectLists cfg.protocols [ "pop3" "imap" ] != []; message = "dovecot needs at least one of the IMAP or POP3 listeners enabled"; } - { assertion = isNull cfg.sslServerCert == isNull cfg.sslServerKey - && (!(isNull cfg.sslCACert) -> !(isNull cfg.sslServerCert || isNull cfg.sslServerKey)); + { assertion = (cfg.sslServerCert == null) == (cfg.sslServerKey == null) + && (cfg.sslCACert != null -> !(cfg.sslServerCert == null || cfg.sslServerKey == null)); message = "dovecot needs both sslServerCert and sslServerKey defined for working crypto"; } { assertion = cfg.showPAMFailure -> cfg.enablePAM; message = "dovecot is configured with showPAMFailure while enablePAM is disabled"; } - { assertion = (cfg.sieveScripts != {}) -> ((cfg.mailUser != null) && (cfg.mailGroup != null)); + { assertion = cfg.sieveScripts != {} -> (cfg.mailUser != null && cfg.mailGroup != null); message = "dovecot requires mailUser and mailGroup to be set when sieveScripts is set"; } ]; diff --git a/nixos/modules/services/misc/bepasty.nix b/nixos/modules/services/misc/bepasty.nix index 006feca42b32..87d360681445 100644 --- a/nixos/modules/services/misc/bepasty.nix +++ b/nixos/modules/services/misc/bepasty.nix @@ -143,7 +143,7 @@ in serviceConfig = { Type = "simple"; PrivateTmp = true; - ExecStartPre = assert !isNull server.secretKeyFile; pkgs.writeScript "bepasty-server.${name}-init" '' + ExecStartPre = assert server.secretKeyFile != null; pkgs.writeScript "bepasty-server.${name}-init" '' #!/bin/sh mkdir -p "${server.workDir}" mkdir -p "${server.dataDir}" diff --git a/nixos/modules/services/misc/errbot.nix b/nixos/modules/services/misc/errbot.nix index ac6ba2181de2..256adce2f02e 100644 --- a/nixos/modules/services/misc/errbot.nix +++ b/nixos/modules/services/misc/errbot.nix @@ |