refactor: update rollback system service for zfs and disable forceImportRoot

This commit is contained in:
Ceferino Patino 2026-05-27 23:34:02 -05:00
commit 17c70f32d2
Signed by: c4patino
SSH key fingerprint: SHA256:9fQ9TsujGrdNNi76mnsu63v7dS5JOmHRZEqBOl49OR8
2 changed files with 20 additions and 5 deletions

View file

@ -1,5 +1,9 @@
{pkgs, ...}: {
boot.supportedFilesystems = ["ntfs" "zfs" "nfs"];
boot = {
supportedFilesystems = ["ntfs" "zfs" "nfs"];
zfs.forceImportRoot = false;
};
services.davfs2.enable = true;

View file

@ -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;