diff --git a/modules/nixos/services/storage/default.nix b/modules/nixos/services/storage/default.nix index a7e7e4c..43d4299 100644 --- a/modules/nixos/services/storage/default.nix +++ b/modules/nixos/services/storage/default.nix @@ -1,5 +1,9 @@ {pkgs, ...}: { - boot.supportedFilesystems = ["ntfs" "zfs" "nfs"]; + boot = { + supportedFilesystems = ["ntfs" "zfs" "nfs"]; + + zfs.forceImportRoot = false; + }; services.davfs2.enable = true; diff --git a/modules/nixos/services/storage/impermanence/default.nix b/modules/nixos/services/storage/impermanence/default.nix index 3323945..0624396 100644 --- a/modules/nixos/services/storage/impermanence/default.nix +++ b/modules/nixos/services/storage/impermanence/default.nix @@ -5,7 +5,7 @@ namespace, ... }: let - inherit (lib) types mkIf mkEnableOption mkOption mkAfter concatLists; + inherit (lib) types mkIf mkEnableOption mkOption concatLists; inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; base = "${namespace}.services.storage.impermanence"; cfg = getAttrByNamespace config base; @@ -49,9 +49,20 @@ in { config = mkIf cfg.enable { fileSystems."/persist".neededForBoot = true; - boot.initrd.postResumeCommands = mkAfter '' - zfs rollback -r zroot/root@blank - ''; + boot.initrd.systemd.services.rollback = { + description = "Rollback ZFS root to blank snapshot"; + wantedBy = ["initrd.target"]; + after = ["zfs-import-zroot.service"]; + before = ["sysroot.mount"]; + path = [config.boot.zfs.package]; + + unitConfig.DefaultDependencies = "no"; + serviceConfig.Type = "oneshot"; + + script = '' + zfs rollback -r zroot/root@blank + ''; + }; environment.persistence."/persist" = { hideMounts = true;