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-08 12:10:23 +0100
committerJörg Thalheim <joerg@thalheim.io>2019-10-14 10:30:57 +0100
commit9a894676068434ad953fc70091885ac12093fd31 (patch)
tree7051b18ed7a9e0f4afe4bd33a89fed9c4d85d022 /nixos/modules/tasks/filesystems/zfs.nix
parent692656daf85d17ceb8b9f0ad2a96aea208233857 (diff)
downloadnixpkgs-9a894676068434ad953fc70091885ac12093fd31.tar
nixpkgs-9a894676068434ad953fc70091885ac12093fd31.tar.gz
nixpkgs-9a894676068434ad953fc70091885ac12093fd31.tar.bz2
nixpkgs-9a894676068434ad953fc70091885ac12093fd31.tar.lz
nixpkgs-9a894676068434ad953fc70091885ac12093fd31.tar.xz
nixpkgs-9a894676068434ad953fc70091885ac12093fd31.tar.zst
nixpkgs-9a894676068434ad953fc70091885ac12093fd31.zip
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.
Diffstat (limited to 'nixos/modules/tasks/filesystems/zfs.nix')
-rw-r--r--nixos/modules/tasks/filesystems/zfs.nix10
1 files changed, 4 insertions, 6 deletions
diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix
index c8ba2cac0c1..baf6da8b6f7 100644
--- a/nixos/modules/tasks/filesystems/zfs.nix
+++ b/nixos/modules/tasks/filesystems/zfs.nix
@@ -16,9 +16,7 @@ let
   inInitrd = any (fs: fs == "zfs") config.boot.initrd.supportedFilesystems;
   inSystem = any (fs: fs == "zfs") config.boot.supportedFilesystems;
 
-  enableAutoSnapshots = cfgSnapshots.enable;
-  enableAutoScrub = cfgScrub.enable;
-  enableZfs = inInitrd || inSystem || enableAutoSnapshots || enableAutoScrub;
+  enableZfs = inInitrd || inSystem;
 
   kernel = config.boot.kernelPackages;
 
@@ -395,7 +393,7 @@ in
 
       system.fsPackages = [ packages.zfsUser ]; # XXX: needed? zfs doesn't have (need) a fsck
       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.
       systemd.packages = [ packages.zfsUser ];
@@ -487,7 +485,7 @@ in
       systemd.targets.zfs.wantedBy = [ "multi-user.target" ];
     })
 
-    (mkIf enableAutoSnapshots {
+    (mkIf (enableZfs && cfgSnapshots.enable) {
       systemd.services = let
                            descr = name: if name == "frequent" then "15 mins"
                                     else if name == "hourly" then "hour"
@@ -525,7 +523,7 @@ in
                             }) snapshotNames);
     })
 
-    (mkIf enableAutoScrub {
+    (mkIf (enableZfs && cfgScrub.enable) {
       systemd.services.zfs-scrub = {
         description = "ZFS pools scrubbing";
         after = [ "zfs-import.target" ];