1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-24 22:50:49 +00:00

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 = {
description = "ZFS pools trim";
after = [ "zfs-import.target" ];
path = [ packages.zfsUser ];
startAt = cfgTrim.interval;
script = ''
zpool list -H -o name | xargs -n1 zpool trim
zpool list -H -o name | xargs --no-run-if-empty -n1 zpool trim
'';
};
})