treewide: replace "yes" else "no" usages to lib.boolToYesNo

This commit is contained in:
Aliaksandr
2025-10-13 21:53:42 +03:00
parent 2de6ce380f
commit 80f12557f5
65 changed files with 118 additions and 140 deletions

View File

@@ -18,7 +18,7 @@ let
[
"# Generated by NixOS module networking.getaddrinfo"
"# Do not edit manually!"
"reload ${if cfg.reload then "yes" else "no"}"
"reload ${lib.boolToYesNo cfg.reload}"
]
++ formatTableEntries "label" cfg.label
++ formatTableEntries "precedence" cfg.precedence

View File

@@ -241,7 +241,7 @@ in
PRUNEFS="${lib.concatStringsSep " " cfg.pruneFS}"
PRUNENAMES="${lib.concatStringsSep " " cfg.pruneNames}"
PRUNEPATHS="${lib.concatStringsSep " " cfg.prunePaths}"
PRUNE_BIND_MOUNTS="${if cfg.pruneBindMounts then "yes" else "no"}"
PRUNE_BIND_MOUNTS="${lib.boolToYesNo cfg.pruneBindMounts}"
'';
systemPackages = [ cfg.package ];
@@ -267,7 +267,7 @@ in
''
exec ${cfg.package}/bin/updatedb \
--output ${toString cfg.output} ${lib.concatStringsSep " " args} \
--prune-bind-mounts ${if cfg.pruneBindMounts then "yes" else "no"} \
--prune-bind-mounts ${lib.boolToYesNo cfg.pruneBindMounts} \
${lib.concatStringsSep " " cfg.extraFlags}
'';
serviceConfig = {

View File

@@ -357,7 +357,7 @@ in
]
++ lib.optional (!config.networking.enableIPv6) "AddressFamily inet"
++ lib.optional cfg.setXAuthLocation "XAuthLocation ${pkgs.xorg.xauth}/bin/xauth"
++ lib.optional (cfg.forwardX11 != null) "ForwardX11 ${if cfg.forwardX11 then "yes" else "no"}"
++ lib.optional (cfg.forwardX11 != null) "ForwardX11 ${lib.boolToYesNo cfg.forwardX11}"
++ lib.optional (
cfg.pubkeyAcceptedKeyTypes != [ ]
) "PubkeyAcceptedKeyTypes ${builtins.concatStringsSep "," cfg.pubkeyAcceptedKeyTypes}"

View File

@@ -86,7 +86,7 @@ let
prepareConfigValue =
v:
if lib.isBool v then
(if v then "yes" else "no")
lib.boolToYesNo v
else if lib.isList v then
lib.concatStringsSep " " (map prepareConfigValue v)
else

View File

@@ -6,8 +6,7 @@
}:
let
cfg = config.security.duosec;
boolToStr = b: if b then "yes" else "no";
inherit (lib) boolToYesNo;
configFilePam = ''
[duo]
@@ -15,15 +14,15 @@ let
host=${cfg.host}
${lib.optionalString (cfg.groups != "") ("groups=" + cfg.groups)}
failmode=${cfg.failmode}
pushinfo=${boolToStr cfg.pushinfo}
autopush=${boolToStr cfg.autopush}
pushinfo=${boolToYesNo cfg.pushinfo}
autopush=${boolToYesNo cfg.autopush}
prompts=${toString cfg.prompts}
fallback_local_ip=${boolToStr cfg.fallbackLocalIP}
fallback_local_ip=${boolToYesNo cfg.fallbackLocalIP}
'';
configFileLogin = configFilePam + ''
motd=${boolToStr cfg.motd}
accept_env_factor=${boolToStr cfg.acceptEnvFactor}
motd=${boolToYesNo cfg.motd}
accept_env_factor=${boolToYesNo cfg.acceptEnvFactor}
'';
in
{

View File

@@ -170,9 +170,7 @@ in
<pam_mount>
<debug enable="${toString cfg.debugLevel}" />
<!-- if activated, requires ofl from hxtools to be present -->
<logout wait="${toString cfg.logoutWait}" hup="${if cfg.logoutHup then "yes" else "no"}" term="${
if cfg.logoutTerm then "yes" else "no"
}" kill="${if cfg.logoutKill then "yes" else "no"}" />
<logout wait="${toString cfg.logoutWait}" hup="${lib.boolToYesNo cfg.logoutHup}" term="${lib.boolToYesNo cfg.logoutTerm}" kill="${lib.boolToYesNo cfg.logoutKill}" />
<!-- set PATH variable for pam_mount module -->
<path>${lib.makeBinPath ([ pkgs.util-linux ] ++ cfg.additionalSearchPaths)}</path>
<!-- create mount point if not present -->

View File

@@ -39,7 +39,7 @@ let
ima_log_file = cfg.fapi.imaLogFile;
}
// lib.optionalAttrs (cfg.fapi.ekCertLess != null) {
ek_cert_less = if cfg.fapi.ekCertLess then "yes" else "no";
ek_cert_less = lib.boolToYesNo cfg.fapi.ekCertLess;
}
// lib.optionalAttrs (cfg.fapi.ekFingerprint != null) { ek_fingerprint = cfg.fapi.ekFingerprint; }
)

