From f3719756b550113c1acbbab00c89a56fb77256f2 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Sat, 24 Jun 2023 20:19:19 +0200 Subject: treewide: use optionalString instead of 'then ""' --- nixos/modules/services/backup/borgbackup.nix | 2 +- .../continuous-integration/jenkins/default.nix | 6 ++---- nixos/modules/services/misc/cgminer.nix | 2 +- nixos/modules/services/misc/sourcehut/default.nix | 6 +++--- .../services/monitoring/prometheus/exporters/pve.nix | 12 ++++++------ nixos/modules/services/networking/biboumi.nix | 3 +-- nixos/modules/services/networking/cjdns.nix | 2 +- nixos/modules/services/networking/libreswan.nix | 4 ++-- nixos/modules/services/networking/murmur.nix | 20 ++++++++++---------- nixos/modules/services/networking/nsd.nix | 4 ++-- nixos/modules/services/networking/ssh/lshd.nix | 4 +--- nixos/modules/services/scheduling/fcron.nix | 2 +- nixos/modules/services/web-apps/invidious.nix | 2 +- nixos/modules/services/web-apps/invoiceplane.nix | 2 +- nixos/modules/services/web-apps/peertube.nix | 2 +- nixos/modules/services/web-servers/lighttpd/cgit.nix | 2 +- .../modules/services/x11/desktop-managers/phosh.nix | 2 +- nixos/modules/system/boot/kernel_config.nix | 7 +++---- nixos/modules/system/boot/loader/grub/grub.nix | 4 ++-- nixos/modules/system/boot/systemd/user.nix | 2 +- pkgs/applications/editors/texmacs/darwin.nix | 8 ++++---- pkgs/applications/editors/vscode/vscodium.nix | 2 +- .../networking/browsers/chromium/default.nix | 4 +--- .../networking/browsers/microsoft-edge/browser.nix | 8 ++------ pkgs/applications/office/libreoffice/default.nix | 2 +- .../applications/science/logic/hol_light/default.nix | 3 +-- pkgs/applications/science/math/sage/sage-tests.nix | 2 +- .../version-management/sapling/default.nix | 2 +- pkgs/applications/window-managers/sway/wrapper.nix | 2 +- pkgs/build-support/bintools-wrapper/default.nix | 16 ++++++++-------- pkgs/build-support/cc-wrapper/default.nix | 14 +++++++------- pkgs/build-support/docker/default.nix | 2 +- pkgs/build-support/fetchgithub/default.nix | 2 +- pkgs/build-support/kernel/make-initrd-ng.nix | 2 +- pkgs/build-support/nix-gitignore/default.nix | 2 +- .../rust/build-rust-crate/configure-crate.nix | 2 +- pkgs/build-support/vm/default.nix | 2 +- .../stylesheets/xslt/docbook-xsl/default.nix | 2 +- .../compilers/purescript/purescript/default.nix | 5 +---- .../interpreters/acl2/libipasirglucose4/default.nix | 2 +- .../interpreters/python/mk-python-derivation.nix | 2 +- pkgs/development/interpreters/python/wrapper.nix | 2 +- pkgs/development/libraries/ffmpeg/generic.nix | 2 +- pkgs/development/libraries/opencv/tests.nix | 2 +- pkgs/development/libraries/qt-4.x/4.8/default.nix | 6 +++--- pkgs/development/mobile/titaniumenv/build-app.nix | 3 +-- .../python-modules/azure-common/default.nix | 2 +- .../python-modules/azure-mgmt-common/default.nix | 2 +- pkgs/development/python-modules/tensorflow/bin.nix | 2 +- .../ruby-modules/bundled-common/default.nix | 11 ++++++----- pkgs/development/ruby-modules/gem/default.nix | 2 +- pkgs/development/tools/misc/distcc/default.nix | 2 +- pkgs/os-specific/linux/kernel/manual-config.nix | 5 +++-- 53 files changed, 101 insertions(+), 116 deletions(-) diff --git a/nixos/modules/services/backup/borgbackup.nix b/nixos/modules/services/backup/borgbackup.nix index 0da70112d48d..3b44f097ab79 100644 --- a/nixos/modules/services/backup/borgbackup.nix +++ b/nixos/modules/services/backup/borgbackup.nix @@ -33,7 +33,7 @@ let } trap on_exit EXIT - archiveName="${if cfg.archiveBaseName == null then "" else cfg.archiveBaseName + "-"}$(date ${cfg.dateFormat})" + archiveName="${optionalString (cfg.archiveBaseName != null) (cfg.archiveBaseName + "-")}$(date ${cfg.dateFormat})" archiveSuffix="${optionalString cfg.appendFailedSuffix ".failed"}" ${cfg.preHook} '' + optionalString cfg.doInit '' diff --git a/nixos/modules/services/continuous-integration/jenkins/default.nix b/nixos/modules/services/continuous-integration/jenkins/default.nix index a9a587b41e88..e4d54b0cb0f4 100644 --- a/nixos/modules/services/continuous-integration/jenkins/default.nix +++ b/nixos/modules/services/continuous-integration/jenkins/default.nix @@ -210,9 +210,7 @@ in { preStart = let replacePlugins = - if cfg.plugins == null - then "" - else + optionalString (cfg.plugins != null) ( let pluginCmds = lib.attrsets.mapAttrsToList (n: v: "cp ${v} ${cfg.home}/plugins/${n}.jpi") cfg.plugins; @@ -220,7 +218,7 @@ in { rm -r ${cfg.home}/plugins || true mkdir -p ${cfg.home}/plugins ${lib.strings.concatStringsSep "\n" pluginCmds} - ''; + ''); in '' rm -rf ${cfg.home}/war ${replacePlugins} diff --git a/nixos/modules/services/misc/cgminer.nix b/nixos/modules/services/misc/cgminer.nix index fced106cb325..81eb42cbc5de 100644 --- a/nixos/modules/services/misc/cgminer.nix +++ b/nixos/modules/services/misc/cgminer.nix @@ -11,7 +11,7 @@ let mapAttrsToList (n: v: ''"${n}": "${(concatStringsSep "," (map convType v))}"'') (foldAttrs (n: a: [n] ++ a) [] cfg.hardware); mergedConfig = with builtins; - mapAttrsToList (n: v: ''"${n}": ${if isBool v then "" else ''"''}${convType v}${if isBool v then "" else ''"''}'') + mapAttrsToList (n: v: ''"${n}": ${if isBool v then (convType v) else ''"${convType v}"''}'') cfg.config; cgminerConfig = pkgs.writeText "cgminer.conf" '' diff --git a/nixos/modules/services/misc/sourcehut/default.nix b/nixos/modules/services/misc/sourcehut/default.nix index d4391bc49e31..580a009a0ad3 100644 --- a/nixos/modules/services/misc/sourcehut/default.nix +++ b/nixos/modules/services/misc/sourcehut/default.nix @@ -8,13 +8,13 @@ let settingsFormat = pkgs.formats.ini { listToValue = concatMapStringsSep "," (generators.mkValueStringDefault {}); mkKeyValue = k: v: - if v == null then "" - else generators.mkKeyValueDefault { + optionalString (v != null) + (generators.mkKeyValueDefault { mkValueString = v: if v == true then "yes" else if v == false then "no" else generators.mkValueStringDefault {} v; - } "=" k v; + } "=" k v); }; configIniOfService = srv: settingsFormat.generate "sourcehut-${srv}-config.ini" # Each service needs access to only a subset of sections (and secrets). diff --git a/nixos/modules/services/monitoring/prometheus/exporters/pve.nix b/nixos/modules/services/monitoring/prometheus/exporters/pve.nix index e02acad3ecd1..f95412efd7dd 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/pve.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/pve.nix @@ -104,12 +104,12 @@ in LoadCredential = "configFile:${computedConfigFile}"; ExecStart = '' ${cfg.package}/bin/pve_exporter \ - --${if cfg.collectors.status == true then "" else "no-"}collector.status \ - --${if cfg.collectors.version == true then "" else "no-"}collector.version \ - --${if cfg.collectors.node == true then "" else "no-"}collector.node \ - --${if cfg.collectors.cluster == true then "" else "no-"}collector.cluster \ - --${if cfg.collectors.resources == true then "" else "no-"}collector.resources \ - --${if cfg.collectors.config == true then "" else "no-"}collector.config \ + --${optionalString (!cfg.collectors.status) "no-"}collector.status \ + --${optionalString (!cfg.collectors.version) "no-"}collector.version \ + --${optionalString (!cfg.collectors.node) "no-"}collector.node \ + --${optionalString (!cfg.collectors.cluster) "no-"}collector.cluster \ + --${optionalString (!cfg.collectors.resources) "no-"}collector.resources \ + --${optionalString (!cfg.collectors.config) "no-"}collector.config \ %d/configFile \ ${toString cfg.port} ${cfg.listenAddress} ''; diff --git a/nixos/modules/services/networking/biboumi.nix b/nixos/modules/services/networking/biboumi.nix index 1428856764e6..d44a46b35a29 100644 --- a/nixos/modules/services/networking/biboumi.nix +++ b/nixos/modules/services/networking/biboumi.nix @@ -8,8 +8,7 @@ let settingsFile = pkgs.writeText "biboumi.cfg" ( generators.toKeyValue { mkKeyValue = k: v: - if v == null then "" - else generators.mkKeyValueDefault {} "=" k v; + lib.optionalString (v != null) (generators.mkKeyValueDefault {} "=" k v); } cfg.settings); need_CAP_NET_BIND_SERVICE = cfg.settings.identd_port != 0 && cfg.settings.identd_port < 1024; in diff --git a/nixos/modules/services/networking/cjdns.nix b/nixos/modules/services/networking/cjdns.nix index 5a19475161fd..80085da92702 100644 --- a/nixos/modules/services/networking/cjdns.nix +++ b/nixos/modules/services/networking/cjdns.nix @@ -239,7 +239,7 @@ in after = [ "network-online.target" ]; bindsTo = [ "network-online.target" ]; - preStart = if cfg.confFile != null then "" else '' + preStart = optionalString (cfg.confFile == null) '' [ -e /etc/cjdns.keys ] && source /etc/cjdns.keys if [ -z "$CJDNS_PRIVATE_KEY" ]; then diff --git a/nixos/modules/services/networking/libreswan.nix b/nixos/modules/services/networking/libreswan.nix index 785729d8f742..b8a3d6c8fdb5 100644 --- a/nixos/modules/services/networking/libreswan.nix +++ b/nixos/modules/services/networking/libreswan.nix @@ -14,8 +14,8 @@ let nonchars = filter (x : !(elem x.value chars)) (imap0 (i: v: {ind = i; value = v;}) (stringToCharacters str)); in - if length nonchars == 0 then "" - else substring (head nonchars).ind (add 1 (sub (last nonchars).ind (head nonchars).ind)) str; + lib.optionalString (length nonchars != 0) + (substring (head nonchars).ind (add 1 (sub (last nonchars).ind (head nonchars).ind)) str); indent = str: concatStrings (concatMap (s: [" " (trim [" " "\t"] s) "\n"]) (splitString "\n" str)); configText = indent (toString cfg.configSetup); connectionText = concatStrings (mapAttrsToList (n: v: diff --git a/nixos/modules/services/networking/murmur.nix b/nixos/modules/services/networking/murmur.nix index ebade7aa8e40..37a1ff8b2d34 100644 --- a/nixos/modules/services/networking/murmur.nix +++ b/nixos/modules/services/networking/murmur.nix @@ -19,8 +19,8 @@ let welcometext="${cfg.welcometext}" port=${toString cfg.port} - ${if cfg.hostName == "" then "" else "host="+cfg.hostName} - ${if cfg.password == "" then "" else "serverpassword="+cfg.password} + ${optionalString (cfg.hostName != "") "host=${cfg.hostName}"} + ${optionalString (cfg.password != "") "serverpassword=${cfg.password}"} bandwidth=${toString cfg.bandwidth} users=${toString cfg.users} @@ -32,17 +32,17 @@ let bonjour=${boolToString cfg.bonjour} sendversion=${boolToString cfg.sendVersion} - ${if cfg.registerName == "" then "" else "registerName="+cfg.registerName} - ${if cfg.registerPassword == "" then "" else "registerPassword="+cfg.registerPassword} - ${if cfg.registerUrl == "" then "" else "registerUrl="+cfg.registerUrl} - ${if cfg.registerHostname == "" then "" else "registerHostname="+cfg.registerHostname} + ${optionalString (cfg.registerName != "") "registerName=${cfg.registerName}"} + ${optionalString (cfg.registerPassword == "") "registerPassword=${cfg.registerPassword}"} + ${optionalString (cfg.registerUrl != "") "registerUrl=${cfg.registerUrl}"} + ${optionalString (cfg.registerHostname != "") "registerHostname=${cfg.registerHostname}"} certrequired=${boolToString cfg.clientCertRequired} - ${if cfg.sslCert == "" then "" else "sslCert="+cfg.sslCert} - ${if cfg.sslKey == "" then "" else "sslKey="+cfg.sslKey} - ${if cfg.sslCa == "" then "" else "sslCA="+cfg.sslCa} + ${optionalString (cfg.sslCert != "") "sslCert=${cfg.sslCert}"} + ${optionalString (cfg.sslKey != "") "sslKey=${cfg.sslKey}"} + ${optionalString (cfg.sslCa != "") "sslCA=${cfg.sslCa}"} - ${lib.optionalString (cfg.dbus != null) "dbus=${cfg.dbus}"} + ${optionalString (cfg.dbus != null) "dbus=${cfg.dbus}"} ${cfg.extraConfig} ''; diff --git a/nixos/modules/services/networking/nsd.nix b/nixos/modules/services/networking/nsd.nix index 09f3bdc7ae07..6db728e7aa5a 100644 --- a/nixos/modules/services/networking/nsd.nix +++ b/nixos/modules/services/networking/nsd.nix @@ -137,8 +137,8 @@ let ''; yesOrNo = b: if b then "yes" else "no"; - maybeString = prefix: x: if x == null then "" else ''${prefix} "${x}"''; - maybeToString = prefix: x: if x == null then "" else ''${prefix} ${toString x}''; + maybeString = prefix: x: optionalString (x != null) ''${prefix} "${x}"''; + maybeToString = prefix: x: optionalString (x != null) ''${prefix} ${toString x}''; forEach = pre: l: concatMapStrings (x: pre + x + "\n") l; diff --git a/nixos/modules/services/networking/ssh/lshd.nix b/nixos/modules/services/networking/ssh/lshd.nix index af64969c2fcd..129e42055514 100644 --- a/nixos/modules/services/networking/ssh/lshd.nix +++ b/nixos/modules/services/networking/ssh/lshd.nix @@ -165,9 +165,7 @@ in ${lsh}/sbin/lshd --daemonic \ --password-helper="${lsh}/sbin/lsh-pam-checkpw" \ -p ${toString portNumber} \ - ${if interfaces == [] then "" - else (concatStrings (map (i: "--interface=\"${i}\"") - interfaces))} \ + ${optionalString (interfaces != []) (concatStrings (map (i: "--interface=\"${i}\"") interfaces))} \ -h "${hostKey}" \ ${optionalString (!syslog) "--no-syslog" } \ ${if passwordAuthentication then "--password" else "--no-password" } \ diff --git a/nixos/modules/services/scheduling/fcron.nix b/nixos/modules/services/scheduling/fcron.nix index f1d2f462a755..47bd358f979d 100644 --- a/nixos/modules/services/scheduling/fcron.nix +++ b/nixos/modules/services/scheduling/fcron.nix @@ -6,7 +6,7 @@ let cfg = config.services.fcron; - queuelen = if cfg.queuelen == null then "" else "-q ${toString cfg.queuelen}"; + queuelen = optionalString (cfg.queuelen != null) "-q ${toString cfg.queuelen}"; # Duplicate code, also found in cron.nix. Needs deduplication. systemCronJobs = diff --git a/nixos/modules/services/web-apps/invidious.nix b/nixos/modules/services/web-apps/invidious.nix index e875be47fb91..8823da010014 100644 --- a/nixos/modules/services/web-apps/invidious.nix +++ b/nixos/modules/services/web-apps/invidious.nix @@ -62,7 +62,7 @@ let port = cfg.database.port; # Blank for unix sockets, see # https://github.com/will/crystal-pg/blob/1548bb255210/src/pq/conninfo.cr#L100-L108 - host = if cfg.database.host == null then "" else cfg.database.host; + host = lib.optionalString (cfg.database.host != null) cfg.database.host; # Not needed because peer authentication is enabled password = lib.mkIf (cfg.database.host == null) ""; }; diff --git a/nixos/modules/services/web-apps/invoiceplane.nix b/nixos/modules/services/web-apps/invoiceplane.nix index 8be1fd3055d0..f419b75cf70f 100644 --- a/nixos/modules/services/web-apps/invoiceplane.nix +++ b/nixos/modules/services/web-apps/invoiceplane.nix @@ -16,7 +16,7 @@ let DB_HOSTNAME=${cfg.database.host} DB_USERNAME=${cfg.database.user} # NOTE: file_get_contents adds newline at the end of returned string - DB_PASSWORD=${if cfg.database.passwordFile == null then "" else "trim(file_get_contents('${cfg.database.passwordFile}'), \"\\r\\n\")"} + DB_PASSWORD=${optionalString (cfg.database.passwordFile != null) "trim(file_get_contents('${cfg.database.passwordFile}'), \"\\r\\n\")"} DB_DATABASE=${cfg.database.name} DB_PORT=${toString cfg.database.port} SESS_EXPIRATION=864000 diff --git a/nixos/modules/services/web-apps/peertube.nix b/nixos/modules/services/web-apps/peertube.nix index 4ef2d7dce532..8a1fc3c567cc 100644 --- a/nixos/modules/services/web-apps/peertube.nix +++ b/nixos/modules/services/web-apps/peertube.nix @@ -350,7 +350,7 @@ in { }; redis = { hostname = "${toString cfg.redis.host}"; - port = (if cfg.redis.port == null then "" else cfg.redis.port); + port = (lib.optionalString (cfg.redis.port != null) cfg.redis.port); }; storage = { tmp = lib.mkDefault "/var/lib/peertube/storage/tmp/"; diff --git a/nixos/modules/services/web-servers/lighttpd/cgit.nix b/nixos/modules/services/web-servers/lighttpd/cgit.nix index 5042fbf1f8f2..e9f42c41183b 100644 --- a/nixos/modules/services/web-servers/lighttpd/cgit.nix +++ b/nixos/modules/services/web-servers/lighttpd/cgit.nix @@ -4,7 +4,7 @@ with lib; let cfg = config.services.lighttpd.cgit; - pathPrefix = if stringLength cfg.subdir == 0 then "" else "/" + cfg.subdir; + pathPrefix = optionalString (stringLength cfg.subdir != 0) ("/" + cfg.subdir); configFile = pkgs.writeText "cgitrc" '' # default paths to static assets diff --git a/nixos/modules/services/x11/desktop-managers/phosh.nix b/nixos/modules/services/x11/desktop-managers/phosh.nix index 3cfa6e044b73..e4cd9fd99e40 100644 --- a/nixos/modules/services/x11/desktop-managers/phosh.nix +++ b/nixos/modules/services/x11/desktop-managers/phosh.nix @@ -100,7 +100,7 @@ let }; }; - optionalKV = k: v: if v == null then "" else "${k} = ${builtins.toString v}"; + optionalKV = k: v: optionalString (v != null) "${k} = ${builtins.toString v}"; renderPhocOutput = name: output: let modelines = if builtins.isList output.modeline diff --git a/nixos/modules/system/boot/kernel_config.nix b/nixos/modules/system/boot/kernel_config.nix index 31e9ec626ca6..e618070f0dc3 100644 --- a/nixos/modules/system/boot/kernel_config.nix +++ b/nixos/modules/system/boot/kernel_config.nix @@ -70,11 +70,10 @@ let let val = if item.freeform != null then item.freeform else item.tristate; in - if val == null - then "" - else if (item.optional) + optionalString (val != null) + (if (item.optional) then "${key}? ${mkValue val}\n" - else "${key} ${mkValue val}\n"; + else "${key} ${mkValue val}\n"); mkConf = cfg: concatStrings (mapAttrsToList mkConfigLine cfg); in mkConf exprs; diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix index 9f80b40d116c..a10dd3d0ca78 100644 --- a/nixos/modules/system/boot/loader/grub/grub.nix +++ b/nixos/modules/system/boot/loader/grub/grub.nix @@ -65,8 +65,8 @@ let [ coreutils gnused gnugrep findutils diffutils btrfs-progs util-linux mdadm ] ++ optional cfg.efiSupport efibootmgr ++ optionals cfg.useOSProber [ busybox os-prober ]); - font = if cfg.font == null then "" - else (if lib.last (lib.splitString "." cfg.font) == "pf2" + font = lib.optionalString (cfg.font != null) ( + if lib.last (lib.splitString "." cfg.font) == "pf2" then cfg.font else "${convertedFont}"); }); diff --git a/nixos/modules/system/boot/systemd/user.nix b/nixos/modules/system/boot/systemd/user.nix index 92e1b087392d..1b6398d2f929 100644 --- a/nixos/modules/system/boot/systemd/user.nix +++ b/nixos/modules/system/boot/systemd/user.nix @@ -42,7 +42,7 @@ let writeTmpfiles = { rules, user ? null }: let - suffix = if user == null then "" else "-${user}"; + suffix = optionalString (user != null) "-${user}"; in pkgs.writeTextFile { name = "nixos-user-tmpfiles.d${suffix}"; diff --git a/pkgs/applications/editors/texmacs/darwin.nix b/pkgs/applications/editors/texmacs/darwin.nix index ff090dd3259a..8c74d8c5c8f2 100644 --- a/pkgs/applications/editors/texmacs/darwin.nix +++ b/pkgs/applications/editors/texmacs/darwin.nix @@ -47,10 +47,10 @@ stdenv.mkDerivation { postInstall = "wrapProgram $out/Applications/TeXmacs-${version}/Contents/MacOS/TeXmacs --suffix PATH : " + "${ghostscript}/bin:" + - (if aspell == null then "" else "${aspell}/bin:") + - (if tex == null then "" else "${tex}/bin:") + - (if netpbm == null then "" else "${lib.getBin netpbm}/bin:") + - (if imagemagick == null then "" else "${imagemagick}/bin:"); + (lib.optionalString (aspell != null) "${aspell}/bin:") + + (lib.optionalString (tex != null) "${tex}/bin:") + + (lib.optionalString (netpbm != null) "${lib.getBin netpbm}/bin:") + + (lib.optionalString (imagemagick != null) "${imagemagick}/bin:"); enableParallelBuilding = true; diff --git a/pkgs/applications/editors/vscode/vscodium.nix b/pkgs/applications/editors/vscode/vscodium.nix index 3e66c7e6abd0..b434279621d1 100644 --- a/pkgs/applications/editors/vscode/vscodium.nix +++ b/pkgs/applications/editors/vscode/vscodium.nix @@ -22,7 +22,7 @@ let armv7l-linux = "0m1v24gg2dy79hgrz37gysgrazg8vkr1gkp52j6m6y76vi0l8249"; }.${system} or throwSystem; - sourceRoot = if stdenv.isDarwin then "" else "."; + sourceRoot = lib.optionalString (!stdenv.isDarwin) "."; in callPackage ./generic.nix rec { inherit sourceRoot commandLineArgs useVSCodeRipgrep; diff --git a/pkgs/applications/networking/browsers/chromium/default.nix b/pkgs/applications/networking/browsers/chromium/default.nix index 77f4def41f33..a5e6855e9637 100644 --- a/pkgs/applications/networking/browsers/chromium/default.nix +++ b/pkgs/applications/networking/browsers/chromium/default.nix @@ -134,9 +134,7 @@ let }; }; - suffix = if (channel == "stable" || channel == "ungoogled-chromium") - then "" - else "-" + channel; + suffix = lib.optionalString (channel != "stable" && channel != "ungoogled-chromium") ("-" + channel); sandboxExecutableName = chromium.browser.passthru.sandboxExecutableName; diff --git a/pkgs/applications/networking/browsers/microsoft-edge/browser.nix b/pkgs/applications/networking/browsers/microsoft-edge/browser.nix index 2af28bb8dd06..7f72a42ffe0d 100644 --- a/pkgs/applications/networking/browsers/microsoft-edge/browser.nix +++ b/pkgs/applications/networking/browsers/microsoft-edge/browser.nix @@ -46,13 +46,9 @@ let then baseName else baseName + "-" + channel; - iconSuffix = if channel == "stable" - then "" - else "_${channel}"; + iconSuffix = lib.optionalString (channel != "stable") "_${channel}"; - desktopSuffix = if channel == "stable" - then "" - else "-${channel}"; + desktopSuffix = lib.optionalString (channel != "stable") "-${channel}"; in stdenv.mkDerivation rec { diff --git a/pkgs/applications/office/libreoffice/default.nix b/pkgs/applications/office/libreoffice/default.nix index 25e8f18998e2..518167cb33d1 100644 --- a/pkgs/applications/office/libreoffice/default.nix +++ b/pkgs/applications/office/libreoffice/default.nix @@ -395,7 +395,7 @@ in dontWrapQtApps = true; configureFlags = [ - (if withHelp then "" else "--without-help") + (lib.optionalString (!withHelp) "--without-help") "--with-boost=${getDev boost}" "--with-boost-libdir=${getLib boost}/lib" "--with-beanshell-jar=${bsh}" diff --git a/pkgs/applications/science/logic/hol_light/default.nix b/pkgs/applications/science/logic/hol_light/default.nix index 4c105a40e20d..9f379252fd52 100644 --- a/pkgs/applications/science/logic/hol_light/default.nix +++ b/pkgs/applications/science/logic/hol_light/default.nix @@ -2,8 +2,7 @@ let load_num = - if num == null then "" else - '' + lib.optionalString (num != null) '' -I ${num}/lib/ocaml/${ocaml.version}/site-lib/num \ -I ${num}/lib/ocaml/${ocaml.version}/site-lib/top-num \ -I ${num}/lib/ocaml/${ocaml.version}/site-lib/stublibs \ diff --git a/pkgs/applications/science/math/sage/sage-tests.nix b/pkgs/applications/science/math/sage/sage-tests.nix index 4910f5e8bf1d..1a415ae65e96 100644 --- a/pkgs/applications/science/math/sage/sage-tests.nix +++ b/pkgs/applications/science/math/sage/sage-tests.nix @@ -19,7 +19,7 @@ let runAllTests = files == null; testArgs = if runAllTests then "--all" else testFileList; patienceSpecifier = lib.optionalString longTests "--long"; - timeSpecifier = if timeLimit == null then "" else "--short ${toString timeLimit}"; + timeSpecifier = lib.optionalString (timeLimit != null) "--short ${toString timeLimit}"; relpathToArg = relpath: lib.escapeShellArg "${src}/${relpath}"; # paths need to be absolute testFileList = lib.concatStringsSep " " (map relpathToArg files); in diff --git a/pkgs/applications/version-management/sapling/default.nix b/pkgs/applications/version-management/sapling/default.nix index 0d14d512c5f2..796d76cc6ef8 100644 --- a/pkgs/applications/version-management/sapling/default.nix +++ b/pkgs/applications/version-management/sapling/default.nix @@ -38,7 +38,7 @@ let # # See https://github.com/NixOS/nixpkgs/pull/198311#issuecomment-1326894295 myCargoSetupHook = rustPlatform.cargoSetupHook.overrideAttrs (old: { - cargoConfig = if stdenv.isDarwin then "" else old.cargoConfig; + cargoConfig = lib.optionalString (!stdenv.isDarwin) old.cargoConfig; }); src = fetchFromGitHub { diff --git a/pkgs/applications/window-managers/sway/wrapper.nix b/pkgs/applications/window-managers/sway/wrapper.nix index 42384fa06ae2..e786e1463816 100644 --- a/pkgs/applications/window-managers/sway/wrapper.nix +++ b/pkgs/applications/window-managers/sway/wrapper.nix @@ -28,7 +28,7 @@ let export DBUS_SESSION_BUS_ADDRESS exec ${sway}/bin/sway "$@" else - exec ${if !dbusSupport then "" else "${dbus}/bin/dbus-run-session"} ${sway}/bin/sway "$@" + exec ${lib.optionalString dbusSupport "${dbus}/bin/dbus-run-session"} ${sway}/bin/sway "$@" fi ''; in symlinkJoin { diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index acc433496b0e..cc6f0ff897ed 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -59,12 +59,12 @@ let bintoolsVersion = lib.getVersion bintools; bintoolsName = lib.removePrefix targetPrefix (lib.getName bintools); - libc_bin = if libc == null then "" else getBin libc; - libc_dev = if libc == null then "" else getDev libc; - libc_lib = if libc == null then "" else getLib libc; - bintools_bin = if nativeTools then "" else getBin bintools; + libc_bin = lib.optionalString (libc != null) (getBin libc); + libc_dev = lib.optionalString (libc != null) (getDev libc); + libc_lib = lib.optionalString (libc != null) (getLib libc); + bintools_bin = lib.optionalString (!nativeTools) (getBin bintools); # The wrapper scripts use 'cat' and 'grep', so we may need coreutils. - coreutils_bin = if nativeTools then "" else getBin coreutils; + coreutils_bin = lib.optionalString (!nativeTools) (getBin coreutils); # See description in cc-wrapper. suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config; @@ -103,7 +103,7 @@ in stdenv.mkDerivation { pname = targetPrefix + (if name != "" then name else "${bintoolsName}-wrapper"); - version = if bintools == null then "" else bintoolsVersion; + version = lib.optionalString (bintools != null) bintoolsVersion; preferLocalBuild = true; @@ -265,7 +265,7 @@ stdenv.mkDerivation { # install the wrapper, you get tools like objdump (same for any # binaries of libc). + optionalString (!nativeTools) '' - printWords ${bintools_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages + printWords ${bintools_bin} ${lib.optionalString (libc != null) libc_bin} > $out/nix-support/propagated-user-env-packages '' ## @@ -381,7 +381,7 @@ stdenv.mkDerivation { # for substitution in utils.bash expandResponseParams = "${expand-response-params}/bin/expand-response-params"; shell = getBin shell + shell.shellPath or ""; - gnugrep_bin = if nativeTools then "" else gnugrep; + gnugrep_bin = lib.optionalString (!nativeTools) gnugrep; wrapperName = "BINTOOLS_WRAPPER"; inherit dynamicLinker targetPrefix suffixSalt coreutils_bin; inherit bintools_bin libc_bin libc_dev libc_lib; diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index ffde44c538e3..a843e6440202 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -75,14 +75,14 @@ let ccVersion = lib.getVersion cc; ccName = lib.removePrefix targetPrefix (lib.getName cc); - libc_bin = if libc == null then "" else getBin libc; - libc_dev = if libc == null then "" else getDev libc; - libc_lib = if libc == null then "" else getLib libc; + libc_bin = optionalString (libc != null) (getBin libc); + libc_dev = optionalString (libc != null) (getDev libc); + libc_lib = optionalString (libc != null) (getLib libc); cc_solib = getLib cc + optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}"; # The wrapper scripts use 'cat' and 'grep', so we may need coreutils. - coreutils_bin = if nativeTools then "" else getBin coreutils; + coreutils_bin = optionalString (!nativeTools) (getBin coreutils); # The "suffix salt" is a arbitrary string added in the end of env vars # defined by cc-wrapper's hooks so that multiple cc-wrappers can be used @@ -164,7 +164,7 @@ assert nativePrefix == bintools.nativePrefix; stdenv.mkDerivation { pname = targetPrefix + (if name != "" then name else "${ccName}-wrapper"); - version = if cc == null then "" else ccVersion; + version = optionalString (cc != null) ccVersion; preferLocalBuild = true; @@ -600,10 +600,10 @@ stdenv.mkDerivation { # for substitution in utils.bash expandResponseParams = "${expand-response-params}/bin/expand-response-params"; shell = getBin shell + shell.shellPath or ""; - gnugrep_bin = if nativeTools then "" else gnugrep; + gnugrep_bin = optionalString (!nativeTools) gnugrep; # stdenv.cc.cc should not be null and we have nothing better for now. # if the native impure bootstrap is gotten rid of this can become `inherit cc;` again. - cc = if nativeTools then "" else cc; + cc = optionalString (!nativeTools) cc; wrapperName = "CC_WRAPPER"; inherit suffixSalt coreutils_bin bintools; inherit libc_bin libc_dev libc_lib; diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix index 5f48fb9f7bdb..b74d7885d54a 100644 --- a/pkgs/build-support/docker/default.nix +++ b/pkgs/build-support/docker/default.nix @@ -594,7 +594,7 @@ rec { nativeBuildInputs = [ jshon pigz jq moreutils ]; # Image name must be lowercase imageName = lib.toLower name; - imageTag = if tag == null then "" else tag; + imageTag = lib.optionalString (tag != null) tag; inherit fromImage baseJson; layerClosure = writeReferencesToFile layer; passthru.buildArgs = args; diff --git a/pkgs/build-support/fetchgithub/default.nix b/pkgs/build-support/fetchgithub/default.nix index faa338b672f0..a2498700b545 100644 --- a/pkgs/build-support/fetchgithub/default.nix +++ b/pkgs/build-support/fetchgithub/default.nix @@ -24,7 +24,7 @@ let position = "${position.file}:${toString position.line}"; }; passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "forceFetchGit" "private" "githubBase" "varPrefix" ]; - varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_"; + varBase = "NIX${lib.optionalString (varPrefix != null) "_${varPrefix}"}_GITHUB_PRIVATE_"; useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit || (sparseCheckout != []); # We prefer fetchzip in cases we don't need submodules as the hash # is more stable in that case. diff --git a/pkgs/build-support/kernel/make-initrd-ng.nix b/pkgs/build-support/kernel/make-initrd-ng.nix index f3cf3d59f92b..2418838176ef 100644 --- a/pkgs/build-support/kernel/make-initrd-ng.nix +++ b/pkgs/build-support/kernel/make-initrd-ng.nix @@ -72,7 +72,7 @@ in ${if makeUInitrd then "uInitrdCompression" else null} = uInitrdCompression; passAsFile = ["contents"]; - contents = lib.concatMapStringsSep "\n" ({ object, symlink, ... }: "${object}\n${if symlink == null then "" else symlink}") contents + "\n"; + contents = lib.concatMapStringsSep "\n" ({ object, symlink, ... }: "${object}\n${lib.optionalString (symlink != null) symlink}") contents + "\n"; nativeBuildInputs = [makeInitrdNGTool cpio] ++ lib.optional makeUInitrd ubootTools ++ lib.optional strip binutils; diff --git a/pkgs/build-support/nix-gitignore/default.nix b/pkgs/build-support/nix-gitignore/default.nix index d55465302e44..5fc1f2cf7f8c 100644 --- a/pkgs/build-support/nix-gitignore/default.nix +++ b/pkgs/build-support/nix-gitignore/default.nix @@ -66,7 +66,7 @@ in rec { handleSlashPrefix = l: let split = (match "^(/?)(.*)" l); - findSlash = l: if (match ".+/.+" l) != null then "" else l; + findSlash = l: lib.optionalString ((match ".+/.+" l) == null) l; hasSlash = mapAroundCharclass findSlash l != l; in (if (elemAt split 0) == "/" || hasSlash diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix index 5168eb6ab759..60310f178747 100644 --- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix +++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix @@ -21,7 +21,7 @@ , verbose , workspace_member }: let version_ = lib.splitString "-" crateVersion; - versionPre = if lib.tail version_ == [] then "" else lib.elemAt version_ 1; + versionPre = lib.optionalString (lib.tail version_ != []) (lib.elemAt version_ 1); version = lib.splitVersion (lib.head version_); rustcOpts = lib.foldl' (opts: opt: opts + " " + opt) (if release then "-C opt-level=3" else "-C debuginfo=2") diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 403bc9b1d2da..e05848217d2b 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -468,7 +468,7 @@ rec { echo "installing RPMs..." PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \ - rpm -iv --nosignature ${if runScripts then "" else "--noscripts"} $rpms + rpm -iv --nosignature ${lib.optionalString (!runScripts) "--noscripts"} $rpms echo "running post-install script..." eval "$postInstall" diff --git a/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl/default.nix b/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl/default.nix index 2f9d22e57d89..66ebf105ffd0 100644 --- a/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl/default.nix +++ b/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl/default.nix @@ -3,7 +3,7 @@ let common = { pname, sha256, suffix ? "" }: let - legacySuffix = if suffix == "-nons" then "" else "-ns"; + legacySuffix = lib.optionalString (suffix != "-nons") "-ns"; self = stdenv.mkDerivation rec { inherit pname; version = "1.79.2"; diff --git a/pkgs/development/compilers/purescript/purescript/default.nix b/pkgs/development/compilers/purescript/purescript/default.nix index d7c8394a57b1..fd3d1a810a5c 100644 --- a/pkgs/development/compilers/purescript/purescript/default.nix +++ b/pkgs/development/compilers/purescript/purescript/default.nix @@ -7,10 +7,7 @@ let dynamic-linker = stdenv.cc.bintools.dynamicLinker; patchelf = libPath : - if stdenv.isDarwin - then "" - else - '' + lib.optionalString (!stdenv.isDarwin) '' chmod u+w $PURS patchelf --interpreter ${dynamic-linker} --set-rpath ${libPath} $PURS chmod u-w $PURS diff --git a/pkgs/development/interpreters/acl2/libipasirglucose4/default.nix b/pkgs/development/interpreters/acl2/libipasirglucose4/default.nix index dc8308267f40..c31e0dbe67f7 100644 --- a/pkgs/development/interpreters/acl2/libipasirglucose4/default.nix +++ b/pkgs/development/interpreters/acl2/libipasirglucose4/default.nix @@ -24,7 +24,7 @@ stdenv.mkDerivation rec { postBuild = '' $CXX -shared -o ${libname} \ - ${if stdenv.cc.isClang then "" else "-Wl,-soname,${libname}"} \ + ${lib.optionalString (!stdenv.cc.isClang) "-Wl,-soname,${libname}"} \ ipasirglucoseglue.o libipasirglucose4.a ''; diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index 17b5667e8ee9..79e45b8dc395 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -118,7 +118,7 @@ let optionalLocation = let pos = builtins.unsafeGetAttrPos (if attrs ? "pname" then "pname" else "name") attrs; - in if pos == null then "" else " at ${pos.file}:${toString pos.line}:${toString pos.column}"; + in lib.optionalString (pos != null) " at ${pos.file}:${toString pos.line}:${toString pos.column}"; leftPadName = name: against: let len = lib.max (lib.stringLength name) (lib.stringLength against); diff --git a/pkgs/development/interpreters/python/wrapper.nix b/pkgs/development/interpreters/python/wrapper.nix index b36662335abe..f5f9b03e0fd3 100644 --- a/pkgs/development/interpreters/python/wrapper.nix +++ b/pkgs/development/interpreters/python/wrapper.nix @@ -42,7 +42,7 @@ let if [ -f "$prg" ]; then rm -f "$out/bin/$prg" if [ -x "$prg" ]; then - makeWrapper "$path/bin/$prg" "$out/bin/$prg" --set NIX_PYTHONPREFIX "$out" --set NIX_PYTHONEXECUTABLE ${pythonExecutable} --set NIX_PYTHONPATH ${pythonPath} ${if permitUserSite then "" else ''--set PYTHONNOUSERSITE "true"''} ${lib.concatStringsSep " " makeWrapperArgs} + makeWrapper "$path/bin/$prg" "$out/bin/$prg" --set NIX_PYTHONPREFIX "$out" --set NIX_PYTHONEXECUTABLE ${pythonExecutable} --set NIX_PYTHONPATH ${pythonPath} ${lib.optionalString (!permitUserSite) ''--set PYTHONNOUSERSITE "true"''} ${lib.concatStringsSep " " makeWrapperArgs} fi fi done diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 12e59c939afe..4c31b82f3103 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -330,7 +330,7 @@ assert buildPostproc -> buildAvutil; assert buildSwscale -> buildAvutil; stdenv.mkDerivation (finalAttrs: { - pname = "ffmpeg" + (if ffmpegVariant == "small" then "" else "-${ffmpegVariant}"); + pname = "ffmpeg" + (optionalString (ffmpegVariant != "small") "-${ffmpegVariant}"); inherit version; src = fetchgit { diff --git a/pkgs/development/libraries/opencv/tests.nix b/pkgs/development/libraries/opencv/tests.nix index 03a89db0882f..d1966b1a4aa8 100644 --- a/pkgs/development/libraries/opencv/tests.nix +++ b/pkgs/development/libraries/opencv/tests.nix @@ -39,7 +39,7 @@ let "stitching" "video" ] ++ lib.optionals (!stdenv.isAarch64 && enableGStreamer) [ "gapi" ]; - testRunner = if stdenv.isDarwin then "" else "${lib.getExe xvfb-run} -a "; + testRunner = lib.optionalString (!stdenv.isDarwin) "${lib.getExe xvfb-run} -a "; testsPreparation = '' touch $out # several tests want a write access, so we have to copy files diff --git a/pkgs/development/libraries/qt-4.x/4.8/default.nix b/pkgs/development/libraries/qt-4.x/4.8/default.nix index 68a300ac250d..a8257a36d39d 100644 --- a/pkgs/development/libraries/qt-4.x/4.8/default.nix +++ b/pkgs/development/libraries/qt-4.x/4.8/default.nix @@ -173,9 +173,9 @@ stdenv.mkDerivation rec { "-make" "libs" "-make" "tools" "-make" "translations" "-no-phonon" "-no-webkit" "-no-multimedia" "-audio-backend" ]) ++ [ - "-${if demos then "" else "no"}make" "demos" - "-${if examples then "" else "no"}make" "examples" - "-${if docs then "" else "no"}make" "docs" + "-${lib.optionalString (!demos) "no"}make" "demos" + "-${lib.optionalString (!examples) "no"}make" "examples" + "-${lib.optionalString (!docs) "no"}make" "docs" ] ++ lib.optional developerBuild "-developer-build" ++ lib.optionals stdenv.hostPlatform.isDarwin [ platformFlag "unsupported/macx-clang-libc++" ] ++ lib.optionals stdenv.hostPlatform.isWindows [ platformFlag "win32-g++-4.6" ]; diff --git a/pkgs/development/mobile/titaniumenv/build-app.nix b/pkgs/development/mobile/titaniumenv/build-app.nix index fa2eeae00b55..42b70c64abe9 100644 --- a/pkgs/development/mobile/titaniumenv/build-app.nix +++ b/pkgs/development/mobile/titaniumenv/build-app.nix @@ -158,8 +158,7 @@ stdenv.mkDerivation ({ installPhase = '' ${if target == "android" then '' - ${if release then "" - else '' + ${lib.optionalString (!release) '' cp "$(ls build/android/bin/*.apk | grep -v '\-unsigned.apk')" $out ''} diff --git a/pkgs/development/python-modules/azure-common/default.nix b/pkgs/development/python-modules/azure-common/default.nix index 504748f033ff..47d0039e5e4b 100644 --- a/pkgs/development/python-modules/azure-common/default.nix +++ b/pkgs/development/python-modules/azure-common/default.nix @@ -23,7 +23,7 @@ buildPythonPackage rec { azure-nspkg ] ++ lib.optionals (!isPy3k) [ setuptools ]; # need for namespace lookup - postInstall = if isPy3k then "" else '' + postInstall = lib.optionalString (!isPy3k) '' echo "__import__('pkg_resources').declare_namespace(__name__)" >> "$out/lib/${python.libPrefix}"/site-packages/azure/__init__.py ''; diff --git a/pkgs/development/python-modules/azure-mgmt-common/default.nix b/pkgs/development/python-modules/azure-mgmt-common/default.nix index 28043046d8aa..dfd7ac2a3f05 100644 --- a/pkgs/development/python-modules/azure-mgmt-common/default.nix +++ b/pkgs/development/python-modules/azure-mgmt-common/default.nix @@ -26,7 +26,7 @@ buildPythonPackage rec { msrestazure ]; - postInstall = if isPy3k then "" else '' + postInstall = pkgs.lib.optionalString (!isPy3k) '' echo "__import__('pkg_resources').declare_namespace(__name__)" >> "$out/lib/${python.libPrefix}"/site-packages/azure/mgmt/__init__.py echo "__import__('pkg_resources').declare_namespace(__name__)" >> "$out/lib/${python.libPrefix}"/site-packages/azure/__init__.py ''; diff --git a/pkgs/development/python-modules/tensorflow/bin.nix b/pkgs/development/python-modules/tensorflow/bin.nix index a988a39c388b..5bb668965048 100644 --- a/pkgs/development/python-modules/tensorflow/bin.nix +++ b/pkgs/development/python-modules/tensorflow/bin.nix @@ -53,7 +53,7 @@ in buildPythonPackage { disabled = pythonAtLeast "3.11"; src = let - pyVerNoDot = lib.strings.stringAsChars (x: if x == "." then "" else x) python.pythonVersion; + pyVerNoDot = lib.strings.stringAsChars (x: lib.optionalString (x != ".") x) python.pythonVersion; platform = if stdenv.isDarwin then "mac" else "linux"; unit = if cudaSupport then "gpu" else "cpu"; key = "${platform}_py_${pyVerNoDot}_${unit}"; diff --git a/pkgs/development/ruby-modules/bundled-common/default.nix b/pkgs/development/ruby-modules/bundled-common/default.nix index aa903a5637c0..01d27b91561e 100644 --- a/pkgs/development/ruby-modules/bundled-common/default.nix +++ b/pkgs/development/ruby-modules/bundled-common/default.nix @@ -70,11 +70,12 @@ let assert gemFiles.gemdir != null; "cp -a ${gemFiles.gemdir}/* $out/") #*/ ); - maybeCopyAll = pkgname: if pkgname == null then "" else - let - mainGem = gems.${pkgname} or (throw "bundlerEnv: gem ${pkgname} not found"); - in - copyIfBundledByPath mainGem; + maybeCopyAll = pkgname: lib.optionalString (pkgname != null) ( + let + mainGem = gems.${pkgname} or (throw "bundlerEnv: gem ${pkgname} not found"); + in + copyIfBundledByPath mainGem + ); # We have to normalize the Gemfile.lock, otherwise bundler tries to be # helpful by doing so at run time, causing executables to immediately bail diff --git a/pkgs/development/ruby-modules/gem/default.nix b/pkgs/development/ruby-modules/gem/default.nix index 7105663413a2..d57eeb2ea055 100644 --- a/pkgs/development/ruby-modules/gem/default.nix +++ b/pkgs/development/ruby-modules/gem/default.nix @@ -224,7 +224,7 @@ stdenv.mkDerivation ((builtins.removeAttrs attrs ["source"]) // { pushd $out/${ruby.gemPath} find doc/ -iname created.rid -delete -print find gems/*/ext/ extensions/ \( -iname Makefile -o -iname mkmf.log -o -iname gem_make.out \) -delete -print - ${if keepGemCache then "" else "rm -fvr cache"} + ${lib.optionalString (!keepGemCache) "rm -fvr cache"} popd # write out metadata and binstubs diff --git a/pkgs/development/tools/misc/distcc/default.nix b/pkgs/development/tools/misc/distcc/default.nix index b7270f79c431..312f69328580 100644 --- a/pkgs/development/tools/misc/distcc/default.nix +++ b/pkgs/development/tools/misc/distcc/default.nix @@ -26,7 +26,7 @@ let configureFlagsArray=( CFLAGS="-O2 -fno-strict-aliasing" CXXFLAGS="-O2 -fno-strict-aliasing" --mandir=$out/share/man - ${if sysconfDir == "" then "" else "--sysconfdir=${sysconfDir}"} + ${lib.optionalString (sysconfDir != "") "--sysconfdir=${sysconfDir}"} ${lib.optionalString static "LDFLAGS=-static"} ${lib.withFeature (static == true || popt == null) "included-popt"} ${lib.withFeature (avahi != null) "avahi"} diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index d7ea4ac2c498..1f9039136f4c 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -397,10 +397,11 @@ stdenv.mkDerivation ({ meta = { description = "The Linux kernel" + - (if kernelPatches == [] then "" else + (lib.optionalString (kernelPatches != []) ( " (with patches: " + lib.concatStringsSep ", " (map (x: x.name) kernelPatches) - + ")"); + + ")" + )); license = lib.licenses.gpl2Only; homepage = "https://www.kernel.org/"; maintainers = lib.teams.linux-kernel.members ++ [ -- cgit v1.2.3