diff --git a/lib/trivial.nix b/lib/trivial.nix index acbd687dd98..62906339e60 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -30,6 +30,11 @@ rec { /* boolean “and” */ and = x: y: x && y; + /* Convert a boolean to a string. + Note that toString on a bool returns "1" and "". + */ + boolToString = b: if b then "true" else "false"; + /* Merge two attribute sets shallowly, right side trumps left Example: diff --git a/nixos/modules/config/fonts/fontconfig-penultimate.nix b/nixos/modules/config/fonts/fontconfig-penultimate.nix index 83d6532774e..3e163b8ec51 100644 --- a/nixos/modules/config/fonts/fontconfig-penultimate.nix +++ b/nixos/modules/config/fonts/fontconfig-penultimate.nix @@ -5,7 +5,7 @@ with lib; let cfg = config.fonts.fontconfig; - fcBool = x: "" + (if x then "true" else "false") + ""; + fcBool = x: "" + (boolToString x) + ""; # back-supported fontconfig version and package # version is used for font cache generation diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index d44b583447a..12f5ca2e799 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -20,7 +20,7 @@ with lib; let cfg = config.fonts.fontconfig; - fcBool = x: "" + (if x then "true" else "false") + ""; + fcBool = x: "" + (boolToString x) + ""; # back-supported fontconfig version and package # version is used for font cache generation diff --git a/nixos/modules/services/cluster/kubernetes.nix b/nixos/modules/services/cluster/kubernetes.nix index 9ccc7295019..bf7b44c698c 100644 --- a/nixos/modules/services/cluster/kubernetes.nix +++ b/nixos/modules/services/cluster/kubernetes.nix @@ -612,8 +612,8 @@ in { --require-kubeconfig \ --address=${cfg.kubelet.address} \ --port=${toString cfg.kubelet.port} \ - --register-node=${if cfg.kubelet.registerNode then "true" else "false"} \ - --register-schedulable=${if cfg.kubelet.registerSchedulable then "true" else "false"} \ + --register-node=${boolToString cfg.kubelet.registerNode} \ + --register-schedulable=${boolToString cfg.kubelet.registerSchedulable} \ ${optionalString (cfg.kubelet.tlsCertFile != null) "--tls-cert-file=${cfg.kubelet.tlsCertFile}"} \ ${optionalString (cfg.kubelet.tlsKeyFile != null) @@ -621,7 +621,7 @@ in { --healthz-bind-address=${cfg.kubelet.healthz.bind} \ --healthz-port=${toString cfg.kubelet.healthz.port} \ --hostname-override=${cfg.kubelet.hostname} \ - --allow-privileged=${if cfg.kubelet.allowPrivileged then "true" else "false"} \ + --allow-privileged=${boolToString cfg.kubelet.allowPrivileged} \ --root-dir=${cfg.dataDir} \ --cadvisor_port=${toString cfg.kubelet.cadvisorPort} \ ${optionalString (cfg.kubelet.clusterDns != "") @@ -670,14 +670,14 @@ in { --bind-address=0.0.0.0 \ ${optionalString (cfg.apiserver.advertiseAddress != null) "--advertise-address=${cfg.apiserver.advertiseAddress}"} \ - --allow-privileged=${if cfg.apiserver.allowPrivileged then "true" else "false"} \ + --allow-privileged=${boolToString cfg.apiserver.allowPrivileged}\ ${optionalString (cfg.apiserver.tlsCertFile != null) "--tls-cert-file=${cfg.apiserver.tlsCertFile}"} \ ${optionalString (cfg.apiserver.tlsKeyFile != null) "--tls-private-key-file=${cfg.apiserver.tlsKeyFile}"} \ ${optionalString (cfg.apiserver.tokenAuth != null) "--token-auth-file=${cfg.apiserver.tokenAuth}"} \ - --kubelet-https=${if cfg.apiserver.kubeletHttps then "true" else "false"} \ + --kubelet-https=${boolToString cfg.apiserver.kubeletHttps} \ ${optionalString (cfg.apiserver.kubeletClientCaFile != null) "--kubelet-certificate-authority=${cfg.apiserver.kubeletClientCaFile}"} \ ${optionalString (cfg.apiserver.kubeletClientCertFile != null) @@ -719,7 +719,7 @@ in { ExecStart = ''${cfg.package}/bin/kube-scheduler \ --address=${cfg.scheduler.address} \ --port=${toString cfg.scheduler.port} \ - --leader-elect=${if cfg.scheduler.leaderElect then "true" else "false"} \ + --leader-elect=${boolToString cfg.scheduler.leaderElect} \ --kubeconfig=${kubeconfig} \ ${optionalString cfg.verbose "--v=6"} \ ${optionalString cfg.verbose "--log-flush-frequency=1s"} \ @@ -744,7 +744,7 @@ in { --address=${cfg.controllerManager.address} \ --port=${toString cfg.controllerManager.port} \ --kubeconfig=${kubeconfig} \ - --leader-elect=${if cfg.controllerManager.leaderElect then "true" else "false"} \ + --leader-elect=${boolToString cfg.controllerManager.leaderElect} \ ${if (cfg.controllerManager.serviceAccountKeyFile!=null) then "--service-account-private-key-file=${cfg.controllerManager.serviceAccountKeyFile}" else "--service-account-private-key-file=/var/run/kubernetes/apiserver.key"} \ diff --git a/nixos/modules/services/continuous-integration/hydra/default.nix b/nixos/modules/services/continuous-integration/hydra/default.nix index fa550f68b33..57f592a2e55 100644 --- a/nixos/modules/services/continuous-integration/hydra/default.nix +++ b/nixos/modules/services/continuous-integration/hydra/default.nix @@ -328,7 +328,7 @@ in IN_SYSTEMD = "1"; # to get log severity levels }; serviceConfig = - { ExecStart = "@${cfg.package}/bin/hydra-queue-runner hydra-queue-runner -v --option build-use-substitutes ${if cfg.useSubstitutes then "true" else "false"}"; + { ExecStart = "@${cfg.package}/bin/hydra-queue-runner hydra-queue-runner -v --option build-use-substitutes ${boolToString cfg.useSubstitutes}"; ExecStopPost = "${cfg.package}/bin/hydra-queue-runner --unlock"; User = "hydra-queue-runner"; Restart = "always"; diff --git a/nixos/modules/services/databases/cassandra.nix b/nixos/modules/services/databases/cassandra.nix index 5df4ae57f80..1e5cd8f5413 100644 --- a/nixos/modules/services/databases/cassandra.nix +++ b/nixos/modules/services/databases/cassandra.nix @@ -21,8 +21,8 @@ let cassandraConf = '' cluster_name: ${cfg.clusterName} num_tokens: 256 - auto_bootstrap: ${if cfg.autoBootstrap then "true" else "false"} - hinted_handoff_enabled: ${if cfg.hintedHandOff then "true" else "false"} + auto_bootstrap: ${boolToString cfg.autoBootstrap} + hinted_handoff_enabled: ${boolToString cfg.hintedHandOff} hinted_handoff_throttle_in_kb: ${builtins.toString cfg.hintedHandOffThrottle} max_hints_delivery_threads: 2 max_hint_window_in_ms: 10800000 # 3 hours @@ -62,7 +62,7 @@ let rpc_keepalive: true rpc_server_type: sync thrift_framed_transport_size_in_mb: 15 - incremental_backups: ${if cfg.incrementalBackups then "true" else "false"} + incremental_backups: ${boolToString cfg.incrementalBackups} snapshot_before_compaction: false auto_snapshot: true column_index_size_in_kb: 64 @@ -89,7 +89,7 @@ let truststore: ${cfg.trustStorePath} truststore_password: ${cfg.trustStorePassword} client_encryption_options: - enabled: ${if cfg.clientEncryption then "true" else "false"} + enabled: ${boolToString cfg.clientEncryption} keystore: ${cfg.keyStorePath} keystore_password: ${cfg.keyStorePassword} internode_compression: all diff --git a/nixos/modules/services/databases/mongodb.nix b/nixos/modules/services/databases/mongodb.nix index 38e46a0c6ef..c56564f57f3 100644 --- a/nixos/modules/services/databases/mongodb.nix +++ b/nixos/modules/services/databases/mongodb.nix @@ -4,8 +4,6 @@ with lib; let - b2s = x: if x then "true" else "false"; - cfg = config.services.mongodb; mongodb = cfg.package; diff --git a/nixos/modules/services/logging/graylog.nix b/nixos/modules/services/logging/graylog.nix index 95283096662..9f0fb11f025 100644 --- a/nixos/modules/services/logging/graylog.nix +++ b/nixos/modules/services/logging/graylog.nix @@ -4,16 +4,15 @@ with lib; let cfg = config.services.graylog; - configBool = b: if b then "true" else "false"; confFile = pkgs.writeText "graylog.conf" '' - is_master = ${configBool cfg.isMaster} + is_master = ${boolToString cfg.isMaster} node_id_file = ${cfg.nodeIdFile} password_secret = ${cfg.passwordSecret} root_username = ${cfg.rootUsername} root_password_sha2 = ${cfg.rootPasswordSha2} elasticsearch_cluster_name = ${cfg.elasticsearchClusterName} - elasticsearch_discovery_zen_ping_multicast_enabled = ${configBool cfg.elasticsearchDiscoveryZenPingMulticastEnabled} + elasticsearch_discovery_zen_ping_multicast_enabled = ${boolToString cfg.elasticsearchDiscoveryZenPingMulticastEnabled} elasticsearch_discovery_zen_ping_unicast_hosts = ${cfg.elasticsearchDiscoveryZenPingUnicastHosts} message_journal_dir = ${cfg.messageJournalDir} mongodb_uri = ${cfg.mongodbUri} diff --git a/nixos/modules/services/misc/cgminer.nix b/nixos/modules/services/misc/cgminer.nix index 5f97cc03414..d5071d8ff76 100644 --- a/nixos/modules/services/misc/cgminer.nix +++ b/nixos/modules/services/misc/cgminer.nix @@ -6,7 +6,7 @@ let cfg = config.services.cgminer; convType = with builtins; - v: if isBool v then (if v then "true" else "false") else toString v; + v: if isBool v then boolToString v else toString v; mergedHwConfig = mapAttrsToList (n: v: ''"${n}": "${(concatStringsSep "," (map convType v))}"'') (foldAttrs (n: a: [n] ++ a) [] cfg.hardware); diff --git a/nixos/modules/services/misc/confd.nix b/nixos/modules/services/misc/confd.nix index fe13013286b..8e9bec15dd4 100755 --- a/nixos/modules/services/misc/confd.nix +++ b/nixos/modules/services/misc/confd.nix @@ -12,7 +12,7 @@ let nodes = [ ${concatMapStringsSep "," (s: ''"${s}"'') cfg.nodes}, ] prefix = "${cfg.prefix}" log-level = "${cfg.logLevel}" - watch = ${if cfg.watch then "true" else "false"} + watch = ${boolToString cfg.watch} ''; in { diff --git a/nixos/modules/services/misc/matrix-synapse.nix b/nixos/modules/services/misc/matrix-synapse.nix index 4a1bea50c14..ae9826968b1 100644 --- a/nixos/modules/services/misc/matrix-synapse.nix +++ b/nixos/modules/services/misc/matrix-synapse.nix @@ -5,9 +5,8 @@ with lib; let cfg = config.services.matrix-synapse; logConfigFile = pkgs.writeText "log_config.yaml" cfg.logConfig; - mkResource = r: ''{names: ${builtins.toJSON r.names}, compress: ${fromBool r.compress}}''; - mkListener = l: ''{port: ${toString l.port}, bind_address: "${l.bind_address}", type: ${l.type}, tls: ${fromBool l.tls}, x_forwarded: ${fromBool l.x_forwarded}, resources: [${concatStringsSep "," (map mkResource l.resources)}]}''; - fromBool = x: if x then "true" else "false"; + mkResource = r: ''{names: ${builtins.toJSON r.names}, compress: ${boolToString r.compress}}''; + mkListener = l: ''{port: ${toString l.port}, bind_address: "${l.bind_address}", type: ${l.type}, tls: ${boolToString l.tls}, x_forwarded: ${boolToString l.x_forwarded}, resources: [${concatStringsSep "," (map mkResource l.resources)}]}''; configFile = pkgs.writeText "homeserver.yaml" '' ${optionalString (cfg.tls_certificate_path != null) '' tls_certificate_path: "${cfg.tls_certificate_path}" @@ -18,7 +17,7 @@ tls_private_key_path: "${cfg.tls_private_key_path}" ${optionalString (cfg.tls_dh_params_path != null) '' tls_dh_params_path: "${cfg.tls_dh_params_path}" ''} -no_tls: ${fromBool cfg.no_tls} +no_tls: ${boolToString cfg.no_tls} ${optionalString (cfg.bind_port != null) '' bind_port: ${toString cfg.bind_port} ''} @@ -30,7 +29,7 @@ bind_host: "${cfg.bind_host}" ''} server_name: "${cfg.server_name}" pid_file: "/var/run/matrix-synapse.pid" -web_client: ${fromBool cfg.web_client} +web_client: ${boolToString cfg.web_client} ${optionalString (cfg.public_baseurl != null) '' public_baseurl: "${cfg.public_baseurl}" ''} @@ -58,8 +57,8 @@ media_store_path: "/var/lib/matrix-synapse/media" uploads_path: "/var/lib/matrix-synapse/uploads" max_upload_size: "${cfg.max_upload_size}" max_image_pixels: "${cfg.max_image_pixels}" -dynamic_thumbnails: ${fromBool cfg.dynamic_thumbnails} -url_preview_enabled: ${fromBool cfg.url_preview_enabled} +dynamic_thumbnails: ${boolToString cfg.dynamic_thumbnails} +url_preview_enabled: ${boolToString cfg.url_preview_enabled} ${optionalString (cfg.url_preview_enabled == true) '' url_preview_ip_range_blacklist: ${builtins.toJSON cfg.url_preview_ip_range_blacklist} url_preview_ip_range_whitelist: ${builtins.toJSON cfg.url_preview_ip_range_whitelist} @@ -67,10 +66,10 @@ url_preview_url_blacklist: ${builtins.toJSON cfg.url_preview_url_blacklist} ''} recaptcha_private_key: "${cfg.recaptcha_private_key}" recaptcha_public_key: "${cfg.recaptcha_public_key}" -enable_registration_captcha: ${fromBool cfg.enable_registration_captcha} +enable_registration_captcha: ${boolToString cfg.enable_registration_captcha} turn_uris: ${builtins.toJSON cfg.turn_uris} turn_shared_secret: "${cfg.turn_shared_secret}" -enable_registration: ${fromBool cfg.enable_registration} +enable_registration: ${boolToString cfg.enable_registration} ${optionalString (cfg.registration_shared_secret != null) '' registration_shared_secret: "${cfg.registration_shared_secret}" ''} @@ -78,15 +77,15 @@ recaptcha_siteverify_api: "https://www.google.com/recaptcha/api/siteverify" turn_user_lifetime: "${cfg.turn_user_lifetime}" user_creation_max_duration: ${cfg.user_creation_max_duration} bcrypt_rounds: ${cfg.bcrypt_rounds} -allow_guest_access: ${fromBool cfg.allow_guest_access} +allow_guest_access: ${boolToString cfg.allow_guest_access} trusted_third_party_id_servers: ${builtins.toJSON cfg.trusted_third_party_id_servers} room_invite_state_types: ${builtins.toJSON cfg.room_invite_state_types} ${optionalString (cfg.macaroon_secret_key != null) '' macaroon_secret_key: "${cfg.macaroon_secret_key}" ''} -expire_access_token: ${fromBool cfg.expire_access_token} -enable_metrics: ${fromBool cfg.enable_metrics} -report_stats: ${fromBool cfg.report_stats} +expire_access_token: ${boolToString cfg.expire_access_token} +enable_metrics: ${boolToString cfg.enable_metrics} +report_stats: ${boolToString cfg.report_stats} signing_key_path: "/var/lib/matrix-synapse/homeserver.signing.key" key_refresh_interval: "${cfg.key_refresh_interval}" perspectives: diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix index 4fe89838e29..bf1304ee7ac 100644 --- a/nixos/modules/services/misc/nix-daemon.nix +++ b/nixos/modules/services/misc/nix-daemon.nix @@ -41,12 +41,12 @@ let build-users-group = nixbld build-max-jobs = ${toString (cfg.maxJobs)} build-cores = ${toString (cfg.buildCores)} - build-use-sandbox = ${if (builtins.isBool cfg.useSandbox) then (if cfg.useSandbox then "true" else "false") else cfg.useSandbox} + build-use-sandbox = ${if (builtins.isBool cfg.useSandbox) then boolToString cfg.useSandbox else cfg.useSandbox} build-sandbox-paths = ${toString cfg.sandboxPaths} /bin/sh=${sh} $(echo $extraPaths) binary-caches = ${toString cfg.binaryCaches} trusted-binary-caches = ${toString cfg.trustedBinaryCaches} binary-cache-public-keys = ${toString cfg.binaryCachePublicKeys} - auto-optimise-store = ${if cfg.autoOptimiseStore then "true" else "false"} + auto-optimise-store = ${boolToString cfg.autoOptimiseStore} ${optionalString cfg.requireSignedBinaryCaches '' signed-binary-caches = * ''} diff --git a/nixos/modules/services/misc/taskserver/default.nix b/nixos/modules/services/misc/taskserver/default.nix index ba9f52f1904..ab9a6ce32f4 100644 --- a/nixos/modules/services/misc/taskserver/default.nix +++ b/nixos/modules/services/misc/taskserver/default.nix @@ -128,7 +128,7 @@ let certBits = cfg.pki.auto.bits; clientExpiration = cfg.pki.auto.expiration.client; crlExpiration = cfg.pki.auto.expiration.crl; - isAutoConfig = if needToCreateCA then "True" else "False"; + isAutoConfig = boolToString needToCreateCA; }}" > "$out/main.py" cat > "$out/setup.py" </conf" ./ircd.conf ]; inherit (pkgs) ircdHybrid coreutils su iproute gnugrep procps; - ipv6Enabled = if config.networking.enableIPv6 then "true" else "false"; + ipv6Enabled = boolToString config.networking.enableIPv6; inherit (cfg) serverName sid description adminEmail extraPort; diff --git a/nixos/modules/services/networking/mosquitto.nix b/nixos/modules/services/networking/mosquitto.nix index 2325424ff3c..5451500b56f 100644 --- a/nixos/modules/services/networking/mosquitto.nix +++ b/nixos/modules/services/networking/mosquitto.nix @@ -16,7 +16,7 @@ let pid_file /run/mosquitto/pid acl_file ${aclFile} persistence true - allow_anonymous ${if cfg.allowAnonymous then "true" else "false"} + allow_anonymous ${boolToString cfg.allowAnonymous} bind_address ${cfg.host} port ${toString cfg.port} ${listenerConf} diff --git a/nixos/modules/services/networking/murmur.nix b/nixos/modules/services/networking/murmur.nix index 81f968ae9fe..c961857c77a 100644 --- a/nixos/modules/services/networking/murmur.nix +++ b/nixos/modules/services/networking/murmur.nix @@ -26,21 +26,21 @@ let textmessagelength=${toString cfg.textMsgLength} imagemessagelength=${toString cfg.imgMsgLength} - allowhtml=${if cfg.allowHtml then "true" else "false"} + allowhtml=${boolToString cfg.allowHtml} logdays=${toString cfg.logDays} - bonjour=${if cfg.bonjour then "true" else "false"} - sendversion=${if cfg.sendVersion then "true" else "false"} + bonjour=${babelToString cfg.bonjour} + sendversion=${babelToString 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} - certrequired=${if cfg.clientCertRequired then "true" else "false"} + certrequired=${babelToString 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} - + ${cfg.extraConfig} ''; in diff --git a/nixos/modules/services/networking/prosody.nix b/nixos/modules/services/networking/prosody.nix index feaa007de15..fb9c9dc67f2 100644 --- a/nixos/modules/services/networking/prosody.nix +++ b/nixos/modules/services/networking/prosody.nix @@ -219,7 +219,7 @@ in data_path = "/var/lib/prosody" - allow_registration = ${ if cfg.allowRegistration then "true" else "false" }; + allow_registration = ${boolToString cfg.allowRegistration}; ${ optionalString cfg.modules.console "console_enabled = true;" } @@ -244,7 +244,7 @@ in ${ lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: '' VirtualHost "${v.domain}" - enabled = ${if v.enabled then "true" else "false"}; + enabled = ${boolToString v.enabled}; ${ optionalString (v.ssl != null) (createSSLOptsStr v.ssl) } ${ v.extraConfig } '') cfg.virtualHosts) } diff --git a/nixos/modules/services/networking/sslh.nix b/nixos/modules/services/networking/sslh.nix index bd584a3a85d..e3d65c49fbf 100644 --- a/nixos/modules/services/networking/sslh.nix +++ b/nixos/modules/services/networking/sslh.nix @@ -5,7 +5,7 @@ with lib; let cfg = config.services.sslh; configFile = pkgs.writeText "sslh.conf" '' - verbose: ${if cfg.verbose then "true" else "false"}; + verbose: ${boolToString cfg.verbose}; foreground: true; inetd: false; numeric: false; diff --git a/nixos/modules/services/networking/znc.nix b/nixos/modules/services/networking/znc.nix index 6d68b790e86..1c63d800e26 100644 --- a/nixos/modules/services/networking/znc.nix +++ b/nixos/modules/services/networking/znc.nix @@ -35,7 +35,7 @@ let Port = ${toString confOpts.port} IPv4 = true IPv6 = true - SSL = ${if confOpts.useSSL then "true" else "false"} + SSL = ${boolToString confOpts.useSSL} diff --git a/nixos/modules/services/security/oauth2_proxy.nix b/nixos/modules/services/security/oauth2_proxy.nix index caa7d9d5081..e292fd9851e 100644 --- a/nixos/modules/services/security/oauth2_proxy.nix +++ b/nixos/modules/services/security/oauth2_proxy.nix @@ -10,9 +10,6 @@ let # repeatedArgs (arg: "--arg=${arg}") args repeatedArgs = concatMapStringsSep " "; - # 'toString' doesn't quite do what we want for bools. - fromBool = x: if x then "true" else "false"; - # oauth2_proxy provides many options that are only relevant if you are using # a certain provider. This set maps from provider name to a function that # takes the configuration and returns a string that can be inserted into the @@ -49,24 +46,24 @@ let --client-secret='${cfg.clientSecret}' \ ${optionalString (!isNull cfg.cookie.domain) "--cookie-domain='${cfg.cookie.domain}'"} \ --cookie-expire='${cfg.cookie.expire}' \ - --cookie-httponly=${fromBool cfg.cookie.httpOnly} \ + --cookie-httponly=${boolToString cfg.cookie.httpOnly} \ --cookie-name='${cfg.cookie.name}' \ --cookie-secret='${cfg.cookie.secret}' \ - --cookie-secure=${fromBool cfg.cookie.secure} \ + --cookie-secure=${boolToString cfg.cookie.secure} \ ${optionalString (!isNull cfg.cookie.refresh) "--cookie-refresh='${cfg.cookie.refresh}'"} \ ${optionalString (!isNull cfg.customTemplatesDir) "--custom-templates-dir='${cfg.customTemplatesDir}'"} \ ${repeatedArgs (x: "--email-domain='${x}'") cfg.email.domains} \ --http-address='${cfg.httpAddress}' \ - ${optionalString (!isNull cfg.htpasswd.file) "--htpasswd-file='${cfg.htpasswd.file}' --display-htpasswd-form=${fromBool cfg.htpasswd.displayForm}"} \ + ${optionalString (!isNull cfg.htpasswd.file) "--htpasswd-file='${cfg.htpasswd.file}' --display-htpasswd-form=${boolToString cfg.htpasswd.displayForm}"} \ ${optionalString (!isNull cfg.loginURL) "--login-url='${cfg.loginURL}'"} \ - --pass-access-token=${fromBool cfg.passAccessToken} \ - --pass-basic-auth=${fromBool cfg.passBasicAuth} \ - --pass-host-header=${fromBool cfg.passHostHeader} \ + --pass-access-token=${boolToString cfg.passAccessToken} \ + --pass-basic-auth=${boolToString cfg.passBasicAuth} \ + --pass-host-header=${boolToString cfg.passHostHeader} \ --proxy-prefix='${cfg.proxyPrefix}' \ ${optionalString (!isNull cfg.profileURL) "--profile-url='${cfg.profileURL}'"} \ ${optionalString (!isNull cfg.redeemURL) "--redeem-url='${cfg.redeemURL}'"} \ ${optionalString (!isNull cfg.redirectURL) "--redirect-url='${cfg.redirectURL}'"} \ - --request-logging=${fromBool cfg.requestLogging} \ + --request-logging=${boolToString cfg.requestLogging} \ ${optionalString (!isNull cfg.scope) "--scope='${cfg.scope}'"} \ ${repeatedArgs (x: "--skip-auth-regex='${x}'") cfg.skipAuthRegexes} \ ${optionalString (!isNull cfg.signatureKey) "--signature-key='${cfg.signatureKey}'"} \ diff --git a/nixos/modules/services/torrent/transmission.nix b/nixos/modules/services/torrent/transmission.nix index 5b2e4ca1606..1f319df794b 100644 --- a/nixos/modules/services/torrent/transmission.nix +++ b/nixos/modules/services/torrent/transmission.nix @@ -15,8 +15,7 @@ let # Strings must be quoted, ints and bools must not (for settings.json). toOption = x: - if x == true then "true" - else if x == false then "false" + if isBool x then boolToString x else if isInt x then toString x else toString ''"${x}"''; diff --git a/nixos/modules/services/web-apps/atlassian/crowd.nix b/nixos/modules/services/web-apps/atlassian/crowd.nix index ce41aa4f1e1..b54c91d7de9 100644 --- a/nixos/modules/services/web-apps/atlassian/crowd.nix +++ b/nixos/modules/services/web-apps/atlassian/crowd.nix @@ -137,7 +137,7 @@ in sed -e 's,port="8095",port="${toString cfg.listenPort}" address="${cfg.listenAddress}",' \ '' + (lib.optionalString cfg.proxy.enable '' - -e 's,compression="on",compression="off" protocol="HTTP/1.1" proxyName="${cfg.proxy.name}" proxyPort="${toString cfg.proxy.port}" scheme="${cfg.proxy.scheme}" secure="${if cfg.proxy.secure then "true" else "false"}",' \ + -e 's,compression="on",compression="off" protocol="HTTP/1.1" proxyName="${cfg.proxy.name}" proxyPort="${toString cfg.proxy.port}" scheme="${cfg.proxy.scheme}" secure="${boolToString cfg.proxy.secure}",' \ '') + '' ${pkg}/apache-tomcat/conf/server.xml.dist > ${cfg.home}/server.xml ''; diff --git a/nixos/modules/services/web-apps/quassel-webserver.nix b/nixos/modules/services/web-apps/quassel-webserver.nix index d19e4bc5827..2ba5698d6cb 100644 --- a/nixos/modules/services/web-apps/quassel-webserver.nix +++ b/nixos/modules/services/web-apps/quassel-webserver.nix @@ -12,11 +12,11 @@ let port: ${toString cfg.quasselCorePort}, // quasselcore port initialBacklogLimit: ${toString cfg.initialBacklogLimit}, // Amount of backlogs to fetch per buffer on connection backlogLimit: ${toString cfg.backlogLimit}, // Amount of backlogs to fetch per buffer after first retrieval - securecore: ${if cfg.secureCore then "true" else "false"}, // Connect to the core using SSL + securecore: ${boolToString cfg.secureCore}, // Connect to the core using SSL theme: '${cfg.theme}' // Default UI theme }, themes: ['default', 'darksolarized'], // Available themes - forcedefault: ${if cfg.forceHostAndPort then "true" else "false"}, // Will force default host and port to be used, and will hide the corresponding fields in the UI + forcedefault: ${boolToString cfg.forceHostAndPort}, // Will force default host and port to be used, and will hide the corresponding fields in the UI prefixpath: '${cfg.prefixPath}' // Configure this if you use a reverse proxy }; ''; diff --git a/nixos/modules/services/web-apps/tt-rss.nix b/nixos/modules/services/web-apps/tt-rss.nix index 5193814da72..76b0ee6da96 100644 --- a/nixos/modules/services/web-apps/tt-rss.nix +++ b/nixos/modules/services/web-apps/tt-rss.nix @@ -6,8 +6,6 @@ let configVersion = 26; - boolToString = b: if b then "true" else "false"; - cacheDir = "cache"; lockDir = "lock"; feedIconsDir = "feed-icons"; diff --git a/nixos/modules/services/x11/display-managers/sddm.nix b/nixos/modules/services/x11/display-managers/sddm.nix index affc1261d19..99c03ca81c2 100644 --- a/nixos/modules/services/x11/display-managers/sddm.nix +++ b/nixos/modules/services/x11/display-managers/sddm.nix @@ -59,7 +59,7 @@ let [Autologin] User=${cfg.autoLogin.user} Session=${defaultSessionName}.desktop - Relogin=${if cfg.autoLogin.relogin then "true" else "false"} + Relogin=${boolToString cfg.autoLogin.relogin} ''} ${cfg.extraConfig} diff --git a/nixos/modules/services/x11/hardware/multitouch.nix b/nixos/modules/services/x11/hardware/multitouch.nix index 0e9eb021494..c03bb3b494f 100644 --- a/nixos/modules/services/x11/hardware/multitouch.nix +++ b/nixos/modules/services/x11/hardware/multitouch.nix @@ -74,7 +74,7 @@ in { MatchIsTouchpad "on" Identifier "Touchpads" Driver "mtrack" - Option "IgnorePalm" "${if cfg.ignorePalm then "true" else "false"}" + Option "IgnorePalm" "${boolToString cfg.ignorePalm}" Option "ClickFinger1" "${builtins.elemAt cfg.buttonsMap 0}" Option "ClickFinger2" "${builtins.elemAt cfg.buttonsMap 1}" Option "ClickFinger3" "${builtins.elemAt cfg.buttonsMap 2}" diff --git a/pkgs/development/java-modules/build-maven-package.nix b/pkgs/development/java-modules/build-maven-package.nix index d83b43ffd75..b3c3e1732e0 100644 --- a/pkgs/development/java-modules/build-maven-package.nix +++ b/pkgs/development/java-modules/build-maven-package.nix @@ -27,7 +27,7 @@ in stdenv.mkDerivation rec { echo "\ tmpm2file://$out/m2*\ $out/m2/" >> $out/m2/settings.xml - ${maven}/bin/mvn ${optionalString (quiet) "-q"} clean package -Dmaven.test.skip=${if skipTests then "true" else "false"} -Danimal.sniffer.skip=true -gs $out/m2/settings.xml + ${maven}/bin/mvn ${optionalString (quiet) "-q"} clean package -Dmaven.test.skip=${boolToString skipTests} -Danimal.sniffer.skip=true -gs $out/m2/settings.xml cp ./target/*.jar $out/m2/${m2Path} cp -v ./target/*.jar $out/target/ ''; diff --git a/pkgs/development/ocaml-modules/mtime/default.nix b/pkgs/development/ocaml-modules/mtime/default.nix index a26109bd4f9..5e18d1fd6e4 100644 --- a/pkgs/development/ocaml-modules/mtime/default.nix +++ b/pkgs/development/ocaml-modules/mtime/default.nix @@ -1,7 +1,9 @@ -{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, js_of_ocaml +{ stdenv, lib, fetchurl, ocaml, findlib, ocamlbuild, opam, js_of_ocaml , jsooSupport ? !(stdenv.lib.versionAtLeast ocaml.version "4.04") }: +with lib; + stdenv.mkDerivation { name = "ocaml${ocaml.version}-mtime-0.8.3"; @@ -15,7 +17,7 @@ stdenv.mkDerivation { buildInputs = [ ocaml findlib ocamlbuild opam ] ++ stdenv.lib.optional jsooSupport js_of_ocaml; - buildPhase = "ocaml pkg/build.ml native=true native-dynlink=true jsoo=${if jsooSupport then "true" else "false"}"; + buildPhase = "ocaml pkg/build.ml native=true native-dynlink=true jsoo=${boolToString jsooSupport}"; installPhase = "opam-installer -i --prefix=$out --libdir=$OCAMLFIND_DESTDIR"; @@ -23,7 +25,7 @@ stdenv.mkDerivation { description = "Monotonic wall-clock time for OCaml"; homepage = http://erratique.ch/software/mtime; inherit (ocaml.meta) platforms; - maintainers = [ stdenv.lib.maintainers.vbgl ]; - license = stdenv.lib.licenses.bsd3; + maintainers = [ maintainers.vbgl ]; + license = licenses.bsd3; }; } diff --git a/pkgs/development/ocaml-modules/nocrypto/default.nix b/pkgs/development/ocaml-modules/nocrypto/default.nix index f9240f7507c..91ab694eb6f 100644 --- a/pkgs/development/ocaml-modules/nocrypto/default.nix +++ b/pkgs/development/ocaml-modules/nocrypto/default.nix @@ -24,7 +24,7 @@ stdenv.mkDerivation rec { buildPhase = '' LD_LIBRARY_PATH=${cpuid}/lib/ocaml/${ocaml.version}/site-lib/stubslibs/ \ - ${topkg.buildPhase} --with-lwt ${if withLwt then "true" else "false"} + ${topkg.buildPhase} --with-lwt ${boolToString withLwt} ''; inherit (topkg) installPhase; diff --git a/pkgs/development/ocaml-modules/notty/default.nix b/pkgs/development/ocaml-modules/notty/default.nix index b967728d048..950395bd7ea 100644 --- a/pkgs/development/ocaml-modules/notty/default.nix +++ b/pkgs/development/ocaml-modules/notty/default.nix @@ -29,7 +29,7 @@ buildOcaml rec { optional withLwt lwt; buildPhase = topkg.buildPhase - + " --with-lwt ${if withLwt then "true" else "false"}"; + + " --with-lwt ${boolToString withLwt}"; inherit (topkg) installPhase; diff --git a/pkgs/development/ocaml-modules/vg/default.nix b/pkgs/development/ocaml-modules/vg/default.nix index cb7878ac731..ba33081486d 100644 --- a/pkgs/development/ocaml-modules/vg/default.nix +++ b/pkgs/development/ocaml-modules/vg/default.nix @@ -1,16 +1,17 @@ -{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg +{ stdenv, lib, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg , uchar, result, gg, uutf, otfm, js_of_ocaml, pdfBackend ? true, # depends on uutf and otfm htmlcBackend ? true # depends on js_of_ocaml }: +with lib; + let inherit (stdenv.lib) optionals versionAtLeast; pname = "vg"; version = "0.9.0"; webpage = "http://erratique.ch/software/${pname}"; - sob = b: if b then "true" else "false"; in assert versionAtLeast ocaml.version "4.02.0"; @@ -35,13 +36,14 @@ stdenv.mkDerivation rec { unpackCmd = "tar xjf $src"; buildPhase = topkg.buildPhase - + " --with-uutf ${sob pdfBackend} --with-otfm ${sob pdfBackend}" - + " --with-js_of_ocaml ${sob htmlcBackend}" - + " --with-cairo2 false"; + + " --with-uutf ${boolToString pdfBackend}" + + " --with-otfm ${boolToString pdfBackend}" + + " --with-js_of_ocaml ${boolToString htmlcBackend}" + + " --with-cairo2 false"; inherit (topkg) installPhase; - meta = with stdenv.lib; { + meta = { description = "Declarative 2D vector graphics for OCaml"; longDescription = '' Vg is an OCaml module for declarative 2D vector graphics. In Vg, images