summary refs log tree commit diff
path: root/nixos/modules/tasks/filesystems/zfs.nix
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2019-10-07 10:43:59 +0100
committerJörg Thalheim <joerg@thalheim.io>2019-10-07 10:44:56 +0100
commita412d90e101b94d797f6aca4b96fdac2fd85e599 (patch)
treecc52af42e170ab3d2991223ad62c1095cb925408 /nixos/modules/tasks/filesystems/zfs.nix
parent0b754fbe542a8455d707516188cb3471663b629e (diff)
downloadnixpkgs-a412d90e101b94d797f6aca4b96fdac2fd85e599.tar
nixpkgs-a412d90e101b94d797f6aca4b96fdac2fd85e599.tar.gz
nixpkgs-a412d90e101b94d797f6aca4b96fdac2fd85e599.tar.bz2
nixpkgs-a412d90e101b94d797f6aca4b96fdac2fd85e599.tar.lz
nixpkgs-a412d90e101b94d797f6aca4b96fdac2fd85e599.tar.xz
nixpkgs-a412d90e101b94d797f6aca4b96fdac2fd85e599.tar.zst
nixpkgs-a412d90e101b94d797f6aca4b96fdac2fd85e599.zip
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.
Diffstat (limited to 'nixos/modules/tasks/filesystems/zfs.nix')
-rw-r--r--nixos/modules/tasks/filesystems/zfs.nix4
1 files changed, 2 insertions, 2 deletions
diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix
index cfdc0a31020..6cfa510a78a 100644
--- a/nixos/modules/tasks/filesystems/zfs.nix
+++ b/nixos/modules/tasks/filesystems/zfs.nix
@@ -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
         '';
       };
     })