lol

Merge pull request #222080 from Stunkymonkey/nixos-optionalString

authored by

Artturi and committed by
GitHub
b83db86a 2fc54db0

+89 -95
+1 -4
nixos/modules/i18n/input-method/ibus.nix
··· 10 10 check = x: (lib.types.package.check x) && (attrByPath ["meta" "isIbusEngine"] false x); 11 11 }; 12 12 13 - impanel = 14 - if cfg.panel != null 15 - then "--panel=${cfg.panel}" 16 - else ""; 13 + impanel = optionalString (cfg.panel != null) "--panel=${cfg.panel}"; 17 14 18 15 ibusAutostart = pkgs.writeTextFile { 19 16 name = "autostart-ibus-daemon";
+2 -2
nixos/modules/installer/cd-dvd/iso-image.nix
··· 22 22 (option: '' 23 23 menuentry '${defaults.name} ${ 24 24 # Name appended to menuentry defaults to params if no specific name given. 25 - option.name or (if option ? params then "(${option.params})" else "") 26 - }' ${if option ? class then " --class ${option.class}" else ""} { 25 + option.name or (optionalString (option ? params) "(${option.params})") 26 + }' ${optionalString (option ? class) " --class ${option.class}"} { 27 27 linux ${defaults.image} \''${isoboot} ${defaults.params} ${ 28 28 option.params or "" 29 29 }
+1 -1
nixos/modules/programs/less.nix
··· 11 11 ${concatStringsSep "\n" 12 12 (mapAttrsToList (command: action: "${command} ${action}") cfg.commands) 13 13 } 14 - ${if cfg.clearDefaultCommands then "#stop" else ""} 14 + ${optionalString cfg.clearDefaultCommands "#stop"} 15 15 16 16 #line-edit 17 17 ${concatStringsSep "\n"
+8 -8
nixos/modules/programs/tmux.nix
··· 1 1 { config, pkgs, lib, ... }: 2 2 3 3 let 4 - inherit (lib) mkOption mkIf types; 4 + inherit (lib) mkOption mkIf types optionalString; 5 5 6 6 cfg = config.programs.tmux; 7 7 ··· 17 17 set -g base-index ${toString cfg.baseIndex} 18 18 setw -g pane-base-index ${toString cfg.baseIndex} 19 19 20 - ${if cfg.newSession then "new-session" else ""} 20 + ${optionalString cfg.newSession "new-session"} 21 21 22 - ${if cfg.reverseSplit then '' 22 + ${optionalString cfg.reverseSplit '' 23 23 bind v split-window -h 24 24 bind s split-window -v 25 - '' else ""} 25 + ''} 26 26 27 27 set -g status-keys ${cfg.keyMode} 28 28 set -g mode-keys ${cfg.keyMode} 29 29 30 - ${if cfg.keyMode == "vi" && cfg.customPaneNavigationAndResize then '' 30 + ${optionalString (cfg.keyMode == "vi" && cfg.customPaneNavigationAndResize) '' 31 31 bind h select-pane -L 32 32 bind j select-pane -D 33 33 bind k select-pane -U ··· 37 37 bind -r J resize-pane -D ${toString cfg.resizeAmount} 38 38 bind -r K resize-pane -U ${toString cfg.resizeAmount} 39 39 bind -r L resize-pane -R ${toString cfg.resizeAmount} 40 - '' else ""} 40 + ''} 41 41 42 - ${if (cfg.shortcut != defaultShortcut) then '' 42 + ${optionalString (cfg.shortcut != defaultShortcut) '' 43 43 # rebind main key: C-${cfg.shortcut} 44 44 unbind C-${defaultShortcut} 45 45 set -g prefix C-${cfg.shortcut} 46 46 bind ${cfg.shortcut} send-prefix 47 47 bind C-${cfg.shortcut} last-window 48 - '' else ""} 48 + ''} 49 49 50 50 setw -g aggressive-resize ${boolToStr cfg.aggressiveResize} 51 51 setw -g clock-mode-style ${if cfg.clock24 then "24" else "12"}
+2 -2
nixos/modules/security/acme/default.nix
··· 781 781 782 782 # FIXME Most of these custom warnings and filters for security.acme.certs.* are required 783 783 # because using mkRemovedOptionModule/mkChangedOptionModule with attrsets isn't possible. 784 - warnings = filter (w: w != "") (mapAttrsToList (cert: data: if data.extraDomains != "_mkMergedOptionModule" then '' 784 + warnings = filter (w: w != "") (mapAttrsToList (cert: data: optionalString (data.extraDomains != "_mkMergedOptionModule") '' 785 785 The option definition `security.acme.certs.${cert}.extraDomains` has changed 786 786 to `security.acme.certs.${cert}.extraDomainNames` and is now a list of strings. 787 787 Setting a custom webroot for extra domains is not possible, instead use separate certs. 788 - '' else "") cfg.certs); 788 + '') cfg.certs); 789 789 790 790 assertions = let 791 791 certs = attrValues cfg.certs;
+2 -2
nixos/modules/services/audio/snapserver.nix
··· 275 275 276 276 warnings = 277 277 # https://github.com/badaix/snapcast/blob/98ac8b2fb7305084376607b59173ce4097c620d8/server/streamreader/stream_manager.cpp#L85 278 - filter (w: w != "") (mapAttrsToList (k: v: if v.type == "spotify" then '' 278 + filter (w: w != "") (mapAttrsToList (k: v: optionalString (v.type == "spotify") '' 279 279 services.snapserver.streams.${k}.type = "spotify" is deprecated, use services.snapserver.streams.${k}.type = "librespot" instead. 280 - '' else "") cfg.streams); 280 + '') cfg.streams); 281 281 282 282 systemd.services.snapserver = { 283 283 after = [ "network.target" ];
+1 -1
nixos/modules/services/backup/mysql-backup.nix
··· 20 20 ''; 21 21 backupDatabaseScript = db: '' 22 22 dest="${cfg.location}/${db}.gz" 23 - if ${mariadb}/bin/mysqldump ${if cfg.singleTransaction then "--single-transaction" else ""} ${db} | ${gzip}/bin/gzip -c > $dest.tmp; then 23 + if ${mariadb}/bin/mysqldump ${optionalString cfg.singleTransaction "--single-transaction"} ${db} | ${gzip}/bin/gzip -c > $dest.tmp; then 24 24 mv $dest.tmp $dest 25 25 echo "Backed up to $dest" 26 26 else
+1 -1
nixos/modules/services/backup/restic.nix
··· 300 300 filesFromTmpFile = "/run/restic-backups-${name}/includes"; 301 301 backupPaths = 302 302 if (backup.dynamicFilesFrom == null) 303 - then if (backup.paths != null) then concatStringsSep " " backup.paths else "" 303 + then optionalString (backup.paths != null) (concatStringsSep " " backup.paths) 304 304 else "--files-from ${filesFromTmpFile}"; 305 305 pruneCmd = optionals (builtins.length backup.pruneOpts > 0) [ 306 306 (resticCmd + " forget --prune " + (concatStringsSep " " backup.pruneOpts))
+2 -2
nixos/modules/services/blockchain/ethereum/geth.nix
··· 196 196 --gcmode ${cfg.gcmode} \ 197 197 --port ${toString cfg.port} \ 198 198 --maxpeers ${toString cfg.maxpeers} \ 199 - ${if cfg.http.enable then ''--http --http.addr ${cfg.http.address} --http.port ${toString cfg.http.port}'' else ""} \ 199 + ${optionalString cfg.http.enable ''--http --http.addr ${cfg.http.address} --http.port ${toString cfg.http.port}''} \ 200 200 ${optionalString (cfg.http.apis != null) ''--http.api ${lib.concatStringsSep "," cfg.http.apis}''} \ 201 - ${if cfg.websocket.enable then ''--ws --ws.addr ${cfg.websocket.address} --ws.port ${toString cfg.websocket.port}'' else ""} \ 201 + ${optionalString cfg.websocket.enable ''--ws --ws.addr ${cfg.websocket.address} --ws.port ${toString cfg.websocket.port}''} \ 202 202 ${optionalString (cfg.websocket.apis != null) ''--ws.api ${lib.concatStringsSep "," cfg.websocket.apis}''} \ 203 203 ${optionalString cfg.metrics.enable ''--metrics --metrics.addr ${cfg.metrics.address} --metrics.port ${toString cfg.metrics.port}''} \ 204 204 --authrpc.addr ${cfg.authrpc.address} --authrpc.port ${toString cfg.authrpc.port} --authrpc.vhosts ${lib.concatStringsSep "," cfg.authrpc.vhosts} \
+1 -1
nixos/modules/services/continuous-integration/jenkins/job-builder.nix
··· 242 242 jobdir="${jenkinsCfg.home}/$jenkinsjobname" 243 243 rm -rf "$jobdir" 244 244 done 245 - '' + (if cfg.accessUser != "" then reloadScript else ""); 245 + '' + (optionalString (cfg.accessUser != "") reloadScript); 246 246 serviceConfig = { 247 247 Type = "oneshot"; 248 248 User = jenkinsCfg.user;
+1 -1
nixos/modules/services/games/minetest-server.nix
··· 4 4 5 5 let 6 6 cfg = config.services.minetest-server; 7 - flag = val: name: if val != null then "--${name} ${toString val} " else ""; 7 + flag = val: name: optionalString (val != null) "--${name} ${toString val} "; 8 8 flags = [ 9 9 (flag cfg.gameId "gameid") 10 10 (flag cfg.world "world")
+2 -3
nixos/modules/services/logging/logrotate.nix
··· 83 83 }; 84 84 85 85 mailOption = 86 - if foldr (n: a: a || (n.mail or false) != false) false (attrValues cfg.settings) 87 - then "--mail=${pkgs.mailutils}/bin/mail" 88 - else ""; 86 + optionalString (foldr (n: a: a || (n.mail or false) != false) false (attrValues cfg.settings)) 87 + "--mail=${pkgs.mailutils}/bin/mail"; 89 88 in 90 89 { 91 90 imports = [
+1 -1
nixos/modules/services/logging/syslogd.nix
··· 7 7 cfg = config.services.syslogd; 8 8 9 9 syslogConf = pkgs.writeText "syslog.conf" '' 10 - ${if (cfg.tty != "") then "kern.warning;*.err;authpriv.none /dev/${cfg.tty}" else ""} 10 + ${optionalString (cfg.tty != "") "kern.warning;*.err;authpriv.none /dev/${cfg.tty}"} 11 11 ${cfg.defaultConfig} 12 12 ${cfg.extraConfig} 13 13 '';
+1 -1
nixos/modules/services/mail/postfix.nix
··· 234 234 235 235 headerChecks = concatStringsSep "\n" (map (x: "${x.pattern} ${x.action}") cfg.headerChecks) + cfg.extraHeaderChecks; 236 236 237 - aliases = let separator = if cfg.aliasMapType == "hash" then ":" else ""; in 237 + aliases = let separator = optionalString (cfg.aliasMapType == "hash") ":"; in 238 238 optionalString (cfg.postmasterAlias != "") '' 239 239 postmaster${separator} ${cfg.postmasterAlias} 240 240 ''
+5 -5
nixos/modules/services/misc/gammu-smsd.nix
··· 10 10 Connection = ${cfg.device.connection} 11 11 SynchronizeTime = ${if cfg.device.synchronizeTime then "yes" else "no"} 12 12 LogFormat = ${cfg.log.format} 13 - ${if (cfg.device.pin != null) then "PIN = ${cfg.device.pin}" else ""} 13 + ${optionalString (cfg.device.pin != null) "PIN = ${cfg.device.pin}"} 14 14 ${cfg.extraConfig.gammu} 15 15 16 16 ··· 33 33 ${optionalString (cfg.backend.service == "sql" && cfg.backend.sql.driver == "native_pgsql") ( 34 34 with cfg.backend; '' 35 35 Driver = ${sql.driver} 36 - ${if (sql.database!= null) then "Database = ${sql.database}" else ""} 37 - ${if (sql.host != null) then "Host = ${sql.host}" else ""} 38 - ${if (sql.user != null) then "User = ${sql.user}" else ""} 39 - ${if (sql.password != null) then "Password = ${sql.password}" else ""} 36 + ${optionalString (sql.database!= null) "Database = ${sql.database}"} 37 + ${optionalString (sql.host != null) "Host = ${sql.host}"} 38 + ${optionalString (sql.user != null) "User = ${sql.user}"} 39 + ${optionalString (sql.password != null) "Password = ${sql.password}"} 40 40 '')} 41 41 42 42 ${cfg.extraConfig.smsd}
+1 -1
nixos/modules/services/misc/gitlab.nix
··· 1215 1215 enableDelete = true; # This must be true, otherwise GitLab won't manage it correctly 1216 1216 extraConfig = { 1217 1217 auth.token = { 1218 - realm = "http${if cfg.https == true then "s" else ""}://${cfg.host}/jwt/auth"; 1218 + realm = "http${optionalString (cfg.https == true) "s"}://${cfg.host}/jwt/auth"; 1219 1219 service = cfg.registry.serviceName; 1220 1220 issuer = cfg.registry.issuer; 1221 1221 rootcertbundle = cfg.registry.certFile;
+1 -1
nixos/modules/services/misc/mbpfan.nix
··· 3 3 4 4 let 5 5 cfg = config.services.mbpfan; 6 - verbose = if cfg.verbose then "v" else ""; 6 + verbose = optionalString cfg.verbose "v"; 7 7 settingsFormat = pkgs.formats.ini {}; 8 8 settingsFile = settingsFormat.generate "mbpfan.ini" cfg.settings; 9 9
+7 -7
nixos/modules/services/misc/redmine.nix
··· 283 283 284 284 services.redmine.settings = { 285 285 production = { 286 - scm_subversion_command = if cfg.components.subversion then "${pkgs.subversion}/bin/svn" else ""; 287 - scm_mercurial_command = if cfg.components.mercurial then "${pkgs.mercurial}/bin/hg" else ""; 288 - scm_git_command = if cfg.components.git then "${pkgs.git}/bin/git" else ""; 289 - scm_cvs_command = if cfg.components.cvs then "${pkgs.cvs}/bin/cvs" else ""; 290 - scm_bazaar_command = if cfg.components.breezy then "${pkgs.breezy}/bin/bzr" else ""; 291 - imagemagick_convert_command = if cfg.components.imagemagick then "${pkgs.imagemagick}/bin/convert" else ""; 292 - gs_command = if cfg.components.ghostscript then "${pkgs.ghostscript}/bin/gs" else ""; 286 + scm_subversion_command = optionalString cfg.components.subversion "${pkgs.subversion}/bin/svn"; 287 + scm_mercurial_command = optionalString cfg.components.mercurial "${pkgs.mercurial}/bin/hg"; 288 + scm_git_command = optionalString cfg.components.git "${pkgs.git}/bin/git"; 289 + scm_cvs_command = optionalString cfg.components.cvs "${pkgs.cvs}/bin/cvs"; 290 + scm_bazaar_command = optionalString cfg.components.breezy "${pkgs.breezy}/bin/bzr"; 291 + imagemagick_convert_command = optionalString cfg.components.imagemagick "${pkgs.imagemagick}/bin/convert"; 292 + gs_command = optionalString cfg.components.ghostscript "${pkgs.ghostscript}/bin/gs"; 293 293 minimagick_font_path = "${cfg.components.minimagick_font_path}"; 294 294 }; 295 295 };
+1 -1
nixos/modules/services/misc/siproxd.nix
··· 20 20 ${optionalString (cfg.hostsAllowReg != []) "hosts_allow_reg = ${concatStringsSep "," cfg.hostsAllowReg}"} 21 21 ${optionalString (cfg.hostsAllowSip != []) "hosts_allow_sip = ${concatStringsSep "," cfg.hostsAllowSip}"} 22 22 ${optionalString (cfg.hostsDenySip != []) "hosts_deny_sip = ${concatStringsSep "," cfg.hostsDenySip}"} 23 - ${if (cfg.passwordFile != "") then "proxy_auth_pwfile = ${cfg.passwordFile}" else ""} 23 + ${optionalString (cfg.passwordFile != "") "proxy_auth_pwfile = ${cfg.passwordFile}"} 24 24 ${cfg.extraConfig} 25 25 ''; 26 26
+2 -2
nixos/modules/services/monitoring/prometheus/exporters/collectd.nix
··· 58 58 }; 59 59 }; 60 60 serviceOpts = let 61 - collectSettingsArgs = if (cfg.collectdBinary.enable) then '' 61 + collectSettingsArgs = optionalString (cfg.collectdBinary.enable) '' 62 62 --collectd.listen-address ${cfg.collectdBinary.listenAddress}:${toString cfg.collectdBinary.port} \ 63 63 --collectd.security-level ${cfg.collectdBinary.securityLevel} \ 64 - '' else ""; 64 + ''; 65 65 in { 66 66 serviceConfig = { 67 67 ExecStart = ''
+2 -2
nixos/modules/services/network-filesystems/openafs/lib.nix
··· 1 1 { config, lib, ...}: 2 2 3 3 let 4 - inherit (lib) concatStringsSep mkOption types; 4 + inherit (lib) concatStringsSep mkOption types optionalString; 5 5 6 6 in { 7 7 8 8 mkCellServDB = cellName: db: '' 9 9 >${cellName} 10 - '' + (concatStringsSep "\n" (map (dbm: if (dbm.ip != "" && dbm.dnsname != "") then dbm.ip + " #" + dbm.dnsname else "") 10 + '' + (concatStringsSep "\n" (map (dbm: optionalString (dbm.ip != "" && dbm.dnsname != "") "${dbm.ip} #${dbm.dnsname}") 11 11 db)) 12 12 + "\n"; 13 13
+1 -1
nixos/modules/services/networking/ndppd.nix
··· 17 17 ttl ${toString proxy.ttl} 18 18 ${render proxy.rules (ruleNetworkName: rule: '' 19 19 rule ${prefer rule.network ruleNetworkName} { 20 - ${rule.method}${if rule.method == "iface" then " ${rule.interface}" else ""} 20 + ${rule.method}${optionalString (rule.method == "iface") " ${rule.interface}"} 21 21 }'')} 22 22 }'')} 23 23 '');
+1 -1
nixos/modules/services/networking/ntopng.nix
··· 86 86 87 87 redis.createInstance = mkOption { 88 88 type = types.nullOr types.str; 89 - default = if versionAtLeast config.system.stateVersion "22.05" then "ntopng" else ""; 89 + default = optionalString (versionAtLeast config.system.stateVersion "22.05") "ntopng"; 90 90 description = lib.mdDoc '' 91 91 Local Redis instance name. Set to `null` to disable 92 92 local Redis instance. Defaults to `""` for
+2 -2
nixos/modules/services/networking/ssh/lshd.nix
··· 169 169 else (concatStrings (map (i: "--interface=\"${i}\"") 170 170 interfaces))} \ 171 171 -h "${hostKey}" \ 172 - ${if !syslog then "--no-syslog" else ""} \ 172 + ${optionalString (!syslog) "--no-syslog" } \ 173 173 ${if passwordAuthentication then "--password" else "--no-password" } \ 174 174 ${if publicKeyAuthentication then "--publickey" else "--no-publickey" } \ 175 175 ${if rootLogin then "--root-login" else "--no-root-login" } \ 176 - ${if loginShell != null then "--login-shell=\"${loginShell}\"" else "" } \ 176 + ${optionalString (loginShell != null) "--login-shell=\"${loginShell}\"" } \ 177 177 ${if srpKeyExchange then "--srp-keyexchange" else "--no-srp-keyexchange" } \ 178 178 ${if !tcpForwarding then "--no-tcpip-forward" else "--tcpip-forward"} \ 179 179 ${if x11Forwarding then "--x11-forward" else "--no-x11-forward" } \
+5 -5
nixos/modules/services/networking/ssh/sshd.nix
··· 474 474 mkdir -m 0755 -p "$(dirname '${k.path}')" 475 475 ssh-keygen \ 476 476 -t "${k.type}" \ 477 - ${if k ? bits then "-b ${toString k.bits}" else ""} \ 478 - ${if k ? rounds then "-a ${toString k.rounds}" else ""} \ 479 - ${if k ? comment then "-C '${k.comment}'" else ""} \ 480 - ${if k ? openSSHFormat && k.openSSHFormat then "-o" else ""} \ 477 + ${optionalString (k ? bits) "-b ${toString k.bits}"} \ 478 + ${optionalString (k ? rounds) "-a ${toString k.rounds}"} \ 479 + ${optionalString (k ? comment) "-C '${k.comment}'"} \ 480 + ${optionalString (k ? openSSHFormat && k.openSSHFormat) "-o"} \ 481 481 -f "${k.path}" \ 482 482 -N "" 483 483 fi ··· 550 550 '') cfg.ports} 551 551 552 552 ${concatMapStrings ({ port, addr, ... }: '' 553 - ListenAddress ${addr}${if port != null then ":" + toString port else ""} 553 + ListenAddress ${addr}${optionalString (port != null) (":" + toString port)} 554 554 '') cfg.listenAddresses} 555 555 556 556 ${optionalString cfgc.setXAuthLocation ''
+3 -3
nixos/modules/services/networking/strongswan.nix
··· 4 4 5 5 inherit (builtins) toFile; 6 6 inherit (lib) concatMapStringsSep concatStringsSep mapAttrsToList 7 - mkIf mkEnableOption mkOption types literalExpression; 7 + mkIf mkEnableOption mkOption types literalExpression optionalString; 8 8 9 9 cfg = config.services.strongswan; 10 10 ··· 34 34 35 35 strongswanConf = {setup, connections, ca, secretsFile, managePlugins, enabledPlugins}: toFile "strongswan.conf" '' 36 36 charon { 37 - ${if managePlugins then "load_modular = no" else ""} 38 - ${if managePlugins then ("load = " + (concatStringsSep " " enabledPlugins)) else ""} 37 + ${optionalString managePlugins "load_modular = no"} 38 + ${optionalString managePlugins ("load = " + (concatStringsSep " " enabledPlugins))} 39 39 plugins { 40 40 stroke { 41 41 secrets_file = ${secretsFile}
+2 -2
nixos/modules/services/networking/stunnel.nix
··· 154 154 environment.systemPackages = [ pkgs.stunnel ]; 155 155 156 156 environment.etc."stunnel.cfg".text = '' 157 - ${ if cfg.user != null then "setuid = ${cfg.user}" else "" } 158 - ${ if cfg.group != null then "setgid = ${cfg.group}" else "" } 157 + ${ optionalString (cfg.user != null) "setuid = ${cfg.user}" } 158 + ${ optionalString (cfg.group != null) "setgid = ${cfg.group}" } 159 159 160 160 debug = ${cfg.logLevel} 161 161
+1 -1
nixos/modules/services/networking/xinetd.nix
··· 27 27 ${optionalString srv.unlisted "type = UNLISTED"} 28 28 ${optionalString (srv.flags != "") "flags = ${srv.flags}"} 29 29 socket_type = ${if srv.protocol == "udp" then "dgram" else "stream"} 30 - ${if srv.port != 0 then "port = ${toString srv.port}" else ""} 30 + ${optionalString (srv.port != 0) "port = ${toString srv.port}"} 31 31 wait = ${if srv.protocol == "udp" then "yes" else "no"} 32 32 user = ${srv.user} 33 33 server = ${srv.server}
+2 -3
nixos/modules/services/security/oauth2_proxy.nix
··· 72 72 } // (getProviderOptions cfg cfg.provider) // cfg.extraConfig; 73 73 74 74 mapConfig = key: attr: 75 - if attr != null && attr != [] then ( 75 + optionalString (attr != null && attr != []) ( 76 76 if isDerivation attr then mapConfig key (toString attr) else 77 77 if (builtins.typeOf attr) == "set" then concatStringsSep " " 78 78 (mapAttrsToList (name: value: mapConfig (key + "-" + name) value) attr) else 79 79 if (builtins.typeOf attr) == "list" then concatMapStringsSep " " (mapConfig key) attr else 80 80 if (builtins.typeOf attr) == "bool" then "--${key}=${boolToString attr}" else 81 81 if (builtins.typeOf attr) == "string" then "--${key}='${attr}'" else 82 - "--${key}=${toString attr}") 83 - else ""; 82 + "--${key}=${toString attr}"); 84 83 85 84 configString = concatStringsSep " " (mapAttrsToList mapConfig allConfig); 86 85 in
+1 -1
nixos/modules/services/system/cachix-agent/default.nix
··· 72 72 EnvironmentFile = cfg.credentialsFile; 73 73 ExecStart = '' 74 74 ${cfg.package}/bin/cachix ${lib.optionalString cfg.verbose "--verbose"} ${lib.optionalString (cfg.host != null) "--host ${cfg.host}"} \ 75 - deploy agent ${cfg.name} ${if cfg.profile != null then cfg.profile else ""} 75 + deploy agent ${cfg.name} ${optionalString (cfg.profile != null) cfg.profile} 76 76 ''; 77 77 }; 78 78 };
+2 -2
nixos/modules/services/web-apps/discourse.nix
··· 1025 1025 1026 1026 services.postfix = lib.mkIf cfg.mail.incoming.enable { 1027 1027 enable = true; 1028 - sslCert = if cfg.sslCertificate != null then cfg.sslCertificate else ""; 1029 - sslKey = if cfg.sslCertificateKey != null then cfg.sslCertificateKey else ""; 1028 + sslCert = lib.optionalString (cfg.sslCertificate != null) cfg.sslCertificate; 1029 + sslKey = lib.optionalString (cfg.sslCertificateKey != null) cfg.sslCertificateKey; 1030 1030 1031 1031 origin = cfg.hostname; 1032 1032 relayDomains = [ cfg.hostname ];
+1 -1
nixos/modules/services/web-servers/fcgiwrap.nix
··· 54 54 55 55 serviceConfig = { 56 56 ExecStart = "${pkgs.fcgiwrap}/sbin/fcgiwrap -c ${builtins.toString cfg.preforkProcesses} ${ 57 - if (cfg.socketType != "unix") then "-s ${cfg.socketType}:${cfg.socketAddress}" else "" 57 + optionalString (cfg.socketType != "unix") "-s ${cfg.socketType}:${cfg.socketAddress}" 58 58 }"; 59 59 } // (if cfg.user != null && cfg.group != null then { 60 60 User = cfg.user;
+5 -5
nixos/modules/services/web-servers/lighttpd/default.nix
··· 64 64 ]; 65 65 66 66 maybeModuleString = moduleName: 67 - if elem moduleName cfg.enableModules then ''"${moduleName}"'' else ""; 67 + optionalString (elem moduleName cfg.enableModules) ''"${moduleName}"''; 68 68 69 69 modulesIncludeString = concatStringsSep ",\n" 70 70 (filter (x: x != "") (map maybeModuleString allKnownModules)); ··· 106 106 static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc" ) 107 107 index-file.names = ( "index.html" ) 108 108 109 - ${if cfg.mod_userdir then '' 109 + ${optionalString cfg.mod_userdir '' 110 110 userdir.path = "public_html" 111 - '' else ""} 111 + ''} 112 112 113 - ${if cfg.mod_status then '' 113 + ${optionalString cfg.mod_status '' 114 114 status.status-url = "/server-status" 115 115 status.statistics-url = "/server-statistics" 116 116 status.config-url = "/server-config" 117 - '' else ""} 117 + ''} 118 118 119 119 ${cfg.extraConfig} 120 120 '';
+2 -2
nixos/modules/services/web-servers/nginx/default.nix
··· 318 318 319 319 listenString = { addr, port, ssl, extraParameters ? [], ... }: 320 320 # UDP listener for QUIC transport protocol. 321 - (if ssl && vhost.quic then " 321 + (optionalString (ssl && vhost.quic) " 322 322 listen ${addr}:${toString port} quic " 323 323 + optionalString vhost.default "default_server " 324 324 + optionalString vhost.reuseport "reuseport " ··· 326 326 let inCompatibleParameters = [ "ssl" "proxy_protocol" "http2" ]; 327 327 isCompatibleParameter = param: !(any (p: p == param) inCompatibleParameters); 328 328 in filter isCompatibleParameter extraParameters)) 329 - + ";" else "") 329 + + ";") 330 330 + " 331 331 332 332 listen ${addr}:${toString port} "
+3 -3
nixos/modules/services/web-servers/tomcat.nix
··· 234 234 ln -sfn ${tomcat}/conf/$i ${cfg.baseDir}/conf/`basename $i` 235 235 done 236 236 237 - ${if cfg.extraConfigFiles != [] then '' 237 + ${optionalString (cfg.extraConfigFiles != []) '' 238 238 for i in ${toString cfg.extraConfigFiles}; do 239 239 ln -sfn $i ${cfg.baseDir}/conf/`basename $i` 240 240 done 241 - '' else ""} 241 + ''} 242 242 243 243 # Create a modified catalina.properties file 244 244 # Change all references from CATALINA_HOME to CATALINA_BASE and add support for shared libraries ··· 345 345 346 346 # Symlink all the given web applications files or paths into the webapps/ directory 347 347 # of this virtual host 348 - for i in "${if virtualHost ? webapps then toString virtualHost.webapps else ""}"; do 348 + for i in "${optionalString (virtualHost ? webapps) (toString virtualHost.webapps)}"; do 349 349 if [ -f $i ]; then 350 350 # If the given web application is a file, symlink it into the webapps/ directory 351 351 ln -sfn $i ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps/`basename $i`
+2 -2
nixos/modules/system/boot/loader/grub/grub.nix
··· 33 33 then realGrub.override { efiSupport = cfg.efiSupport; } 34 34 else null; 35 35 36 - f = x: if x == null then "" else "" + x; 36 + f = x: optionalString (x != null) ("" + x); 37 37 38 38 grubConfig = args: 39 39 let ··· 52 52 fullName = lib.getName realGrub; 53 53 fullVersion = lib.getVersion realGrub; 54 54 grubEfi = f grubEfi; 55 - grubTargetEfi = if cfg.efiSupport && (cfg.version == 2) then f (grubEfi.grubTarget or "") else ""; 55 + grubTargetEfi = optionalString (cfg.efiSupport && (cfg.version == 2)) (f (grubEfi.grubTarget or "")); 56 56 bootPath = args.path; 57 57 storePath = config.boot.loader.grub.storePath; 58 58 bootloaderId = if args.efiBootloaderId == null then "${config.system.nixos.distroName}${efiSysMountPoint'}" else args.efiBootloaderId;
+3 -3
nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
··· 20 20 21 21 nix = config.nix.package.out; 22 22 23 - timeout = if config.boot.loader.timeout != null then config.boot.loader.timeout else ""; 23 + timeout = optionalString (config.boot.loader.timeout != null) config.boot.loader.timeout; 24 24 25 25 editor = if cfg.editor then "True" else "False"; 26 26 ··· 32 32 33 33 inherit (config.system.nixos) distroName; 34 34 35 - memtest86 = if cfg.memtest86.enable then pkgs.memtest86-efi else ""; 35 + memtest86 = optionalString cfg.memtest86.enable pkgs.memtest86-efi; 36 36 37 - netbootxyz = if cfg.netbootxyz.enable then pkgs.netbootxyz-efi else ""; 37 + netbootxyz = optionalString cfg.netbootxyz.enable pkgs.netbootxyz-efi; 38 38 39 39 copyExtraFiles = pkgs.writeShellScript "copy-extra-files" '' 40 40 empty_file=$(${pkgs.coreutils}/bin/mktemp)
+1 -2
nixos/modules/system/boot/luksroot.nix
··· 1024 1024 copy_bin_and_libs ${pkgs.gnupg}/libexec/scdaemon 1025 1025 1026 1026 ${concatMapStringsSep "\n" (x: 1027 - if x.gpgCard != null then 1027 + optionalString (x.gpgCard != null) 1028 1028 '' 1029 1029 mkdir -p $out/secrets/gpg-keys/${x.device} 1030 1030 cp -a ${x.gpgCard.encryptedPass} $out/secrets/gpg-keys/${x.device}/cryptkey.gpg 1031 1031 cp -a ${x.gpgCard.publicKey} $out/secrets/gpg-keys/${x.device}/pubkey.asc 1032 1032 '' 1033 - else "" 1034 1033 ) (attrValues luks.devices) 1035 1034 } 1036 1035 ''}
+1 -1
nixos/modules/tasks/filesystems.nix
··· 319 319 message = let 320 320 fs = head (filter notAutoResizable fileSystems); 321 321 in 322 - "Mountpoint '${fs.mountPoint}': 'autoResize = true' is not supported for 'fsType = \"${fs.fsType}\"':${if fs.fsType == "auto" then " fsType has to be explicitly set and" else ""} only the ext filesystems and f2fs support it."; 322 + "Mountpoint '${fs.mountPoint}': 'autoResize = true' is not supported for 'fsType = \"${fs.fsType}\"':${optionalString (fs.fsType == "auto") " fsType has to be explicitly set and"} only the ext filesystems and f2fs support it."; 323 323 } 324 324 ]; 325 325
+4 -4
nixos/modules/virtualisation/nixos-containers.nix
··· 170 170 --setenv HOST_PORT="$HOST_PORT" \ 171 171 --setenv PATH="$PATH" \ 172 172 ${optionalString cfg.ephemeral "--ephemeral"} \ 173 - ${if cfg.additionalCapabilities != null && cfg.additionalCapabilities != [] then 174 - ''--capability="${concatStringsSep "," cfg.additionalCapabilities}"'' else "" 173 + ${optionalString (cfg.additionalCapabilities != null && cfg.additionalCapabilities != []) 174 + ''--capability="${concatStringsSep "," cfg.additionalCapabilities}"'' 175 175 } \ 176 - ${if cfg.tmpfs != null && cfg.tmpfs != [] then 177 - ''--tmpfs=${concatStringsSep " --tmpfs=" cfg.tmpfs}'' else "" 176 + ${optionalString (cfg.tmpfs != null && cfg.tmpfs != []) 177 + ''--tmpfs=${concatStringsSep " --tmpfs=" cfg.tmpfs}'' 178 178 } \ 179 179 ${containerInit cfg} "''${SYSTEM_PATH:-/nix/var/nix/profiles/system}/init" 180 180 '';
+2 -2
nixos/modules/virtualisation/qemu-vm.nix
··· 214 214 mkdir $out 215 215 diskImage=$out/disk.img 216 216 ${qemu}/bin/qemu-img create -f qcow2 $diskImage "120M" 217 - ${if cfg.useEFIBoot then '' 217 + ${lib.optionalString cfg.useEFIBoot '' 218 218 efiVars=$out/efi-vars.fd 219 219 cp ${cfg.efi.variables} $efiVars 220 220 chmod 0644 $efiVars 221 - '' else ""} 221 + ''} 222 222 ''; 223 223 buildInputs = [ pkgs.util-linux ]; 224 224 QEMU_OPTS = "-nographic -serial stdio -monitor none"