View File

@@ -10,6 +10,7 @@
let
inherit (lib)
boolToYesNo
concatStringsSep
literalExpression
mapAttrsToList
@@ -21,16 +22,15 @@ let
;
libDir = "/var/lib/bacula";
yes_no = bool: if bool then "yes" else "no";
tls_conf =
tls_cfg:
optionalString tls_cfg.enable (
concatStringsSep "\n" (
[ "TLS Enable = yes;" ]
++ optional (tls_cfg.require != null) "TLS Require = ${yes_no tls_cfg.require};"
++ optional (tls_cfg.require != null) "TLS Require = ${boolToYesNo tls_cfg.require};"
++ optional (tls_cfg.certificate != null) ''TLS Certificate = "${tls_cfg.certificate}";''
++ [ ''TLS Key = "${tls_cfg.key}";'' ]
++ optional (tls_cfg.verifyPeer != null) "TLS Verify Peer = ${yes_no tls_cfg.verifyPeer};"
++ optional (tls_cfg.verifyPeer != null) "TLS Verify Peer = ${boolToYesNo tls_cfg.verifyPeer};"
++ optional (
tls_cfg.allowedCN != [ ]
) "TLS Allowed CN = ${concatStringsSep " " (tls_cfg.allowedCN)};"

View File

@@ -504,7 +504,7 @@ in
MAX_HEAP_SIZE = toString cfg.maxHeapSize;
HEAP_NEWSIZE = toString cfg.heapNewSize;
MALLOC_ARENA_MAX = toString cfg.mallocArenaMax;
LOCAL_JMX = if cfg.remoteJmx then "no" else "yes";
LOCAL_JMX = lib.boolToYesNo (!cfg.remoteJmx);
JMX_PORT = toString cfg.jmxPort;
};
wantedBy = [ "multi-user.target" ];

View File

@@ -15,6 +15,7 @@ let
optionalString
generators
mapAttrsToList
boolToYesNo
;
inherit (lib.strings) concatStringsSep;
inherit (lib.types)
@@ -63,7 +64,7 @@ let
mkValueString =
v:
if builtins.isBool v then
if v then "yes" else "no"
boolToYesNo v
else if builtins.isList v then
concatStringsSep " " v
else

View File

@@ -211,9 +211,7 @@ let
''
worker "${value.type}" {
type = "${value.type}";
${optionalString (value.enable != null)
"enabled = ${if value.enable != false then "yes" else "no"};"
}
${optionalString (value.enable != null) "enabled = ${lib.boolToYesNo (value.enable != false)};"}
${mkBindSockets value.enable value.bindSockets}
${optionalString (value.count != null) "count = ${toString value.count};"}
${concatStringsSep "\n " (map (each: ".include \"${each}\"") value.includes)}

View File

@@ -11,7 +11,7 @@ let
[gammu]
Device = ${cfg.device.path}
Connection = ${cfg.device.connection}
SynchronizeTime = ${if cfg.device.synchronizeTime then "yes" else "no"}
SynchronizeTime = ${lib.boolToYesNo cfg.device.synchronizeTime}
LogFormat = ${cfg.log.format}
${lib.optionalString (cfg.device.pin != null) "PIN = ${cfg.device.pin}"}
${cfg.extraConfig.gammu}

View File

@@ -12,7 +12,6 @@ let
opt = options.services.mediatomb;
name = cfg.package.pname;
pkg = cfg.package;
optionYesNo = option: if option then "yes" else "no";
# configuration on media directory
mediaDirectory = {
options = {
@@ -36,7 +35,7 @@ let
};
toMediaDirectory =
d:
"<directory location=\"${d.path}\" mode=\"inotify\" recursive=\"${optionYesNo d.recursive}\" hidden-files=\"${optionYesNo d.hidden-files}\" />\n";
"<directory location=\"${d.path}\" mode=\"inotify\" recursive=\"${lib.boolToYesNo d.recursive}\" hidden-files=\"${lib.boolToYesNo d.hidden-files}\" />\n";
transcodingConfig =
if cfg.transcoding then
@@ -89,13 +88,13 @@ let
<home>${cfg.dataDir}</home>
<interface>${cfg.interface}</interface>
<webroot>${pkg}/share/${name}/web</webroot>
<pc-directory upnp-hide="${optionYesNo cfg.pcDirectoryHide}"/>
<pc-directory upnp-hide="${lib.boolToYesNo cfg.pcDirectoryHide}"/>
<storage>
<sqlite3 enabled="yes">
<database-file>${name}.db</database-file>
</sqlite3>
</storage>
<protocolInfo extend="${optionYesNo cfg.ps3Support}"/>
<protocolInfo extend="${lib.boolToYesNo cfg.ps3Support}"/>
${lib.optionalString cfg.dsmSupport ''
<custom-http-headers>
<add header="X-User-Agent: redsonic"/>

View File

@@ -50,8 +50,8 @@ let
</DataHandleRanges>
<StorageHints>
TroveSyncMeta ${if fs.troveSyncMeta then "yes" else "no"}
TroveSyncData ${if fs.troveSyncData then "yes" else "no"}
TroveSyncMeta ${lib.boolToYesNo fs.troveSyncMeta}
TroveSyncData ${lib.boolToYesNo fs.troveSyncData}
${fs.extraStorageHints}
</StorageHints>

View File

@@ -7,8 +7,6 @@
let
cfg = config.services.avahi;
yesNo = yes: if yes then "yes" else "no";
avahiDaemonConf =
with cfg;
pkgs.writeText "avahi-daemon.conf" ''
@@ -21,8 +19,8 @@ let
lib.optionalString (hostName != "") "host-name=${hostName}"
}
browse-domains=${lib.concatStringsSep ", " browseDomains}
use-ipv4=${yesNo ipv4}
use-ipv6=${yesNo ipv6}
use-ipv4=${lib.boolToYesNo ipv4}
use-ipv6=${lib.boolToYesNo ipv6}
${lib.optionalString (
allowInterfaces != null
) "allow-interfaces=${lib.concatStringsSep "," allowInterfaces}"}
@@ -30,22 +28,22 @@ let
denyInterfaces != null
) "deny-interfaces=${lib.concatStringsSep "," denyInterfaces}"}
${lib.optionalString (domainName != null) "domain-name=${domainName}"}
allow-point-to-point=${yesNo allowPointToPoint}
allow-point-to-point=${lib.boolToYesNo allowPointToPoint}
${lib.optionalString (cacheEntriesMax != null) "cache-entries-max=${toString cacheEntriesMax}"}
[wide-area]
enable-wide-area=${yesNo wideArea}
enable-wide-area=${lib.boolToYesNo wideArea}
[publish]
disable-publishing=${yesNo (!publish.enable)}
disable-user-service-publishing=${yesNo (!publish.userServices)}
publish-addresses=${yesNo (publish.userServices || publish.addresses)}
publish-hinfo=${yesNo publish.hinfo}
publish-workstation=${yesNo publish.workstation}
publish-domain=${yesNo publish.domain}
disable-publishing=${lib.boolToYesNo (!publish.enable)}
disable-user-service-publishing=${lib.boolToYesNo (!publish.userServices)}
publish-addresses=${lib.boolToYesNo (publish.userServices || publish.addresses)}
publish-hinfo=${lib.boolToYesNo publish.hinfo}
publish-workstation=${lib.boolToYesNo publish.workstation}
publish-domain=${lib.boolToYesNo publish.domain}
[reflector]
enable-reflector=${yesNo reflector}
enable-reflector=${lib.boolToYesNo reflector}
${extraConfig}
'';
in

View File

@@ -6,7 +6,6 @@
}:
let
cfg = config.services.ddclient;
boolToStr = bool: if bool then "yes" else "no";
dataDir = "/var/lib/ddclient";
StateDirectory = builtins.baseNameOf dataDir;
RuntimeDirectory = StateDirectory;
@@ -33,10 +32,10 @@ let
${lib.optionalString (cfg.script != "") "script=${cfg.script}"}
${lib.optionalString (cfg.server != "") "server=${cfg.server}"}
${lib.optionalString (cfg.zone != "") "zone=${cfg.zone}"}
ssl=${boolToStr cfg.ssl}
ssl=${lib.boolToYesNo cfg.ssl}
wildcard=YES
quiet=${boolToStr cfg.quiet}
verbose=${boolToStr cfg.verbose}
quiet=${lib.boolToYesNo cfg.quiet}
verbose=${lib.boolToYesNo cfg.verbose}
${cfg.extraConfig}
${lib.concatStringsSep "," cfg.domains}
'';

