3
0
Fork 0
forked from mirrors/nixpkgs

treewide: deprecate isNull

https://nixos.org/manual/nix/stable/language/builtins.html#builtins-isNull
This commit is contained in:
Felix Buehler 2023-03-05 22:08:45 +01:00
parent 794f34657e
commit d10e69c86b
30 changed files with 62 additions and 63 deletions

View file

@ -422,7 +422,7 @@ ${expr "" v}
(if v then "True" else "False")
else if isFunction v then
abort "generators.toDhall: cannot convert a function to Dhall"
else if isNull v then
else if v == null then
abort "generators.toDhall: cannot convert a null to Dhall"
else
builtins.toJSON v;

View file

@ -3,7 +3,7 @@ let
pkgs = import ../../.. {};
inherit (pkgs) lib;
getDeps = _: pkg: {
deps = builtins.filter (x: !isNull x) (map (x: x.pname or null) (pkg.propagatedBuildInputs or []));
deps = builtins.filter (x: x != null) (map (x: x.pname or null) (pkg.propagatedBuildInputs or []));
broken = (pkg.meta.hydraPlatforms or [null]) == [];
};
in

View file

@ -65,7 +65,7 @@ let
};
};
filterDTBs = src: if isNull cfg.filter
filterDTBs = src: if cfg.filter == null
then "${src}/dtbs"
else
pkgs.runCommand "dtbs-filtered" {} ''
@ -93,8 +93,8 @@ let
# Fill in `dtboFile` for each overlay if not set already.
# Existence of one of these is guarded by assertion below
withDTBOs = xs: flip map xs (o: o // { dtboFile =
if isNull o.dtboFile then
if !isNull o.dtsFile then compileDTS o.name o.dtsFile
if o.dtboFile == null then
if o.dtsFile != null then compileDTS o.name o.dtsFile
else compileDTS o.name (pkgs.writeText "dts" o.dtsText)
else o.dtboFile; } );
@ -181,7 +181,7 @@ in
config = mkIf (cfg.enable) {
assertions = let
invalidOverlay = o: isNull o.dtsFile && isNull o.dtsText && isNull o.dtboFile;
invalidOverlay = o: (o.dtsFile == null) && (o.dtsText == null) && (o.dtboFile == null);
in lib.singleton {
assertion = lib.all (o: !invalidOverlay o) cfg.overlays;
message = ''

View file

@ -19,7 +19,7 @@ let
];
mkArgs = rule:
if (isNull rule.args) then ""
if (rule.args == null) then ""
else if (length rule.args == 0) then "args"
else "args ${concatStringsSep " " rule.args}";
@ -27,9 +27,9 @@ let
let
opts = mkOpts rule;
as = optionalString (!isNull rule.runAs) "as ${rule.runAs}";
as = optionalString (rule.runAs != null) "as ${rule.runAs}";
cmd = optionalString (!isNull rule.cmd) "cmd ${rule.cmd}";
cmd = optionalString (rule.cmd != null) "cmd ${rule.cmd}";
args = mkArgs rule;
in

View file

@ -793,7 +793,7 @@ let
};
}));
motd = if isNull config.users.motdFile
motd = if config.users.motdFile == null
then pkgs.writeText "motd" config.users.motd
else config.users.motdFile;
@ -1233,7 +1233,7 @@ in
config = {
assertions = [
{
assertion = isNull config.users.motd || isNull config.users.motdFile;
assertion = config.users.motd == null || config.users.motdFile == null;
message = ''
Only one of users.motd and users.motdFile can be set.
'';

View file

@ -270,7 +270,7 @@ in
'';
})]);
environment.etc.${cfg.etcClusterAdminKubeconfig}.source = mkIf (!isNull cfg.etcClusterAdminKubeconfig)
environment.etc.${cfg.etcClusterAdminKubeconfig}.source = mkIf (cfg.etcClusterAdminKubeconfig != null)
clusterAdminKubeconfig;
environment.systemPackages = mkIf (top.kubelet.enable || top.proxy.enable) [

View file

@ -5,8 +5,8 @@ let
cfg = config.services.undervolt;
mkPLimit = limit: window:
if (isNull limit && isNull window) then null
else assert asserts.assertMsg (!isNull limit && !isNull window) "Both power limit and window must be set";
if (limit == null && window == null) then null
else assert asserts.assertMsg (limit != null && window != null) "Both power limit and window must be set";
"${toString limit} ${toString window}";
cliArgs = lib.cli.toGNUCommandLine {} {
inherit (cfg)

View file

@ -362,7 +362,7 @@ in {
config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.openFirewall -> !isNull cfg.config;
assertion = cfg.openFirewall -> cfg.config != null;
message = "openFirewall can only be used with a declarative config";
}
];

View file

@ -513,22 +513,22 @@ in {
${indentLines 2 devices}
}
${optionalString (!isNull defaults) ''
${optionalString (defaults != null) ''
defaults {
${indentLines 2 defaults}
}
''}
${optionalString (!isNull blacklist) ''
${optionalString (blacklist != null) ''
blacklist {
${indentLines 2 blacklist}
}
''}
${optionalString (!isNull blacklist_exceptions) ''
${optionalString (blacklist_exceptions != null) ''
blacklist_exceptions {
${indentLines 2 blacklist_exceptions}
}
''}
${optionalString (!isNull overrides) ''
${optionalString (overrides != null) ''
overrides {
${indentLines 2 overrides}
}

View file

@ -9,7 +9,7 @@ let
listToValue = concatMapStringsSep ", " (generators.mkValueStringDefault { });
};
pkg = if isNull cfg.package then
pkg = if cfg.package == null then
pkgs.radicale
else
cfg.package;
@ -117,13 +117,13 @@ in {
}
];
warnings = optional (isNull cfg.package && versionOlder config.system.stateVersion "17.09") ''
warnings = optional (cfg.package == null && versionOlder config.system.stateVersion "17.09") ''
The configuration and storage formats of your existing Radicale
installation might be incompatible with the newest version.
For upgrade instructions see
https://radicale.org/2.1.html#documentation/migration-from-1xx-to-2xx.
Set services.radicale.package to suppress this warning.
'' ++ optional (isNull cfg.package && versionOlder config.system.stateVersion "20.09") ''
'' ++ optional (cfg.package == null && versionOlder config.system.stateVersion "20.09") ''
The configuration format of your existing Radicale installation might be
incompatible with the newest version. For upgrade instructions see
https://github.com/Kozea/Radicale/blob/3.0.6/NEWS.md#upgrade-checklist.

View file

@ -132,7 +132,7 @@ in
requires = lib.mkIf (!(isPathType cfg.repository)) [ "network-online.target" ];
environment.GIT_SSH_COMMAND = lib.mkIf (!(isNull cfg.sshKeyFile))
environment.GIT_SSH_COMMAND = lib.mkIf (cfg.sshKeyFile != null)
"${pkgs.openssh}/bin/ssh -i ${lib.escapeShellArg cfg.sshKeyFile}";
restartIfChanged = false;

View file

@ -16,7 +16,7 @@ let
if (any (str: k == str) secretKeys) then v
else if isString v then "'${v}'"
else if isBool v then boolToString v
else if isNull v then "null"
else if v == null then "null"
else toString v
;
in

View file

@ -10,12 +10,11 @@ let
format = pkgs.formats.ini {
mkKeyValue = key: value:
let
value' = if builtins.isNull value then
""
else if builtins.isBool value then
if value == true then "true" else "false"
else
toString value;
value' = lib.optionalString (value != null)
(if builtins.isBool value then
if value == true then "true" else "false"
else
toString value);
in "${key} = ${value'}";
};

View file

@ -73,28 +73,28 @@ in {
error = sourceArgs.error or args.error or null;
hasSource = lib.hasAttr variant args;
pname = builtins.replaceStrings [ "@" ] [ "at" ] ename;
broken = ! isNull error;
broken = error != null;
in
if hasSource then
lib.nameValuePair ename (
self.callPackage ({ melpaBuild, fetchurl, ... }@pkgargs:
melpaBuild {
inherit pname ename commit;
version = if isNull version then "" else
lib.concatStringsSep "." (map toString
version = lib.optionalString (version != null)
(lib.concatStringsSep "." (map toString
# Hack: Melpa archives contains versions with parse errors such as [ 4 4 -4 413 ] which should be 4.4-413
# This filter method is still technically wrong, but it's computationally cheap enough and tapers over the issue
(builtins.filter (n: n >= 0) version));
(builtins.filter (n: n >= 0) version)));
# TODO: Broken should not result in src being null (hack to avoid eval errors)
src = if (isNull sha256 || broken) then null else
src = if (sha256 == null || broken) then null else
lib.getAttr fetcher (fetcherGenerators args sourceArgs);
recipe = if isNull commit then null else
recipe = if commit == null then null else
fetchurl {
name = pname + "-recipe";
url = "https://raw.githubusercontent.com/melpa/melpa/${commit}/recipes/${ename}";
inherit sha256;
};
packageRequires = lib.optionals (! isNull deps)
packageRequires = lib.optionals (deps != null)
(map (dep: pkgargs.${dep} or self.${dep} or null)
deps);
meta = (sourceArgs.meta or {}) // {

View file

@ -70,7 +70,7 @@ let
substituteInPlace plugins/micromega/sos.ml --replace "; csdp" "; ${csdp}/bin/csdp"
substituteInPlace plugins/micromega/coq_micromega.ml --replace "System.is_in_system_path \"csdp\"" "true"
'';
ocamlPackages = if !isNull customOCamlPackages then customOCamlPackages
ocamlPackages = if customOCamlPackages != null then customOCamlPackages
else with versions; switch coq-version [
{ case = range "8.16" "8.17"; out = ocamlPackages_4_14; }
{ case = range "8.14" "8.15"; out = ocamlPackages_4_12; }

View file

@ -76,7 +76,7 @@ in
let
defaultPathOriginal = "/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
privileged-un-utils = if ((isNull newuidmapPath) && (isNull newgidmapPath)) then null else
privileged-un-utils = if ((newuidmapPath == null) && (newgidmapPath == null)) then null else
(runCommandLocal "privileged-un-utils" { } ''
mkdir -p "$out/bin"
ln -s ${lib.escapeShellArg newuidmapPath} "$out/bin/newuidmap"
@ -212,10 +212,10 @@ buildGoModule {
rm "$file"
done
''}
${lib.optionalString enableSuid (lib.warnIf (isNull starterSuidPath) "${projectName}: Null starterSuidPath when enableSuid produces non-SUID-ed starter-suid and run-time permission denial." ''
${lib.optionalString enableSuid (lib.warnIf (starterSuidPath == null) "${projectName}: Null starterSuidPath when enableSuid produces non-SUID-ed starter-suid and run-time permission denial." ''
chmod +x $out/libexec/${projectName}/bin/starter-suid
'')}
${lib.optionalString (enableSuid && !isNull starterSuidPath) ''
${lib.optionalString (enableSuid && (starterSuidPath != null)) ''
mv "$out"/libexec/${projectName}/bin/starter-suid{,.orig}
ln -s ${lib.escapeShellArg starterSuidPath} "$out/libexec/${projectName}/bin/starter-suid"
''}

View file

@ -52,7 +52,7 @@ let
inherit release releaseRev;
location = { inherit domain owner repo; };
} // optionalAttrs (args?fetcher) {inherit fetcher;});
fetched = fetch (if !isNull version then version else defaultVersion);
fetched = fetch (if version != null then version else defaultVersion);
display-pkg = n: sep: v:
let d = displayVersion.${n} or (if sep == "" then ".." else true); in
n + optionalString (v != "" && v != null) (switch d [

View file

@ -8,13 +8,13 @@ let
fmt = if args?sha256 then "zip" else "tarball";
pr = match "^#(.*)$" rev;
url = switch-if [
{ cond = isNull pr && !isNull (match "^github.*" domain);
{ cond = pr == null && (match "^github.*" domain) != null;
out = "https://${domain}/${owner}/${repo}/archive/${rev}.${ext}"; }
{ cond = !isNull pr && !isNull (match "^github.*" domain);
{ cond = pr != null && (match "^github.*" domain) != null;
out = "https://api.${domain}/repos/${owner}/${repo}/${fmt}/pull/${head pr}/head"; }
{ cond = isNull pr && !isNull (match "^gitlab.*" domain);
{ cond = pr == null && (match "^gitlab.*" domain) != null;
out = "https://${domain}/${owner}/${repo}/-/archive/${rev}/${repo}-${rev}.${ext}"; }
{ cond = !isNull (match "(www.)?mpi-sws.org" domain);
{ cond = (match "(www.)?mpi-sws.org" domain) != null;
out = "https://www.mpi-sws.org/~${owner}/${repo}/download/${repo}-${rev}.${ext}";}
] (throw "meta-fetch: no fetcher found for domain ${domain} on ${rev}");
fetch = x: if args?sha256 then fetchzip (x // { inherit sha256; }) else fetchTarball x;

View file

@ -89,7 +89,7 @@ let
renderSection = sectionName: attrs:
lib.pipe attrs [
(lib.mapAttrsToList renderLine)
(builtins.filter (v: !isNull v))
(builtins.filter (v: v != null))
(builtins.concatStringsSep "\n")
(section: ''
[${sectionName}]

View file

@ -45,7 +45,7 @@ rec {
runHook preInstall
bash install.sh -d $out/share/themes -t all \
${lib.optionalString (tweaks != []) "--tweaks " + builtins.toString tweaks} \
${lib.optionalString (!isNull border-radius) ("--round " + builtins.toString border-radius + "px")}
${lib.optionalString (border-radius != null) ("--round " + builtins.toString border-radius + "px")}
${lib.optionalString withWallpapers ''
mkdir -p $out/share/backgrounds
cp src/wallpaper/{1080p,2k,4k}.jpg $out/share/backgrounds

View file

@ -9,7 +9,7 @@ stdenv.mkDerivation (attrs // {
depsBuildBuild = [ nim_builder ] ++ depsBuildBuild;
nativeBuildInputs = [ nim ] ++ nativeBuildInputs;
configurePhase = if isNull configurePhase then ''
configurePhase = if (configurePhase == null) then ''
runHook preConfigure
export NIX_NIM_BUILD_INPUTS=''${pkgsHostTarget[@]} $NIX_NIM_BUILD_INPUTS
nim_builder --phase:configure
@ -17,21 +17,21 @@ stdenv.mkDerivation (attrs // {
'' else
configurePhase;
buildPhase = if isNull buildPhase then ''
buildPhase = if (buildPhase == null) then ''
runHook preBuild
nim_builder --phase:build
runHook postBuild
'' else
buildPhase;
checkPhase = if isNull checkPhase then ''
checkPhase = if (checkPhase == null) then ''
runHook preCheck
nim_builder --phase:check
runHook postCheck
'' else
checkPhase;
installPhase = if isNull installPhase then ''
installPhase = if (installPhase == null) then ''
runHook preInstall
nim_builder --phase:install
runHook postInstall

View file

@ -35,7 +35,7 @@ buildPythonPackage rec {
cffi
] ++ lib.optionals gurobiSupport ([
gurobipy
] ++ lib.optional (builtins.isNull gurobiHome) gurobi);
] ++ lib.optional (gurobiHome == null) gurobi);
# Source files have CRLF terminators, which make patch error out when supplied
# with diffs made on *nix machines
@ -58,7 +58,7 @@ buildPythonPackage rec {
# Make MIP use the Gurobi solver, if configured to do so
makeWrapperArgs = lib.optional gurobiSupport
"--set GUROBI_HOME ${if builtins.isNull gurobiHome then gurobi.outPath else gurobiHome}";
"--set GUROBI_HOME ${if gurobiHome == null then gurobi.outPath else gurobiHome}";
# Tests that rely on Gurobi are activated only when Gurobi support is enabled
disabledTests = lib.optional (!gurobiSupport) "gurobi";

View file

@ -4,7 +4,7 @@
}:
let
wafToolsArg = with lib.strings;
optionalString (!isNull withTools) " --tools=\"${concatStringsSep "," withTools}\"";
optionalString (withTools != null) " --tools=\"${concatStringsSep "," withTools}\"";
in
stdenv.mkDerivation rec {
pname = "waf";

View file

@ -50,7 +50,7 @@ let
{
nativeBuildInputs =
(old.nativeBuildInputs or [ ])
++ lib.optionals (!(builtins.isNull buildSystem)) [ buildSystem ]
++ lib.optionals (buildSystem != null) [ buildSystem ]
++ map (a: self.${a}) extraAttrs;
}
)

View file

@ -16,7 +16,7 @@ let
pkgs' = lib.mapAttrs (_: mods: lib.filterAttrs isAvailable mods) pkgs;
isAvailable = _: mod:
if isNull build then
if (build == null) then
true
else if build.isTiles then
mod.forTiles or false

View file

@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
SDL
];
makeFlags = (if isNull SDL then [] else [ "SDL=yes" ]) ++ [
makeFlags = (lib.optionals (SDL != null) [ "SDL=yes" ]) ++ [
"PREFIX=$(out)"
# force platform's cc on darwin, otherwise gcc is used
"CC=${stdenv.cc.targetPrefix}cc"

View file

@ -25,7 +25,7 @@ let
else "core";
targetArch =
if isNull targetArchitecture
if targetArchitecture == null
then defaultTargetArchitecture
else targetArchitecture;
in

View file

@ -206,7 +206,7 @@ let
checkDependencyList = checkDependencyList' [];
checkDependencyList' = positions: name: deps: lib.flip lib.imap1 deps (index: dep:
if lib.isDerivation dep || isNull dep || builtins.typeOf dep == "string" || builtins.typeOf dep == "path" then dep
if lib.isDerivation dep || dep == null || builtins.typeOf dep == "string" || builtins.typeOf dep == "path" then dep
else if lib.isList dep then checkDependencyList' ([index] ++ positions) name dep
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}");
in if builtins.length erroneousHardeningFlags != 0

View file

@ -20,14 +20,14 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [
cmake
] ++ lib.optionals (!isNull python) [
] ++ lib.optionals (python != null) [
python
swig
];
cmakeFlags = [
"-DPLFIT_USE_OPENMP=ON"
] ++ lib.optionals (!isNull python) [
] ++ lib.optionals (python != null) [
"-DPLFIT_COMPILE_PYTHON_MODULE=ON"
];

View file

@ -6,7 +6,7 @@
let
buildExtension = lib.makeOverridable
({ name, gawkextlib, extraBuildInputs ? [ ], doCheck ? true }:
let is_extension = !isNull gawkextlib;
let is_extension = gawkextlib != null;
in stdenv.mkDerivation rec {
pname = "gawkextlib-${name}";
version = "unstable-2019-11-21";