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>2021-01-15 13:18:34 +0100
committerJörg Thalheim <joerg@thalheim.io>2021-02-01 17:59:18 +0100
commited1f13244b080df6fc0b249590ce5d06a726aea6 (patch)
tree24afb9545fc2bc20ad28b199cae434343000fb8e /nixos/modules/tasks/filesystems/zfs.nix
parent648a6c4348f19c5c50bbff20ed683f783194574b (diff)
downloadnixpkgs-ed1f13244b080df6fc0b249590ce5d06a726aea6.tar
nixpkgs-ed1f13244b080df6fc0b249590ce5d06a726aea6.tar.gz
nixpkgs-ed1f13244b080df6fc0b249590ce5d06a726aea6.tar.bz2
nixpkgs-ed1f13244b080df6fc0b249590ce5d06a726aea6.tar.lz
nixpkgs-ed1f13244b080df6fc0b249590ce5d06a726aea6.tar.xz
nixpkgs-ed1f13244b080df6fc0b249590ce5d06a726aea6.tar.zst
nixpkgs-ed1f13244b080df6fc0b249590ce5d06a726aea6.zip
nixos/zfs: expose enabled option
Diffstat (limited to 'nixos/modules/tasks/filesystems/zfs.nix')
-rw-r--r--nixos/modules/tasks/filesystems/zfs.nix18
1 files changed, 12 insertions, 6 deletions
diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix
index f3af8cc7116..df9d0fdc4d3 100644
--- a/nixos/modules/tasks/filesystems/zfs.nix
+++ b/nixos/modules/tasks/filesystems/zfs.nix
@@ -17,8 +17,6 @@ let
   inInitrd = any (fs: fs == "zfs") config.boot.initrd.supportedFilesystems;
   inSystem = any (fs: fs == "zfs") config.boot.supportedFilesystems;
 
-  enableZfs = inInitrd || inSystem;
-
   autosnapPkg = pkgs.zfstools.override {
     zfs = cfgZfs.package;
   };
@@ -107,6 +105,14 @@ in
         default = if config.boot.zfs.enableUnstable then pkgs.zfsUnstable else pkgs.zfs;
         description = "Configured ZFS userland tools package.";
       };
+
+      enabled = mkOption {
+        readOnly = true;
+        type = types.bool;
+        default = inInitrd || inSystem;
+        description = "True if ZFS filesystem support is enabled";
+      };
+
       enableUnstable = mkOption {
         type = types.bool;
         default = false;
@@ -350,7 +356,7 @@ in
   ###### implementation
 
   config = mkMerge [
-    (mkIf enableZfs {
+    (mkIf cfgZfs.enabled {
       assertions = [
         {
           assertion = config.networking.hostId != null;
@@ -589,7 +595,7 @@ in
       systemd.targets.zfs.wantedBy = [ "multi-user.target" ];
     })
 
-    (mkIf (enableZfs && cfgSnapshots.enable) {
+    (mkIf (cfgZfs.enabled && cfgSnapshots.enable) {
       systemd.services = let
                            descr = name: if name == "frequent" then "15 mins"
                                     else if name == "hourly" then "hour"
@@ -627,7 +633,7 @@ in
                             }) snapshotNames);
     })
 
-    (mkIf (enableZfs && cfgScrub.enable) {
+    (mkIf (cfgZfs.enabled && cfgScrub.enable) {
       systemd.services.zfs-scrub = {
         description = "ZFS pools scrubbing";
         after = [ "zfs-import.target" ];
@@ -654,7 +660,7 @@ in
       };
     })
 
-    (mkIf (enableZfs && cfgTrim.enable) {
+    (mkIf (cfgZfs.enabled && cfgTrim.enable) {
       systemd.services.zpool-trim = {
         description = "ZFS pools trim";
         after = [ "zfs-import.target" ];