forked from mirrors/nixpkgs
nixos/zfs: simplify logic for scrub/autosnapshot service
This makes them consistent with the way zfs.trim is enabled and allow to enable them by default in future.
This commit is contained in:
parent
692656daf8
commit
9a89467606
|
@ -36,6 +36,15 @@
|
||||||
quirk in the boot menu.
|
quirk in the boot menu.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The zfs scrub service (<varname>services.zfs.autoScrub.enable</varname>)
|
||||||
|
and the zfs autosnapshot service (<varname>services.zfs.autoSnapshot.enable</varname>)
|
||||||
|
are now only enabled if zfs is set in <varname>config.boot.initrd.supportedFilesystems</varname> or
|
||||||
|
<varname>config.boot.supportedFilesystems</varname>. These lists will automatically contain
|
||||||
|
zfs as soon as any zfs mountpoint is configured in <varname>fileSystems</varname>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,7 @@ let
|
||||||
inInitrd = any (fs: fs == "zfs") config.boot.initrd.supportedFilesystems;
|
inInitrd = any (fs: fs == "zfs") config.boot.initrd.supportedFilesystems;
|
||||||
inSystem = any (fs: fs == "zfs") config.boot.supportedFilesystems;
|
inSystem = any (fs: fs == "zfs") config.boot.supportedFilesystems;
|
||||||
|
|
||||||
enableAutoSnapshots = cfgSnapshots.enable;
|
enableZfs = inInitrd || inSystem;
|
||||||
enableAutoScrub = cfgScrub.enable;
|
|
||||||
enableZfs = inInitrd || inSystem || enableAutoSnapshots || enableAutoScrub;
|
|
||||||
|
|
||||||
kernel = config.boot.kernelPackages;
|
kernel = config.boot.kernelPackages;
|
||||||
|
|
||||||
|
@ -395,7 +393,7 @@ in
|
||||||
|
|
||||||
system.fsPackages = [ packages.zfsUser ]; # XXX: needed? zfs doesn't have (need) a fsck
|
system.fsPackages = [ packages.zfsUser ]; # XXX: needed? zfs doesn't have (need) a fsck
|
||||||
environment.systemPackages = [ packages.zfsUser ]
|
environment.systemPackages = [ packages.zfsUser ]
|
||||||
++ optional enableAutoSnapshots autosnapPkg; # so the user can run the command to see flags
|
++ optional cfgSnapshots.enable autosnapPkg; # so the user can run the command to see flags
|
||||||
|
|
||||||
services.udev.packages = [ packages.zfsUser ]; # to hook zvol naming, etc.
|
services.udev.packages = [ packages.zfsUser ]; # to hook zvol naming, etc.
|
||||||
systemd.packages = [ packages.zfsUser ];
|
systemd.packages = [ packages.zfsUser ];
|
||||||
|
@ -487,7 +485,7 @@ in
|
||||||
systemd.targets.zfs.wantedBy = [ "multi-user.target" ];
|
systemd.targets.zfs.wantedBy = [ "multi-user.target" ];
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf enableAutoSnapshots {
|
(mkIf (enableZfs && cfgSnapshots.enable) {
|
||||||
systemd.services = let
|
systemd.services = let
|
||||||
descr = name: if name == "frequent" then "15 mins"
|
descr = name: if name == "frequent" then "15 mins"
|
||||||
else if name == "hourly" then "hour"
|
else if name == "hourly" then "hour"
|
||||||
|
@ -525,7 +523,7 @@ in
|
||||||
}) snapshotNames);
|
}) snapshotNames);
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf enableAutoScrub {
|
(mkIf (enableZfs && cfgScrub.enable) {
|
||||||
systemd.services.zfs-scrub = {
|
systemd.services.zfs-scrub = {
|
||||||
description = "ZFS pools scrubbing";
|
description = "ZFS pools scrubbing";
|
||||||
after = [ "zfs-import.target" ];
|
after = [ "zfs-import.target" ];
|
||||||
|
|
Loading…
Reference in a new issue