View File

@@ -82,7 +82,7 @@ let
isEnabled = service: cfg.${service}.enable;
daemonLine = d: "${d}=${if isEnabled d then "yes" else "no"}";
daemonLine = d: "${d}=${lib.boolToYesNo (isEnabled d)}";
configFile =
if cfg.configFile != null then

View File

@@ -11,8 +11,8 @@ let
cfg = config.services.miniupnpd;
configFile = pkgs.writeText "miniupnpd.conf" ''
ext_ifname=${cfg.externalInterface}
enable_natpmp=${if cfg.natpmp then "yes" else "no"}
enable_upnp=${if cfg.upnp then "yes" else "no"}
enable_natpmp=${boolToYesNo cfg.natpmp}
enable_upnp=${boolToYesNo cfg.upnp}
${concatMapStrings (range: ''
listening_ip=${range}

View File

@@ -100,19 +100,19 @@ let
# interfaces
${forEach " ip-address: " cfg.interfaces}
ip-freebind: ${yesOrNo cfg.ipFreebind}
hide-version: ${yesOrNo cfg.hideVersion}
ip-freebind: ${boolToYesNo cfg.ipFreebind}
hide-version: ${boolToYesNo cfg.hideVersion}
identity: "${cfg.identity}"
ip-transparent: ${yesOrNo cfg.ipTransparent}
do-ip4: ${yesOrNo cfg.ipv4}
ip-transparent: ${boolToYesNo cfg.ipTransparent}
do-ip4: ${boolToYesNo cfg.ipv4}
ipv4-edns-size: ${toString cfg.ipv4EDNSSize}
do-ip6: ${yesOrNo cfg.ipv6}
do-ip6: ${boolToYesNo cfg.ipv6}
ipv6-edns-size: ${toString cfg.ipv6EDNSSize}
log-time-ascii: ${yesOrNo cfg.logTimeAscii}
log-time-ascii: ${boolToYesNo cfg.logTimeAscii}
${maybeString "nsid: " cfg.nsid}
port: ${toString cfg.port}
reuseport: ${yesOrNo cfg.reuseport}
round-robin: ${yesOrNo cfg.roundRobin}
reuseport: ${boolToYesNo cfg.reuseport}
round-robin: ${boolToYesNo cfg.roundRobin}
server-count: ${toString cfg.serverCount}
${maybeToString "statistics: " cfg.statistics}
tcp-count: ${toString cfg.tcpCount}
@@ -121,7 +121,7 @@ let
verbosity: ${toString cfg.verbosity}
${maybeString "version: " cfg.version}
xfrd-reload-timeout: ${toString cfg.xfrdReloadTimeout}
zonefiles-check: ${yesOrNo cfg.zonefilesCheck}
zonefiles-check: ${boolToYesNo cfg.zonefilesCheck}
zonefiles-write: ${toString cfg.zonefilesWrite}
${maybeString "rrl-ipv4-prefix-length: " cfg.ratelimit.ipv4PrefixLength}
@@ -134,7 +134,7 @@ let
${keyConfigFile}
remote-control:
control-enable: ${yesOrNo cfg.remoteControl.enable}
control-enable: ${boolToYesNo cfg.remoteControl.enable}
control-key-file: "${cfg.remoteControl.controlKeyFile}"
control-cert-file: "${cfg.remoteControl.controlCertFile}"
${forEach " control-interface: " cfg.remoteControl.interfaces}
@@ -147,7 +147,6 @@ let
${cfg.extraConfig}
'';
yesOrNo = b: if b then "yes" else "no";
maybeString = prefix: x: optionalString (x != null) ''${prefix} "${x}"'';
maybeToString = prefix: x: optionalString (x != null) ''${prefix} ${toString x}'';
forEach = pre: l: concatMapStrings (x: pre + x + "\n") l;
@@ -183,8 +182,8 @@ let
${maybeToString "max-retry-time: " zone.maxRetrySecs}
${maybeToString "min-retry-time: " zone.minRetrySecs}
allow-axfr-fallback: ${yesOrNo zone.allowAXFRFallback}
multi-master-check: ${yesOrNo zone.multiMasterCheck}
allow-axfr-fallback: ${boolToYesNo zone.allowAXFRFallback}
multi-master-check: ${boolToYesNo zone.multiMasterCheck}
${forEach " allow-notify: " zone.allowNotify}
${forEach " request-xfr: " zone.requestXFR}

View File

@@ -21,7 +21,6 @@ let
];
configType = with types; attrsOf (nullOr (oneOrMore valueType));
toBool = val: if val then "yes" else "no";
serialize =
val:
with types;
@@ -32,7 +31,7 @@ let
else if path.check val then
toString val
else if bool.check val then
toBool val
boolToYesNo val
else if builtins.isList val then
(concatMapStringsSep "," serialize val)
else

View File

@@ -23,7 +23,7 @@ let
with generators;
toKeyValue {
mkKeyValue = mkKeyValueDefault {
mkValueString = v: if isBool v then if v then "yes" else "no" else mkValueStringDefault { } v;
mkValueString = v: if isBool v then boolToYesNo v else mkValueStringDefault { } v;
} " ";
listsAsDuplicateKeys = true; # Allowing duplications because we need to deal with multiple entries with the same key.
} cfg.settings

View File

@@ -484,7 +484,6 @@ in
};
UseDns = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
# apply if cfg.useDns then "yes" else "no"
default = false;
description = ''
Specifies whether {manpage}`sshd(8)` should look up the remote host name, and to check that the resolved host name for

