treewide: deprecate isNull

https://nixos.org/manual/nix/stable/language/builtins.html#builtins-isNull

+62 -63
+1 -1
lib/generators.nix
··· 422 422 (if v then "True" else "False") 423 423 else if isFunction v then 424 424 abort "generators.toDhall: cannot convert a function to Dhall" 425 - else if isNull v then 425 + else if v == null then 426 426 abort "generators.toDhall: cannot convert a null to Dhall" 427 427 else 428 428 builtins.toJSON v;
+1 -1
maintainers/scripts/haskell/dependencies.nix
··· 3 3 pkgs = import ../../.. {}; 4 4 inherit (pkgs) lib; 5 5 getDeps = _: pkg: { 6 - deps = builtins.filter (x: !isNull x) (map (x: x.pname or null) (pkg.propagatedBuildInputs or [])); 6 + deps = builtins.filter (x: x != null) (map (x: x.pname or null) (pkg.propagatedBuildInputs or [])); 7 7 broken = (pkg.meta.hydraPlatforms or [null]) == []; 8 8 }; 9 9 in
+4 -4
nixos/modules/hardware/device-tree.nix
··· 65 65 }; 66 66 }; 67 67 68 - filterDTBs = src: if isNull cfg.filter 68 + filterDTBs = src: if cfg.filter == null 69 69 then "${src}/dtbs" 70 70 else 71 71 pkgs.runCommand "dtbs-filtered" {} '' ··· 93 93 # Fill in `dtboFile` for each overlay if not set already. 94 94 # Existence of one of these is guarded by assertion below 95 95 withDTBOs = xs: flip map xs (o: o // { dtboFile = 96 - if isNull o.dtboFile then 97 - if !isNull o.dtsFile then compileDTS o.name o.dtsFile 96 + if o.dtboFile == null then 97 + if o.dtsFile != null then compileDTS o.name o.dtsFile 98 98 else compileDTS o.name (pkgs.writeText "dts" o.dtsText) 99 99 else o.dtboFile; } ); 100 100 ··· 181 181 config = mkIf (cfg.enable) { 182 182 183 183 assertions = let 184 - invalidOverlay = o: isNull o.dtsFile && isNull o.dtsText && isNull o.dtboFile; 184 + invalidOverlay = o: (o.dtsFile == null) && (o.dtsText == null) && (o.dtboFile == null); 185 185 in lib.singleton { 186 186 assertion = lib.all (o: !invalidOverlay o) cfg.overlays; 187 187 message = ''
+3 -3
nixos/modules/security/doas.nix
··· 19 19 ]; 20 20 21 21 mkArgs = rule: 22 - if (isNull rule.args) then "" 22 + if (rule.args == null) then "" 23 23 else if (length rule.args == 0) then "args" 24 24 else "args ${concatStringsSep " " rule.args}"; 25 25 ··· 27 27 let 28 28 opts = mkOpts rule; 29 29 30 - as = optionalString (!isNull rule.runAs) "as ${rule.runAs}"; 30 + as = optionalString (rule.runAs != null) "as ${rule.runAs}"; 31 31 32 - cmd = optionalString (!isNull rule.cmd) "cmd ${rule.cmd}"; 32 + cmd = optionalString (rule.cmd != null) "cmd ${rule.cmd}"; 33 33 34 34 args = mkArgs rule; 35 35 in
+2 -2
nixos/modules/security/pam.nix
··· 793 793 }; 794 794 })); 795 795 796 - motd = if isNull config.users.motdFile 796 + motd = if config.users.motdFile == null 797 797 then pkgs.writeText "motd" config.users.motd 798 798 else config.users.motdFile; 799 799 ··· 1233 1233 config = { 1234 1234 assertions = [ 1235 1235 { 1236 - assertion = isNull config.users.motd || isNull config.users.motdFile; 1236 + assertion = config.users.motd == null || config.users.motdFile == null; 1237 1237 message = '' 1238 1238 Only one of users.motd and users.motdFile can be set. 1239 1239 '';
+1 -1
nixos/modules/services/cluster/kubernetes/pki.nix
··· 270 270 ''; 271 271 })]); 272 272 273 - environment.etc.${cfg.etcClusterAdminKubeconfig}.source = mkIf (!isNull cfg.etcClusterAdminKubeconfig) 273 + environment.etc.${cfg.etcClusterAdminKubeconfig}.source = mkIf (cfg.etcClusterAdminKubeconfig != null) 274 274 clusterAdminKubeconfig; 275 275 276 276 environment.systemPackages = mkIf (top.kubelet.enable || top.proxy.enable) [
+2 -2
nixos/modules/services/hardware/undervolt.nix
··· 5 5 cfg = config.services.undervolt; 6 6 7 7 mkPLimit = limit: window: 8 - if (isNull limit && isNull window) then null 9 - else assert asserts.assertMsg (!isNull limit && !isNull window) "Both power limit and window must be set"; 8 + if (limit == null && window == null) then null 9 + else assert asserts.assertMsg (limit != null && window != null) "Both power limit and window must be set"; 10 10 "${toString limit} ${toString window}"; 11 11 cliArgs = lib.cli.toGNUCommandLine {} { 12 12 inherit (cfg)
+1 -1
nixos/modules/services/home-automation/home-assistant.nix
··· 362 362 config = mkIf cfg.enable { 363 363 assertions = [ 364 364 { 365 - assertion = cfg.openFirewall -> !isNull cfg.config; 365 + assertion = cfg.openFirewall -> cfg.config != null; 366 366 message = "openFirewall can only be used with a declarative config"; 367 367 } 368 368 ];
+4 -4
nixos/modules/services/networking/multipath.nix
··· 513 513 ${indentLines 2 devices} 514 514 } 515 515 516 - ${optionalString (!isNull defaults) '' 516 + ${optionalString (defaults != null) '' 517 517 defaults { 518 518 ${indentLines 2 defaults} 519 519 } 520 520 ''} 521 - ${optionalString (!isNull blacklist) '' 521 + ${optionalString (blacklist != null) '' 522 522 blacklist { 523 523 ${indentLines 2 blacklist} 524 524 } 525 525 ''} 526 - ${optionalString (!isNull blacklist_exceptions) '' 526 + ${optionalString (blacklist_exceptions != null) '' 527 527 blacklist_exceptions { 528 528 ${indentLines 2 blacklist_exceptions} 529 529 } 530 530 ''} 531 - ${optionalString (!isNull overrides) '' 531 + ${optionalString (overrides != null) '' 532 532 overrides { 533 533 ${indentLines 2 overrides} 534 534 }
+3 -3
nixos/modules/services/networking/radicale.nix
··· 9 9 listToValue = concatMapStringsSep ", " (generators.mkValueStringDefault { }); 10 10 }; 11 11 12 - pkg = if isNull cfg.package then 12 + pkg = if cfg.package == null then 13 13 pkgs.radicale 14 14 else 15 15 cfg.package; ··· 117 117 } 118 118 ]; 119 119 120 - warnings = optional (isNull cfg.package && versionOlder config.system.stateVersion "17.09") '' 120 + warnings = optional (cfg.package == null && versionOlder config.system.stateVersion "17.09") '' 121 121 The configuration and storage formats of your existing Radicale 122 122 installation might be incompatible with the newest version. 123 123 For upgrade instructions see 124 124 https://radicale.org/2.1.html#documentation/migration-from-1xx-to-2xx. 125 125 Set services.radicale.package to suppress this warning. 126 - '' ++ optional (isNull cfg.package && versionOlder config.system.stateVersion "20.09") '' 126 + '' ++ optional (cfg.package == null && versionOlder config.system.stateVersion "20.09") '' 127 127 The configuration format of your existing Radicale installation might be 128 128 incompatible with the newest version. For upgrade instructions see 129 129 https://github.com/Kozea/Radicale/blob/3.0.6/NEWS.md#upgrade-checklist.
+1 -1
nixos/modules/services/system/self-deploy.nix
··· 132 132 133 133 requires = lib.mkIf (!(isPathType cfg.repository)) [ "network-online.target" ]; 134 134 135 - environment.GIT_SSH_COMMAND = lib.mkIf (!(isNull cfg.sshKeyFile)) 135 + environment.GIT_SSH_COMMAND = lib.mkIf (cfg.sshKeyFile != null) 136 136 "${pkgs.openssh}/bin/ssh -i ${lib.escapeShellArg cfg.sshKeyFile}"; 137 137 138 138 restartIfChanged = false;
+1 -1
nixos/modules/services/web-apps/dolibarr.nix
··· 16 16 if (any (str: k == str) secretKeys) then v 17 17 else if isString v then "'${v}'" 18 18 else if isBool v then boolToString v 19 - else if isNull v then "null" 19 + else if v == null then "null" 20 20 else toString v 21 21 ; 22 22 in
+5 -6
nixos/modules/services/web-apps/writefreely.nix
··· 10 10 format = pkgs.formats.ini { 11 11 mkKeyValue = key: value: 12 12 let 13 - value' = if builtins.isNull value then 14 - "" 15 - else if builtins.isBool value then 16 - if value == true then "true" else "false" 17 - else 18 - toString value; 13 + value' = lib.optionalString (value != null) 14 + (if builtins.isBool value then 15 + if value == true then "true" else "false" 16 + else 17 + toString value); 19 18 in "${key} = ${value'}"; 20 19 }; 21 20
+7 -7
pkgs/applications/editors/emacs/elisp-packages/libgenerated.nix
··· 73 73 error = sourceArgs.error or args.error or null; 74 74 hasSource = lib.hasAttr variant args; 75 75 pname = builtins.replaceStrings [ "@" ] [ "at" ] ename; 76 - broken = ! isNull error; 76 + broken = error != null; 77 77 in 78 78 if hasSource then 79 79 lib.nameValuePair ename ( 80 80 self.callPackage ({ melpaBuild, fetchurl, ... }@pkgargs: 81 81 melpaBuild { 82 82 inherit pname ename commit; 83 - version = if isNull version then "" else 84 - lib.concatStringsSep "." (map toString 83 + version = lib.optionalString (version != null) 84 + (lib.concatStringsSep "." (map toString 85 85 # Hack: Melpa archives contains versions with parse errors such as [ 4 4 -4 413 ] which should be 4.4-413 86 86 # This filter method is still technically wrong, but it's computationally cheap enough and tapers over the issue 87 - (builtins.filter (n: n >= 0) version)); 87 + (builtins.filter (n: n >= 0) version))); 88 88 # TODO: Broken should not result in src being null (hack to avoid eval errors) 89 - src = if (isNull sha256 || broken) then null else 89 + src = if (sha256 == null || broken) then null else 90 90 lib.getAttr fetcher (fetcherGenerators args sourceArgs); 91 - recipe = if isNull commit then null else 91 + recipe = if commit == null then null else 92 92 fetchurl { 93 93 name = pname + "-recipe"; 94 94 url = "https://raw.githubusercontent.com/melpa/melpa/${commit}/recipes/${ename}"; 95 95 inherit sha256; 96 96 }; 97 - packageRequires = lib.optionals (! isNull deps) 97 + packageRequires = lib.optionals (deps != null) 98 98 (map (dep: pkgargs.${dep} or self.${dep} or null) 99 99 deps); 100 100 meta = (sourceArgs.meta or {}) // {
+1 -1
pkgs/applications/science/logic/coq/default.nix
··· 70 70 substituteInPlace plugins/micromega/sos.ml --replace "; csdp" "; ${csdp}/bin/csdp" 71 71 substituteInPlace plugins/micromega/coq_micromega.ml --replace "System.is_in_system_path \"csdp\"" "true" 72 72 ''; 73 - ocamlPackages = if !isNull customOCamlPackages then customOCamlPackages 73 + ocamlPackages = if customOCamlPackages != null then customOCamlPackages 74 74 else with versions; switch coq-version [ 75 75 { case = range "8.16" "8.17"; out = ocamlPackages_4_14; } 76 76 { case = range "8.14" "8.15"; out = ocamlPackages_4_12; }
+3 -3
pkgs/applications/virtualization/singularity/generic.nix
··· 76 76 77 77 let 78 78 defaultPathOriginal = "/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"; 79 - privileged-un-utils = if ((isNull newuidmapPath) && (isNull newgidmapPath)) then null else 79 + privileged-un-utils = if ((newuidmapPath == null) && (newgidmapPath == null)) then null else 80 80 (runCommandLocal "privileged-un-utils" { } '' 81 81 mkdir -p "$out/bin" 82 82 ln -s ${lib.escapeShellArg newuidmapPath} "$out/bin/newuidmap" ··· 212 212 rm "$file" 213 213 done 214 214 ''} 215 - ${lib.optionalString enableSuid (lib.warnIf (isNull starterSuidPath) "${projectName}: Null starterSuidPath when enableSuid produces non-SUID-ed starter-suid and run-time permission denial." '' 215 + ${lib.optionalString enableSuid (lib.warnIf (starterSuidPath == null) "${projectName}: Null starterSuidPath when enableSuid produces non-SUID-ed starter-suid and run-time permission denial." '' 216 216 chmod +x $out/libexec/${projectName}/bin/starter-suid 217 217 '')} 218 - ${lib.optionalString (enableSuid && !isNull starterSuidPath) '' 218 + ${lib.optionalString (enableSuid && (starterSuidPath != null)) '' 219 219 mv "$out"/libexec/${projectName}/bin/starter-suid{,.orig} 220 220 ln -s ${lib.escapeShellArg starterSuidPath} "$out/libexec/${projectName}/bin/starter-suid" 221 221 ''}
+1 -1
pkgs/build-support/coq/default.nix
··· 52 52 inherit release releaseRev; 53 53 location = { inherit domain owner repo; }; 54 54 } // optionalAttrs (args?fetcher) {inherit fetcher;}); 55 - fetched = fetch (if !isNull version then version else defaultVersion); 55 + fetched = fetch (if version != null then version else defaultVersion); 56 56 display-pkg = n: sep: v: 57 57 let d = displayVersion.${n} or (if sep == "" then ".." else true); in 58 58 n + optionalString (v != "" && v != null) (switch d [
+4 -4
pkgs/build-support/coq/meta-fetch/default.nix
··· 8 8 fmt = if args?sha256 then "zip" else "tarball"; 9 9 pr = match "^#(.*)$" rev; 10 10 url = switch-if [ 11 - { cond = isNull pr && !isNull (match "^github.*" domain); 11 + { cond = pr == null && (match "^github.*" domain) != null; 12 12 out = "https://${domain}/${owner}/${repo}/archive/${rev}.${ext}"; } 13 - { cond = !isNull pr && !isNull (match "^github.*" domain); 13 + { cond = pr != null && (match "^github.*" domain) != null; 14 14 out = "https://api.${domain}/repos/${owner}/${repo}/${fmt}/pull/${head pr}/head"; } 15 - { cond = isNull pr && !isNull (match "^gitlab.*" domain); 15 + { cond = pr == null && (match "^gitlab.*" domain) != null; 16 16 out = "https://${domain}/${owner}/${repo}/-/archive/${rev}/${repo}-${rev}.${ext}"; } 17 - { cond = !isNull (match "(www.)?mpi-sws.org" domain); 17 + { cond = (match "(www.)?mpi-sws.org" domain) != null; 18 18 out = "https://www.mpi-sws.org/~${owner}/${repo}/download/${repo}-${rev}.${ext}";} 19 19 ] (throw "meta-fetch: no fetcher found for domain ${domain} on ${rev}"); 20 20 fetch = x: if args?sha256 then fetchzip (x // { inherit sha256; }) else fetchTarball x;
+1 -1
pkgs/build-support/make-desktopitem/default.nix
··· 89 89 renderSection = sectionName: attrs: 90 90 lib.pipe attrs [ 91 91 (lib.mapAttrsToList renderLine) 92 - (builtins.filter (v: !isNull v)) 92 + (builtins.filter (v: v != null)) 93 93 (builtins.concatStringsSep "\n") 94 94 (section: '' 95 95 [${sectionName}]
+1 -1
pkgs/data/themes/orchis-theme/default.nix
··· 45 45 runHook preInstall 46 46 bash install.sh -d $out/share/themes -t all \ 47 47 ${lib.optionalString (tweaks != []) "--tweaks " + builtins.toString tweaks} \ 48 - ${lib.optionalString (!isNull border-radius) ("--round " + builtins.toString border-radius + "px")} 48 + ${lib.optionalString (border-radius != null) ("--round " + builtins.toString border-radius + "px")} 49 49 ${lib.optionalString withWallpapers '' 50 50 mkdir -p $out/share/backgrounds 51 51 cp src/wallpaper/{1080p,2k,4k}.jpg $out/share/backgrounds
+4 -4
pkgs/development/nim-packages/build-nim-package/default.nix
··· 9 9 depsBuildBuild = [ nim_builder ] ++ depsBuildBuild; 10 10 nativeBuildInputs = [ nim ] ++ nativeBuildInputs; 11 11 12 - configurePhase = if isNull configurePhase then '' 12 + configurePhase = if (configurePhase == null) then '' 13 13 runHook preConfigure 14 14 export NIX_NIM_BUILD_INPUTS=''${pkgsHostTarget[@]} $NIX_NIM_BUILD_INPUTS 15 15 nim_builder --phase:configure ··· 17 17 '' else 18 18 configurePhase; 19 19 20 - buildPhase = if isNull buildPhase then '' 20 + buildPhase = if (buildPhase == null) then '' 21 21 runHook preBuild 22 22 nim_builder --phase:build 23 23 runHook postBuild 24 24 '' else 25 25 buildPhase; 26 26 27 - checkPhase = if isNull checkPhase then '' 27 + checkPhase = if (checkPhase == null) then '' 28 28 runHook preCheck 29 29 nim_builder --phase:check 30 30 runHook postCheck 31 31 '' else 32 32 checkPhase; 33 33 34 - installPhase = if isNull installPhase then '' 34 + installPhase = if (installPhase == null) then '' 35 35 runHook preInstall 36 36 nim_builder --phase:install 37 37 runHook postInstall
+2 -2
pkgs/development/python-modules/mip/default.nix
··· 35 35 cffi 36 36 ] ++ lib.optionals gurobiSupport ([ 37 37 gurobipy 38 - ] ++ lib.optional (builtins.isNull gurobiHome) gurobi); 38 + ] ++ lib.optional (gurobiHome == null) gurobi); 39 39 40 40 # Source files have CRLF terminators, which make patch error out when supplied 41 41 # with diffs made on *nix machines ··· 58 58 59 59 # Make MIP use the Gurobi solver, if configured to do so 60 60 makeWrapperArgs = lib.optional gurobiSupport 61 - "--set GUROBI_HOME ${if builtins.isNull gurobiHome then gurobi.outPath else gurobiHome}"; 61 + "--set GUROBI_HOME ${if gurobiHome == null then gurobi.outPath else gurobiHome}"; 62 62 63 63 # Tests that rely on Gurobi are activated only when Gurobi support is enabled 64 64 disabledTests = lib.optional (!gurobiSupport) "gurobi";
+1 -1
pkgs/development/tools/build-managers/waf/default.nix
··· 4 4 }: 5 5 let 6 6 wafToolsArg = with lib.strings; 7 - optionalString (!isNull withTools) " --tools=\"${concatStringsSep "," withTools}\""; 7 + optionalString (withTools != null) " --tools=\"${concatStringsSep "," withTools}\""; 8 8 in 9 9 stdenv.mkDerivation rec { 10 10 pname = "waf";
+1 -1
pkgs/development/tools/poetry2nix/poetry2nix/overrides/default.nix
··· 50 50 { 51 51 nativeBuildInputs = 52 52 (old.nativeBuildInputs or [ ]) 53 - ++ lib.optionals (!(builtins.isNull buildSystem)) [ buildSystem ] 53 + ++ lib.optionals (buildSystem != null) [ buildSystem ] 54 54 ++ map (a: self.${a}) extraAttrs; 55 55 } 56 56 )
+1 -1
pkgs/games/cataclysm-dda/pkgs/default.nix
··· 16 16 pkgs' = lib.mapAttrs (_: mods: lib.filterAttrs isAvailable mods) pkgs; 17 17 18 18 isAvailable = _: mod: 19 - if isNull build then 19 + if (build == null) then 20 20 true 21 21 else if build.isTiles then 22 22 mod.forTiles or false
+1 -1
pkgs/games/curseofwar/default.nix
··· 20 20 SDL 21 21 ]; 22 22 23 - makeFlags = (if isNull SDL then [] else [ "SDL=yes" ]) ++ [ 23 + makeFlags = (lib.optionals (SDL != null) [ "SDL=yes" ]) ++ [ 24 24 "PREFIX=$(out)" 25 25 # force platform's cc on darwin, otherwise gcc is used 26 26 "CC=${stdenv.cc.targetPrefix}cc"
+1 -1
pkgs/servers/nosql/arangodb/default.nix
··· 25 25 else "core"; 26 26 27 27 targetArch = 28 - if isNull targetArchitecture 28 + if targetArchitecture == null 29 29 then defaultTargetArchitecture 30 30 else targetArchitecture; 31 31 in
+1 -1
pkgs/stdenv/generic/make-derivation.nix
··· 206 206 207 207 checkDependencyList = checkDependencyList' []; 208 208 checkDependencyList' = positions: name: deps: lib.flip lib.imap1 deps (index: dep: 209 - if lib.isDerivation dep || isNull dep || builtins.typeOf dep == "string" || builtins.typeOf dep == "path" then dep 209 + if lib.isDerivation dep || dep == null || builtins.typeOf dep == "string" || builtins.typeOf dep == "path" then dep 210 210 else if lib.isList dep then checkDependencyList' ([index] ++ positions) name dep 211 211 else throw "Dependency is not of a valid type: ${lib.concatMapStrings (ix: "element ${toString ix} of ") ([index] ++ positions)}${name} for ${attrs.name or attrs.pname}"); 212 212 in if builtins.length erroneousHardeningFlags != 0
+2 -2
pkgs/tools/misc/plfit/default.nix
··· 20 20 21 21 nativeBuildInputs = [ 22 22 cmake 23 - ] ++ lib.optionals (!isNull python) [ 23 + ] ++ lib.optionals (python != null) [ 24 24 python 25 25 swig 26 26 ]; 27 27 28 28 cmakeFlags = [ 29 29 "-DPLFIT_USE_OPENMP=ON" 30 - ] ++ lib.optionals (!isNull python) [ 30 + ] ++ lib.optionals (python != null) [ 31 31 "-DPLFIT_COMPILE_PYTHON_MODULE=ON" 32 32 ]; 33 33
+1 -1
pkgs/tools/text/gawk/gawkextlib.nix
··· 6 6 let 7 7 buildExtension = lib.makeOverridable 8 8 ({ name, gawkextlib, extraBuildInputs ? [ ], doCheck ? true }: 9 - let is_extension = !isNull gawkextlib; 9 + let is_extension = gawkextlib != null; 10 10 in stdenv.mkDerivation rec { 11 11 pname = "gawkextlib-${name}"; 12 12 version = "unstable-2019-11-21";