nixos/zfs: only enable trim if zfs is enabled

Also don't fail the service if there are no pools yet.
This might happen on installation ISOs.
This commit is contained in:
Jörg Thalheim 2019-10-07 10:43:59 +01:00
parent 0b754fbe54
commit a412d90e10
No known key found for this signature in database
GPG Key ID: B3F5D81B0C6967C4

View File

@ -552,14 +552,14 @@ in
}; };
}) })
(mkIf cfgTrim.enable { (mkIf (enableZfs && cfgTrim.enable) {
systemd.services.zpool-trim = { systemd.services.zpool-trim = {
description = "ZFS pools trim"; description = "ZFS pools trim";
after = [ "zfs-import.target" ]; after = [ "zfs-import.target" ];
path = [ packages.zfsUser ]; path = [ packages.zfsUser ];
startAt = cfgTrim.interval; startAt = cfgTrim.interval;
script = '' script = ''
zpool list -H -o name | xargs -n1 zpool trim zpool list -H -o name | xargs --no-run-if-empty -n1 zpool trim
''; '';
}; };
}) })