View File

@@ -97,7 +97,7 @@ rec {
default = null;
description = documentDefault description strongswanDefault;
};
render = single (b: if b then "yes" else "no");
render = single boolToYesNo;
};
yes = true;
no = false;

View File

@@ -7,7 +7,6 @@
let
cfg = config.services.stunnel;
yesNo = val: if val then "yes" else "no";
verifyRequiredField = type: field: n: c: {
assertion = lib.hasAttr field c;
@@ -23,13 +22,7 @@ let
removeNulls = lib.mapAttrs (_: lib.filterAttrs (_: v: v != null));
mkValueString =
v:
if v == true then
"yes"
else if v == false then
"no"
else
lib.generators.mkValueStringDefault { } v;
v: if lib.isBool v then lib.boolToYesNo v else lib.generators.mkValueStringDefault { } v;
generateConfig =
c:
lib.generators.toINI {

View File

@@ -28,7 +28,7 @@ let
log ${concatStringsSep " " cfg.log}
''}
wkpf-strict ${if cfg.wkpfStrict then "yes" else "no"}
wkpf-strict ${boolToYesNo cfg.wkpfStrict}
'';
addrOpts =

View File

@@ -9,8 +9,6 @@ with lib;
let
cfg = config.services.unbound;
yesOrNo = v: if v then "yes" else "no";
toOption =
indent: n: v:
"${indent}${toString n}: ${v}";
@@ -22,7 +20,7 @@ let
else if isInt v then
(toOption indent n (toString v))
else if isBool v then
(toOption indent n (yesOrNo v))
(toOption indent n (lib.boolToYesNo v))
else if isString v then
(toOption indent n v)
else if isList v then

View File

@@ -31,7 +31,7 @@ let
${optionalString (srv.flags != "") "flags = ${srv.flags}"}
socket_type = ${if srv.protocol == "udp" then "dgram" else "stream"}
${optionalString (srv.port != 0) "port = ${toString srv.port}"}
wait = ${if srv.protocol == "udp" then "yes" else "no"}
wait = ${lib.boolToYesNo (srv.protocol == "udp")}
user = ${srv.user}
server = ${srv.server}
${optionalString (srv.serverArgs != "") "server_args = ${srv.serverArgs}"}

View File

@@ -18,7 +18,7 @@ let
interfaceRoutes = i: i.ipv4.routes ++ optionals cfg.enableIPv6 i.ipv6.routes;
dhcpStr = useDHCP: if useDHCP == true || useDHCP == null then "yes" else "no";
dhcpStr = useDHCP: boolToYesNo (useDHCP == true || useDHCP == null);
slaves =
concatLists (map (bond: bond.interfaces) (attrValues cfg.bonds))

View File

@@ -70,12 +70,12 @@ let
++ lib.optionals (pname == "gammastep") [ wayland-scanner ];
configureFlags = [
"--enable-randr=${if withRandr then "yes" else "no"}"
"--enable-geoclue2=${if withGeoclue then "yes" else "no"}"
"--enable-drm=${if withDrm then "yes" else "no"}"
"--enable-vidmode=${if withVidmode then "yes" else "no"}"
"--enable-quartz=${if withQuartz then "yes" else "no"}"
"--enable-corelocation=${if withCoreLocation then "yes" else "no"}"
"--enable-randr=${lib.boolToYesNo withRandr}"
"--enable-geoclue2=${lib.boolToYesNo withGeoclue}"
"--enable-drm=${lib.boolToYesNo withDrm}"
"--enable-vidmode=${lib.boolToYesNo withVidmode}"
"--enable-quartz=${lib.boolToYesNo withQuartz}"
"--enable-corelocation=${lib.boolToYesNo withCoreLocation}"
]
++ lib.optionals (pname == "gammastep") [
"--with-systemduserunitdir=${placeholder "out"}/lib/systemd/user/"

View File

@@ -69,7 +69,7 @@ vmTools.runInLinuxImage (
# the log file
export PAGER=cat
${checkinstall}/sbin/checkinstall --nodoc -y -D \
--fstrans=${if fsTranslation then "yes" else "no"} \
--fstrans=${lib.boolToYesNo fsTranslation} \
--requires="${lib.concatStringsSep "," debRequires}" \
--provides="${lib.concatStringsSep "," debProvides}" \
${

View File

@@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
# These answers are valid on x86_64-linux and aarch64-linux.
# TODO: provide all valid answers for BSD.
"ac_cv_file__dev_zero=yes"
"ac_cv_func_setpgrp_void=${if stdenv.hostPlatform.isBSD then "no" else "yes"}"
"ac_cv_func_setpgrp_void=${lib.boolToYesNo (!stdenv.hostPlatform.isBSD)}"
"apr_cv_tcp_nodelay_with_cork=yes"
"ac_cv_define_PTHREAD_PROCESS_SHARED=yes"
"apr_cv_process_shared_works=yes"

View File

@@ -50,7 +50,7 @@ stdenv.mkDerivation rec {
]
++
lib.optional (stdenv.buildPlatform != stdenv.hostPlatform)
"ac_cv_func_setpgrp_void=${if stdenv.hostPlatform.isBSD then "no" else "yes"}"
"ac_cv_func_setpgrp_void=${lib.boolToYesNo (!stdenv.hostPlatform.isBSD)}"
++ lib.optionals stdenv.hostPlatform.isDarwin [
# baculas `configure` script fails to detect CoreFoundation correctly,
# but these symbols are available in the nixpkgs CoreFoundation framework.

View File

@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ autoreconfHook ];
configureFlags = [
"--enable-openmp=${if stdenv.hostPlatform.isLinux then "yes" else "no"}"
"--enable-openmp=${lib.boolToYesNo stdenv.hostPlatform.isLinux}"
"--enable-examples=no"
];

View File

@@ -155,9 +155,9 @@ stdenv.mkDerivation rec {
"--with-textcat"
]
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"i_cv_epoll_works=${if stdenv.hostPlatform.isLinux then "yes" else "no"}"
"i_cv_posix_fallocate_works=${if stdenv.hostPlatform.isDarwin then "no" else "yes"}"
"i_cv_inotify_works=${if stdenv.hostPlatform.isLinux then "yes" else "no"}"
"i_cv_epoll_works=${lib.boolToYesNo stdenv.hostPlatform.isLinux}"
"i_cv_posix_fallocate_works=${lib.boolToYesNo stdenv.hostPlatform.isDarwin}"
"i_cv_inotify_works=${lib.boolToYesNo stdenv.hostPlatform.isLinux}"
"i_cv_signed_size_t=no"
"i_cv_signed_time_t=yes"
"i_cv_c99_vsnprintf=yes"

View File

@@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
];
makeFlags = [
"USE_UPNP=${if upnpSupport then "yes" else "no"}"
"USE_UPNP=${lib.boolToYesNo upnpSupport}"
];
enableParallelBuilding = true;

View File

@@ -56,7 +56,7 @@ stdenv.mkDerivation rec {
makeFlags = [
"lib=lib"
"PAM_CAP=${if usePam then "yes" else "no"}"
"PAM_CAP=${lib.boolToYesNo usePam}"
"BUILD_CC=$(CC_FOR_BUILD)"
"CC:=$(CC)"
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"

View File

@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
]
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
# Can't run this test while cross-compiling
"ac_cv_func_setpgrp_void=${if stdenv.hostPlatform.isBSD then "no" else "yes"}"
"ac_cv_func_setpgrp_void=${lib.boolToYesNo (!stdenv.hostPlatform.isBSD)}"
];
meta = {

View File

@@ -63,8 +63,8 @@ stdenv.mkDerivation (finalAttrs: {
];
mesonFlags = [
"-Degl=${if (x11Support && !stdenv.hostPlatform.isDarwin) then "yes" else "no"}"
"-Dglx=${if x11Support then "yes" else "no"}"
"-Degl=${lib.boolToYesNo (x11Support && !stdenv.hostPlatform.isDarwin)}"
"-Dglx=${lib.boolToYesNo x11Support}"
"-Dtests=${lib.boolToString finalAttrs.finalPackage.doCheck}"
"-Dx11=${lib.boolToString x11Support}"
];

View File

@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
];
configureFlags = [
"--enable-tools=${if enable-tools then "yes" else "no"}"
"--enable-tools=${lib.boolToYesNo enable-tools}"
"--enable-bindings-cxx"
];

View File

@@ -41,7 +41,7 @@ stdenv.mkDerivation rec {
];
configureFlags = [
"--enable-tools=${if enable-tools then "yes" else "no"}"
"--enable-tools=${lib.boolToYesNo enable-tools}"
"--enable-bindings-cxx"
"--prefix=${placeholder "out"}"
]

View File

@@ -147,7 +147,7 @@ stdenv.mkDerivation {
# Misc
(lib.withFeature curlSupport "curl")
(lib.withFeature samplerateSupport "samplerate")
("--enable-debug=" + (if withDebug then "yes" else "no"))
"--enable-debug=${lib.boolToYesNo withDebug}"
"--disable-cache"
"--without-rcc"
];

View File

@@ -119,7 +119,7 @@ stdenv.mkDerivation rec {
# provide correct configure answers for cross builds
configureFlags = [
"ac_cv_func_setpgrp_void=${if stdenv.hostPlatform.isBSD then "no" else "yes"}"
"ac_cv_func_setpgrp_void=${lib.boolToYesNo (!stdenv.hostPlatform.isBSD)}"
];
env = lib.optionalAttrs stdenv.cc.isClang {

View File

@@ -282,7 +282,7 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
env.USE_SONAME = if (stdenv.hostPlatform.isDarwin) then "no" else "yes";
env.USE_SONAME = lib.boolToYesNo (!stdenv.hostPlatform.isDarwin);
passthru = {
tests = {

View File

@@ -63,8 +63,8 @@ stdenv.mkDerivation rec {
];
configureFlags = [
"--with-gnome=${if withGnome then "yes" else "no"}"
"--with-gtk4=${if withGnome then "yes" else "no"}"
"--with-gnome=${lib.boolToYesNo withGnome}"
"--with-gtk4=${lib.boolToYesNo withGnome}"
"--localstatedir=/var"
"--enable-absolute-paths"
];

View File

@@ -53,7 +53,7 @@ stdenv.mkDerivation {
];
configureFlags = [
"--with-gnome=${if withGnome then "yes" else "no"}"
"--with-gnome=${lib.boolToYesNo withGnome}"
"--localstatedir=/" # needed for the management socket under /run/NetworkManager
"--enable-absolute-paths"
];

View File

@@ -62,8 +62,8 @@ stdenv.mkDerivation rec {
];
configureFlags = [
"--with-gnome=${if withGnome then "yes" else "no"}"
"--with-gtk4=${if withGnome then "yes" else "no"}"
"--with-gnome=${lib.boolToYesNo withGnome}"
"--with-gtk4=${lib.boolToYesNo withGnome}"
"--localstatedir=/var"
"--enable-absolute-paths"
];

View File

@@ -60,8 +60,8 @@ stdenv.mkDerivation rec {
];
configureFlags = [
"--with-gnome=${if withGnome then "yes" else "no"}"
"--with-gtk4=${if withGnome then "yes" else "no"}"
"--with-gnome=${lib.boolToYesNo withGnome}"
"--with-gtk4=${lib.boolToYesNo withGnome}"
"--enable-absolute-paths"
];

View File

@@ -56,8 +56,8 @@ stdenv.mkDerivation (finalAttrs: {
];
configureFlags = [
"--with-gnome=${if withGnome then "yes" else "no"}"
"--with-gtk4=${if withGnome then "yes" else "no"}"
"--with-gnome=${lib.boolToYesNo withGnome}"
"--with-gtk4=${lib.boolToYesNo withGnome}"
"--localstatedir=/" # needed for the management socket under /run/NetworkManager
"--enable-absolute-paths"
];

View File

@@ -59,8 +59,8 @@ stdenv.mkDerivation rec {
'';
configureFlags = [
"--with-gnome=${if withGnome then "yes" else "no"}"
"--with-gtk4=${if withGnome then "yes" else "no"}"
"--with-gnome=${lib.boolToYesNo withGnome}"
"--with-gtk4=${lib.boolToYesNo withGnome}"
"--with-pppd-plugin-dir=$(out)/lib/pppd/2.5.0"
"--enable-absolute-paths"
];

View File

@@ -52,8 +52,8 @@ stdenv.mkDerivation rec {
];
configureFlags = [
"--with-gnome=${if withGnome then "yes" else "no"}"
"--with-gtk4=${if withGnome then "yes" else "no"}"
"--with-gnome=${lib.boolToYesNo withGnome}"
"--with-gtk4=${lib.boolToYesNo withGnome}"
"--enable-absolute-paths"
];

View File

@@ -58,7 +58,7 @@ stdenv.mkDerivation (finalAttrs: {
substituteInPlace configure \
--replace-fail \
ompi_cv_op_avx_check_${option}=yes \
ompi_cv_op_avx_check_${option}=${if val then "yes" else "no"}
ompi_cv_op_avx_check_${option}=${lib.boolToYesNo val}
''
))
(lib.concatStringsSep "\n")

View File

@@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
makeFlags = [
"SHARED=${if static then "no" else "yes"}"
"SHARED=${lib.boolToYesNo (!static)}"
"PREFIX=\${out}"
"STRIP="
"HOST=${stdenv.hostPlatform.system}"

View File

@@ -86,7 +86,7 @@ stdenv.mkDerivation rec {
# `AC_FUNC_SETPGRP' is not cross-compilation capable.
preConfigure = ''
export ac_cv_func_setpgrp_void=${if stdenv.hostPlatform.isBSD then "no" else "yes"}
export ac_cv_func_setpgrp_void=${lib.boolToYesNo (!stdenv.hostPlatform.isBSD)}
export shadow_cv_logdir=/var/log
'';

View File

@@ -87,7 +87,7 @@ chosenStdenv.mkDerivation (finalAttrs: {
(lib.enableFeature finalAttrs.doCheck "integration")
# Strangely, it uses --with-fapi=yes|no instead of a normal configure flag.
"--with-fapi=${if fapiSupport then "yes" else "no"}"
"--with-fapi=${lib.boolToYesNo fapiSupport}"
]
++ lib.optionals enableFuzzing [
"--enable-fuzzing"

View File

@@ -110,7 +110,7 @@ stdenv.mkDerivation (finalAttrs: {
"CFLAGS=-std=gnu17"
]
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
"ac_cv_func_setpgrp_void=${if stdenv.hostPlatform.isBSD then "no" else "yes"}"
"ac_cv_func_setpgrp_void=${lib.boolToYesNo (!stdenv.hostPlatform.isBSD)}"
]
++ lib.optional graphicsSupport "--enable-image=${lib.optionalString x11Support "x11,"}fb"
++ lib.optional (graphicsSupport && !x11Support) "--without-x";

View File

@@ -63,8 +63,8 @@ stdenv.mkDerivation rec {
"PROCESSORS=$(NIX_BUILD_CORES)"
# confusingly, for gprbuild --target is autoconf --host
"TARGET=${stdenv.hostPlatform.config}"
"GNATCOLL_MINIMAL_ONLY=${if !enableGnatcollCore then "yes" else "no"}"
"GNATCOLL_PROJECTS=${if enableGnatcollProjects then "yes" else "no"}"
"GNATCOLL_MINIMAL_ONLY=${lib.boolToYesNo (!enableGnatcollCore)}"
"GNATCOLL_PROJECTS=${lib.boolToYesNo enableGnatcollProjects}"
];
passthru.tests = {

View File

@@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
makeFlags = [
"prefix=$(out)"
"PROCESSORS=$(NIX_BUILD_CORES)"
"ENABLE_SHARED=${if enableShared then "yes" else "no"}"
"ENABLE_SHARED=${lib.boolToYesNo enableShared}"
"GPR2_BUILD=release"
]
++ lib.optionals (gpr2kbdir != null) [

View File

@@ -31,7 +31,7 @@ stdenv.mkDerivation {
];
makeFlags = [
"ENABLE_SHARED=${if stdenv.hostPlatform.isStatic then "no" else "yes"}"
"ENABLE_SHARED=${lib.boolToYesNo (!stdenv.hostPlatform.isStatic)}"
"PROCESSORS=$(NIX_BUILD_CORES)"
# confusingly, for gprbuild --target is autoconf --host
"TARGET=${stdenv.hostPlatform.config}"

View File

@@ -516,8 +516,8 @@ stdenv.mkDerivation (finalAttrs: {
"ac_cv_have_size_t_format=yes"
"ac_cv_computed_gotos=yes"
# Both fail when building for windows, normally configure checks this by itself but on other platforms this is set to yes always.
"ac_cv_file__dev_ptmx=${if stdenv.hostPlatform.isWindows then "no" else "yes"}"
"ac_cv_file__dev_ptc=${if stdenv.hostPlatform.isWindows then "no" else "yes"}"
"ac_cv_file__dev_ptmx=${lib.boolToYesNo (!stdenv.hostPlatform.isWindows)}"
"ac_cv_file__dev_ptc=${lib.boolToYesNo (!stdenv.hostPlatform.isWindows)}"
]
++ optionals (stdenv.hostPlatform != stdenv.buildPlatform && pythonAtLeast "3.11") [
"--with-build-python=${pythonOnBuildForHostInterpreter}"

View File

@@ -78,15 +78,15 @@ stdenv.mkDerivation rec {
];
configureFlags = [
"--with-mysql=${if mysqlSupport then "yes" else "no"}"
"--with-postgres=${if postgresSupport then "yes" else "no"}"
"--with-mysql=${lib.boolToYesNo mysqlSupport}"
"--with-postgres=${lib.boolToYesNo postgresSupport}"
# macOS builds use the sqlite source code that comes with libgda,
# as opposed to using the system or brewed sqlite3, which is not supported on macOS,
# as mentioned in https://github.com/GNOME/libgda/blob/95eeca4b0470f347c645a27f714c62aa6e59f820/libgda/sqlite/README#L31,
# which references the paper https://web.archive.org/web/20100610151539/http://lattice.umiacs.umd.edu/files/functions_tr.pdf
# See also https://github.com/Homebrew/homebrew-core/blob/104f9ecd02854a82372b64d63d41356555378a52/Formula/libgda.rb
"--enable-system-sqlite=${if stdenv.hostPlatform.isDarwin then "no" else "yes"}"
"--enable-system-sqlite=${lib.boolToYesNo (!stdenv.hostPlatform.isDarwin)}"
];
env.NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types";

View File

@@ -26,7 +26,7 @@ stdenv.mkDerivation (finalAttrs: {
makeFlags = [
"PREFIX=$(out)"
"STATIC=${if isStatic then "yes" else "no"}"
"STATIC=${lib.boolToYesNo isStatic}"
];
doCheck = true;

View File

@@ -14,8 +14,6 @@
}:
let
mkFlag = b: if b then "yes" else "no";
games = import ./games.nix { inherit stdenv lib fetchFromGitHub; };
wrapper = import ./wrapper.nix {
@@ -58,7 +56,7 @@ let
++ lib.optional openalSupport openal;
makeFlags = [
"WITH_OPENAL=${mkFlag openalSupport}"
"WITH_OPENAL=${lib.boolToYesNo openalSupport}"
"WITH_SYSTEMWIDE=yes"
"WITH_SYSTEMDIR=$\{out}/share/games/quake2"
];

View File

@@ -70,7 +70,7 @@ let
// (lib.flip lib.mapAttrs' extraFlags (
name: value: {
name = "MK_${lib.toUpper name}";
value = if value then "yes" else "no";
value = lib.boolToYesNo value;
}
));
in

View File

@@ -103,7 +103,7 @@ lib.warnIf (withDocs != null)
# default is fine for static linking on Linux (weak symbols?) but
# not with BSDs, when it does clash with the regular `getenv`.
"bash_cv_getenv_redef=${
if !(with stdenv.hostPlatform; isStatic && (isOpenBSD || isFreeBSD)) then "yes" else "no"
lib.boolToYesNo (!(with stdenv.hostPlatform; isStatic && (isOpenBSD || isFreeBSD)))
}"
]
++ lib.optionals stdenv.hostPlatform.isCygwin [

View File

@@ -23,7 +23,7 @@ stdenv.mkDerivation {
]
++ (lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ])
);
is_darwin = if stdenv.hostPlatform.isDarwin then "yes" else "no";
is_darwin = lib.boolToYesNo stdenv.hostPlatform.isDarwin;
sandboxtest = ./sandbox.nix;
relaxedsandboxtest = ./relaxedsandbox.nix;