From 17c70f32d2d51c0b0a78afb4e3746232f3c763ee Mon Sep 17 00:00:00 2001 From: C4 Patino Date: Wed, 27 May 2026 23:34:02 -0500 Subject: [PATCH] refactor: update rollback system service for zfs and disable forceImportRoot --- modules/nixos/services/storage/default.nix | 6 +++++- .../services/storage/impermanence/default.nix | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) 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;