From 14007ca4f8099344fa12db3a96d417434f0e3731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 24 Oct 2024 11:49:05 +0200 Subject: [PATCH] fix: boot issues --- hosts/nixos-desktop/disko.nix | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/hosts/nixos-desktop/disko.nix b/hosts/nixos-desktop/disko.nix index d373c43..43d1242 100644 --- a/hosts/nixos-desktop/disko.nix +++ b/hosts/nixos-desktop/disko.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, pkgs, ... }: { # needed for zfs pool @@ -83,9 +83,27 @@ }; }; # rollback to blank - boot.initrd.postDeviceCommands = lib.mkAfter '' - zfs rollback -r zroot/encrypted/root@blank && echo "rollback complete" - ''; + boot.initrd.systemd.services.rollback = { + description = "Rollback ZFS datasets to a pristine state"; + wantedBy = [ + "initrd.target" + ]; + after = [ + "zfs-import-zroot.service" + ]; + before = [ + "sysroot.mount" + ]; + path = with pkgs; [ + zfs + ]; + unitConfig.DefaultDependencies = "no"; + serviceConfig.Type = "oneshot"; + script = '' + zfs rollback -r zroot/encrypted/root@blank && echo "rollback complete" + ''; + }; + boot.initrd.systemd.enable = true; fileSystems."/persist".neededForBoot = true; # HACK: to fix issue of agenix running before impermanence age.identityPaths = [