Get rid of the last uses of mkAlways
mkAlways is an insane function, mkMerge is much saner.
This commit is contained in:
parent
9eb81d2578
commit
7435db4f89
|
@ -150,7 +150,7 @@ $ nixos-rebuild switch -I <replaceable>/my/sources</replaceable>
|
||||||
definitions. This conditional values can be distinguished in two
|
definitions. This conditional values can be distinguished in two
|
||||||
categories. The condition which are local to the current configuration
|
categories. The condition which are local to the current configuration
|
||||||
and conditions which are dependent on others configurations. Local
|
and conditions which are dependent on others configurations. Local
|
||||||
properties are <varname>mkIf</varname>, <varname>mkAlways</varname>
|
properties are <varname>mkIf</varname>
|
||||||
and <varname>mkAssert</varname>. Global properties
|
and <varname>mkAssert</varname>. Global properties
|
||||||
are <varname>mkOverride</varname>, <varname>mkDefault</varname>
|
are <varname>mkOverride</varname>, <varname>mkDefault</varname>
|
||||||
and <varname>mkOrder</varname>.</para>
|
and <varname>mkOrder</varname>.</para>
|
||||||
|
@ -158,12 +158,7 @@ $ nixos-rebuild switch -I <replaceable>/my/sources</replaceable>
|
||||||
<para><varname>mkIf</varname> is used to remove the option definitions which
|
<para><varname>mkIf</varname> is used to remove the option definitions which
|
||||||
are below it if the condition is evaluated to
|
are below it if the condition is evaluated to
|
||||||
false. <varname>mkAssert</varname> expects the condition to be evaluated
|
false. <varname>mkAssert</varname> expects the condition to be evaluated
|
||||||
to true otherwise it raises an error message. <varname>mkAlways</varname>
|
to true otherwise it raises an error message.</para>
|
||||||
is used to ignore all the <varname>mkIf</varname>
|
|
||||||
and <varname>mkAssert</varname> which have been made
|
|
||||||
previously. <varname>mkAlways</varname> and <varname>mkAssert</varname>
|
|
||||||
are often used together to set an option value and to ensure that it has
|
|
||||||
not been masked by another one.</para>
|
|
||||||
|
|
||||||
<para><varname>mkOverride</varname> is used to mask previous definitions if
|
<para><varname>mkOverride</varname> is used to mask previous definitions if
|
||||||
the current value has a lower mask number. The mask value is 100 (default)
|
the current value has a lower mask number. The mask value is 100 (default)
|
||||||
|
@ -223,14 +218,6 @@ let
|
||||||
locatedb = "/var/cache/locatedb";
|
locatedb = "/var/cache/locatedb";
|
||||||
logfile = "/var/log/updatedb";
|
logfile = "/var/log/updatedb";
|
||||||
cmd =''root updatedb --localuser=nobody --output=${locatedb} > ${logfile}'';
|
cmd =''root updatedb --localuser=nobody --output=${locatedb} > ${logfile}'';
|
||||||
|
|
||||||
mkCheck = x:
|
|
||||||
mkIf cfg.enable (
|
|
||||||
mkAssert config.services.cron.enable ''
|
|
||||||
The cron daemon is not enabled, required by services.locate.enable.
|
|
||||||
''
|
|
||||||
x
|
|
||||||
)
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -260,9 +247,9 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkCheck {
|
config = mkIf cfg.enable {
|
||||||
services.cron = {
|
services.cron = {
|
||||||
enable = mkAlways cfg.enable;
|
enable = true;
|
||||||
systemCronJobs = "${cfg.period} root ${cmd}";
|
systemCronJobs = "${cfg.period} root ${cmd}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,15 +28,11 @@ let cfg = config.hardware.pulseaudio; in
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkMerge
|
||||||
|
|
||||||
environment.systemPackages =
|
|
||||||
[ cfg.package ];
|
|
||||||
|
|
||||||
environment.etc = mkAlways (
|
|
||||||
[ # Create pulse/client.conf even if PulseAudio is disabled so
|
[ # Create pulse/client.conf even if PulseAudio is disabled so
|
||||||
# that we can disable the autospawn feature in programs that
|
# that we can disable the autospawn feature in programs that
|
||||||
# are built with PulseAudio support (like KDE).
|
# are built with PulseAudio support (like KDE).
|
||||||
|
{ environment.etc = singleton
|
||||||
{ target = "pulse/client.conf";
|
{ target = "pulse/client.conf";
|
||||||
source = pkgs.writeText "client.conf"
|
source = pkgs.writeText "client.conf"
|
||||||
''
|
''
|
||||||
|
@ -45,9 +41,14 @@ let cfg = config.hardware.pulseaudio; in
|
||||||
daemon-binary=${cfg.package}/bin/pulseaudio
|
daemon-binary=${cfg.package}/bin/pulseaudio
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
] ++ optionals cfg.enable
|
(mkIf cfg.enable {
|
||||||
|
|
||||||
|
environment.systemPackages = [ cfg.package ];
|
||||||
|
|
||||||
|
environment.etc =
|
||||||
[ # Write an /etc/asound.conf that causes all ALSA applications to
|
[ # Write an /etc/asound.conf that causes all ALSA applications to
|
||||||
# be re-routed to the PulseAudio server through ALSA's Pulse
|
# be re-routed to the PulseAudio server through ALSA's Pulse
|
||||||
# plugin.
|
# plugin.
|
||||||
|
@ -80,12 +81,12 @@ let cfg = config.hardware.pulseaudio; in
|
||||||
{ target = "pulse/system.pa";
|
{ target = "pulse/system.pa";
|
||||||
source = "${cfg.package}/etc/pulse/system.pa";
|
source = "${cfg.package}/etc/pulse/system.pa";
|
||||||
}
|
}
|
||||||
|
];
|
||||||
]);
|
|
||||||
|
|
||||||
# Allow PulseAudio to get realtime priority using rtkit.
|
# Allow PulseAudio to get realtime priority using rtkit.
|
||||||
security.rtkit.enable = true;
|
security.rtkit.enable = true;
|
||||||
|
|
||||||
};
|
})
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,8 +180,17 @@ in
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf config.services.samba.enable {
|
config = mkMerge
|
||||||
|
[ { # Always provide a smb.conf to shut up programs like smbclient and smbspool.
|
||||||
|
environment.etc = singleton
|
||||||
|
{ source =
|
||||||
|
if cfg.enable then configFile
|
||||||
|
else pkgs.writeText "smb-dummy.conf" "# Samba is disabled.";
|
||||||
|
target = "samba/smb.conf";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
(mkIf config.services.samba.enable {
|
||||||
users.extraUsers = singleton
|
users.extraUsers = singleton
|
||||||
{ name = user;
|
{ name = user;
|
||||||
description = "Samba service user";
|
description = "Samba service user";
|
||||||
|
@ -192,13 +201,6 @@ in
|
||||||
{ name = group;
|
{ name = group;
|
||||||
};
|
};
|
||||||
|
|
||||||
# always provide a smb.conf to shut up programs like smbclient and smbspool.
|
|
||||||
environment.etc = mkAlways (singleton
|
|
||||||
{ source =
|
|
||||||
if cfg.enable then configFile
|
|
||||||
else pkgs.writeText "smb-dummy.conf" "# Samba is disabled.";
|
|
||||||
target = "samba/smb.conf";
|
|
||||||
});
|
|
||||||
|
|
||||||
# Dummy job to start the real Samba daemons (nmbd, smbd, winbindd).
|
# Dummy job to start the real Samba daemons (nmbd, smbd, winbindd).
|
||||||
jobs.sambaControl =
|
jobs.sambaControl =
|
||||||
|
@ -216,7 +218,7 @@ in
|
||||||
jobs.smbd = daemonJob "smbd" "-D";
|
jobs.smbd = daemonJob "smbd" "-D";
|
||||||
|
|
||||||
jobs.winbindd = daemonJob "winbindd" "-D";
|
jobs.winbindd = daemonJob "winbindd" "-D";
|
||||||
|
})
|
||||||
};
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue