diff --git a/global/fs/zfs.nix b/global/fs/zfs.nix index 2ad0a722..6d09fedf 100644 --- a/global/fs/zfs.nix +++ b/global/fs/zfs.nix @@ -16,25 +16,25 @@ in { defaults to nix store dataset ''; }; + mountpoints = mkOption { + type = with types; attrsOf str; + description = "zfs dataset mountpoints"; + }; }; config = mkIf (cfg.type == "zfs") { - fileSystems = { + fileSystems = (mapAttrs (path: dataset: { + device = "${cfg.zfs.persist}/${dataset}"; + fsType = "zfs"; + # required by impermanence + neededForBoot = true; + }) cfg.zfs.mountpoints) // { "/nix" = { device = "${cfg.store}/nix"; fsType = "zfs"; }; - "/nix/persist" = - { device = "${cfg.zfs.persist}/persist"; - fsType = "zfs"; - neededForBoot = true; - }; - } // (mapAttrs' (name: opts: nameValuePair - "/nix/persist/home/${name}" { - device = "${cfg.zfs.persist}/home/${name}"; - fsType = "zfs"; - neededForBoot = true; - }) (filterAttrs (n: _: n != "root") config.users.profiles)); + }; + global.fs.zfs.mountpoints."/nix/persist" = "persist"; services.zfs.trim.enable = true; services.zfs.autoSnapshot.enable = true;