diff options
author | Daniel Peebles <copumpkin@users.noreply.github.com> | 2017-04-13 09:45:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-13 09:45:31 -0400 |
commit | 09a9a472ee783b40c2a3dd287bbe9d3c60f8fc58 (patch) | |
tree | 2832fb78a53694685603701f740bd9535be2d783 /nixos | |
parent | c9ba39116c6e85f06cfba9c435fc437591bbca1c (diff) | |
parent | 3ab45f4b369c9c741b55ddedeaac4c797dc61c04 (diff) | |
download | nixpkgs-09a9a472ee783b40c2a3dd287bbe9d3c60f8fc58.tar nixpkgs-09a9a472ee783b40c2a3dd287bbe9d3c60f8fc58.tar.gz nixpkgs-09a9a472ee783b40c2a3dd287bbe9d3c60f8fc58.tar.bz2 nixpkgs-09a9a472ee783b40c2a3dd287bbe9d3c60f8fc58.tar.lz nixpkgs-09a9a472ee783b40c2a3dd287bbe9d3c60f8fc58.tar.xz nixpkgs-09a9a472ee783b40c2a3dd287bbe9d3c60f8fc58.tar.zst nixpkgs-09a9a472ee783b40c2a3dd287bbe9d3c60f8fc58.zip |
Merge pull request #24830 from mayflower/refactor/boolToString
treewide: use boolToString function
Diffstat (limited to 'nixos')
34 files changed, 89 insertions, 105 deletions
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: "<bool>" + (if x then "true" else "false") + "</bool>"; + fcBool = x: "<bool>" + (boolToString x) + "</bool>"; # 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: "<bool>" + (if x then "true" else "false") + "</bool>"; + fcBool = x: "<bool>" + (boolToString x) + "</bool>"; # 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" <<EOF from setuptools import setup diff --git a/nixos/modules/services/monitoring/collectd.nix b/nixos/modules/services/monitoring/collectd.nix index 641da60e9ad..79a8a1ff5ae 100644 --- a/nixos/modules/services/monitoring/collectd.nix +++ b/nixos/modules/services/monitoring/collectd.nix @@ -8,7 +8,7 @@ let conf = pkgs.writeText "collectd.conf" '' BaseDir "${cfg.dataDir}" PIDFile "${cfg.pidFile}" - AutoLoadPlugin ${if cfg.autoLoadPlugin then "true" else "false"} + AutoLoadPlugin ${boolToString cfg.autoLoadPlugin} Hostname "${config.networking.hostName}" LoadPlugin syslog diff --git a/nixos/modules/services/monitoring/grafana.nix b/nixos/modules/services/monitoring/grafana.nix index 97806d5d83e..4fbacef788f 100644 --- a/nixos/modules/services/monitoring/grafana.nix +++ b/nixos/modules/services/monitoring/grafana.nix @@ -5,8 +5,6 @@ with lib; let cfg = config.services.grafana; - b2s = val: if val then "true" else "false"; - envOptions = { PATHS_DATA = cfg.dataDir; PATHS_PLUGINS = "${cfg.dataDir}/plugins"; @@ -32,16 +30,16 @@ let SECURITY_ADMIN_PASSWORD = cfg.security.adminPassword; SECURITY_SECRET_KEY = cfg.security.secretKey; - USERS_ALLOW_SIGN_UP = b2s cfg.users.allowSignUp; - USERS_ALLOW_ORG_CREATE = b2s cfg.users.allowOrgCreate; - USERS_AUTO_ASSIGN_ORG = b2s cfg.users.autoAssignOrg; + USERS_ALLOW_SIGN_UP = boolToString cfg.users.allowSignUp; + USERS_ALLOW_ORG_CREATE = boolToString cfg.users.allowOrgCreate; + USERS_AUTO_ASSIGN_ORG = boolToString cfg.users.autoAssignOrg; USERS_AUTO_ASSIGN_ORG_ROLE = cfg.users.autoAssignOrgRole; - AUTH_ANONYMOUS_ENABLED = b2s cfg.auth.anonymous.enable; + AUTH_ANONYMOUS_ENABLED = boolToString cfg.auth.anonymous.enable; AUTH_ANONYMOUS_ORG_NAME = cfg.auth.anonymous.org_name; AUTH_ANONYMOUS_ORG_ROLE = cfg.auth.anonymous.org_role; - ANALYTICS_REPORTING_ENABLED = b2s cfg.analytics.reporting.enable; + ANALYTICS_REPORTING_ENABLED = boolToString cfg.analytics.reporting.enable; } // cfg.extraOptions; in { diff --git a/nixos/modules/services/network-filesystems/netatalk.nix b/nixos/modules/services/network-filesystems/netatalk.nix index bff54406a2b..1dd869043f0 100644 --- a/nixos/modules/services/network-filesystems/netatalk.nix +++ b/nixos/modules/services/network-filesystems/netatalk.nix @@ -9,7 +9,7 @@ let extmapFile = pkgs.writeText "extmap.conf" cfg.extmap; afpToString = x: if builtins.typeOf x == "bool" - then (if x then "true" else "false") + then boolToString x else toString x; volumeConfig = name: diff --git a/nixos/modules/services/network-filesystems/samba.nix b/nixos/modules/services/network-filesystems/samba.nix index 6ae5292fc30..87c4f7a8ebc 100644 --- a/nixos/modules/services/network-filesystems/samba.nix +++ b/nixos/modules/services/network-filesystems/samba.nix @@ -5,7 +5,7 @@ with lib; let smbToString = x: if builtins.typeOf x == "bool" - then (if x then "true" else "false") + then boolToString x else toString x; cfg = config.services.samba; diff --git a/nixos/modules/services/network-filesystems/tahoe.nix b/nixos/modules/services/network-filesystems/tahoe.nix index 3d78ac096a2..9815a5434ee 100644 --- a/nixos/modules/services/network-filesystems/tahoe.nix +++ b/nixos/modules/services/network-filesystems/tahoe.nix @@ -290,14 +290,14 @@ in shares.total = ${toString settings.client.shares.total} [storage] - enabled = ${if settings.storage.enable then "true" else "false"} + enabled = ${boolToString settings.storage.enable} reserved_space = ${settings.storage.reservedSpace} [helper] - enabled = ${if settings.helper.enable then "true" else "false"} + enabled = ${boolToString settings.helper.enable} [sftpd] - enabled = ${if settings.sftpd.enable then "true" else "false"} + enabled = ${boolToString settings.sftpd.enable} ${optionalString (settings.sftpd.port != null) "port = ${toString settings.sftpd.port}"} ${optionalString (settings.sftpd.hostPublicKeyFile != null) diff --git a/nixos/modules/services/networking/aiccu.nix b/nixos/modules/services/networking/aiccu.nix index aeb0910d624..ac755270951 100644 --- a/nixos/modules/services/networking/aiccu.nix +++ b/nixos/modules/services/networking/aiccu.nix @@ -5,7 +5,6 @@ with lib; let cfg = config.services.aiccu; - showBool = b: if b then "true" else "false"; notNull = a: ! isNull a; configFile = pkgs.writeText "aiccu.conf" '' ${if notNull cfg.username then "username " + cfg.username else ""} @@ -13,16 +12,16 @@ let protocol ${cfg.protocol} server ${cfg.server} ipv6_interface ${cfg.interfaceName} - verbose ${showBool cfg.verbose} + verbose ${boolToString cfg.verbose} daemonize true - automatic ${showBool cfg.automatic} - requiretls ${showBool cfg.requireTLS} + automatic ${boolToString cfg.automatic} + requiretls ${boolToString cfg.requireTLS} pidfile ${cfg.pidFile} - defaultroute ${showBool cfg.defaultRoute} + defaultroute ${boolToString cfg.defaultRoute} ${if notNull cfg.setupScript then cfg.setupScript else ""} - makebeats ${showBool cfg.makeHeartBeats} - noconfigure ${showBool cfg.noConfigure} - behindnat ${showBool cfg.behindNAT} + makebeats ${boolToString cfg.makeHeartBeats} + noconfigure ${boolToString cfg.noConfigure} + behindnat ${boolToString cfg.behindNAT} ${if cfg.localIPv4Override then "local_ipv4_override" else ""} ''; diff --git a/nixos/modules/services/networking/btsync.nix b/nixos/modules/services/networking/btsync.nix index 92e9fa7be41..6e479a5860a 100644 --- a/nixos/modules/services/networking/btsync.nix +++ b/nixos/modules/services/networking/btsync.nix @@ -9,7 +9,6 @@ let listenAddr = cfg.httpListenAddr + ":" + (toString cfg.httpListenPort); - boolStr = x: if x then "true" else "false"; optionalEmptyStr = b: v: optionalString (b != "") v; webUIConfig = optionalString cfg.enableWebUI @@ -31,7 +30,7 @@ let sharedFoldersRecord = concatStringsSep "," (map (entry: let helper = attr: v: - if (entry ? attr) then boolStr entry.attr else boolStr v; + if (entry ? attr) then boolToString entry.attr else boolToString v; in '' { @@ -65,11 +64,11 @@ let "listening_port": ${toString cfg.listeningPort}, "use_gui": false, - "check_for_updates": ${boolStr cfg.checkForUpdates}, - "use_upnp": ${boolStr cfg.useUpnp}, + "check_for_updates": ${boolToString cfg.checkForUpdates}, + "use_upnp": ${boolToString cfg.useUpnp}, "download_limit": ${toString cfg.downloadLimit}, "upload_limit": ${toString cfg.uploadLimit}, - "lan_encrypt_data": ${boolStr cfg.encryptLAN}, + "lan_encrypt_data": ${boolToString cfg.encryptLAN}, ${webUIConfig} ${sharedFoldersConfig} diff --git a/nixos/modules/services/networking/firefox/sync-server.nix b/nixos/modules/services/networking/firefox/sync-server.nix index 5c14ceff6a0..3a95b9c4ec9 100644 --- a/nixos/modules/services/networking/firefox/sync-server.nix +++ b/nixos/modules/services/networking/firefox/sync-server.nix @@ -19,7 +19,7 @@ let [syncserver] public_url = ${cfg.publicUrl} ${optionalString (cfg.sqlUri != "") "sqluri = ${cfg.sqlUri}"} - allow_new_users = ${if cfg.allowNewUsers then "true" else "false"} + allow_new_users = ${boolToString cfg.allowNewUsers} [browserid] backend = tokenserver.verifiers.LocalVerifier diff --git a/nixos/modules/services/networking/i2pd.nix b/nixos/modules/services/networking/i2pd.nix index c5b27350b3c..24a3196bed4 100644 --- a/nixos/modules/services/networking/i2pd.nix +++ b/nixos/modules/services/networking/i2pd.nix @@ -10,8 +10,6 @@ let extip = "EXTIP=\$(${pkgs.curl.bin}/bin/curl -sLf \"http://jsonip.com\" | ${pkgs.gawk}/bin/awk -F'\"' '{print $4}')"; - toYesNo = b: if b then "true" else "false"; - mkEndpointOpt = name: addr: port: { enable = mkEnableOption name; name = mkOption { @@ -76,10 +74,10 @@ let i2pdConf = pkgs.writeText "i2pd.conf" '' - ipv4 = ${toYesNo cfg.enableIPv4} - ipv6 = ${toYesNo cfg.enableIPv6} - notransit = ${toYesNo cfg.notransit} - floodfill = ${toYesNo cfg.floodfill} + ipv4 = ${boolToString cfg.enableIPv4} + ipv6 = ${boolToString cfg.enableIPv6} + notransit = ${boolToString cfg.notransit} + floodfill = ${boolToString cfg.floodfill} netid = ${toString cfg.netid} ${if isNull cfg.bandwidth then "" else "bandwidth = ${toString cfg.bandwidth}" } ${if isNull cfg.port then "" else "port = ${toString cfg.port}"} @@ -88,14 +86,14 @@ let transittunnels = ${toString cfg.limits.transittunnels} [upnp] - enabled = ${toYesNo cfg.upnp.enable} + enabled = ${boolToString cfg.upnp.enable} name = ${cfg.upnp.name} [precomputation] - elgamal = ${toYesNo cfg.precomputation.elgamal} + elgamal = ${boolToString cfg.precomputation.elgamal} [reseed] - verify = ${toYesNo cfg.reseed.verify} + verify = ${boolToString cfg.reseed.verify} file = ${cfg.reseed.file} urls = ${builtins.concatStringsSep "," cfg.reseed.urls} @@ -107,11 +105,11 @@ let (proto: let portStr = toString proto.port; in '' [${proto.name}] - enabled = ${toYesNo proto.enable} + enabled = ${boolToString proto.enable} address = ${proto.address} port = ${toString proto.port} ${if proto ? keys then "keys = ${proto.keys}" else ""} - ${if proto ? auth then "auth = ${toYesNo proto.auth}" else ""} + ${if proto ? auth then "auth = ${boolToString proto.auth}" else ""} ${if proto ? user then "user = ${proto.user}" else ""} ${if proto ? pass then "pass = ${proto.pass}" else ""} ${if proto ? outproxy then "outproxy = ${proto.outproxy}" else ""} diff --git a/nixos/modules/services/networking/ircd-hybrid/default.nix b/nixos/modules/services/networking/ircd-hybrid/default.nix index ede57c5046d..bd583fb020e 100644 --- a/nixos/modules/services/networking/ircd-hybrid/default.nix +++ b/nixos/modules/services/networking/ircd-hybrid/default.nix @@ -12,7 +12,7 @@ let substFiles = [ "=>/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} </Listener> <User ${confOpts.userName}> 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}" |