@@ -16,9 +16,7 @@ let
1616 inInitrd = any (fs: fs == "zfs") config.boot.initrd.supportedFilesystems;
1717 inSystem = any (fs: fs == "zfs") config.boot.supportedFilesystems;
1818
19− enableAutoSnapshots = cfgSnapshots.enable;
20− enableAutoScrub = cfgScrub.enable;
21− enableZfs = inInitrd || inSystem || enableAutoSnapshots || enableAutoScrub;
19+ enableZfs = inInitrd || inSystem;
2220
2321 kernel = config.boot.kernelPackages;
2422
@@ -395,7 +393,7 @@ in
395393
396394 system.fsPackages = [ packages.zfsUser ]; # XXX: needed? zfs doesn't have (need) a fsck
397395 environment.systemPackages = [ packages.zfsUser ]
398− ++ optional enableAutoSnapshots autosnapPkg; # so the user can run the command to see flags
396+ ++ optional cfgSnapshots.enable autosnapPkg; # so the user can run the command to see flags
399397
400398 services.udev.packages = [ packages.zfsUser ]; # to hook zvol naming, etc.
401399 systemd.packages = [ packages.zfsUser ];
@@ -487,7 +485,7 @@ in
487485 systemd.targets.zfs.wantedBy = [ "multi-user.target" ];
488486 })
489487
490− (mkIf enableAutoSnapshots {
488+ (mkIf (enableZfs && cfgSnapshots.enable) {
491489 systemd.services = let
492490 descr = name: if name == "frequent" then "15 mins"
493491 else if name == "hourly" then "hour"
@@ -525,7 +523,7 @@ in
525523 }) snapshotNames);
526524 })
527525
528− (mkIf enableAutoScrub {
526+ (mkIf (enableZfs && cfgScrub.enable) {
529527 systemd.services.zfs-scrub = {
530528 description = "ZFS pools scrubbing";
531529 after = [ "zfs-import.target" ];
@@ -552,15 +550,13 @@ in
552550 };
553551 })
554552
555− (mkIf cfgTrim.enable {
553+ (mkIf (enableZfs && cfgTrim.enable) {
556554 systemd.services.zpool-trim = {
557555 description = "ZFS pools trim";
558556 after = [ "zfs-import.target" ];
559557 path = [ packages.zfsUser ];
560558 startAt = cfgTrim.interval;
561− script = ''
562− zpool list -H -o name | xargs -n1 zpool trim
563− '';
559+ serviceConfig.ExecStart = "${pkgs.runtimeShell} -c 'zpool list -H -o name | xargs --no-run-if-empty -n1 zpool trim'";
564560 };
565561 })
566562 ];