From a483dd37659bb730ff981b5947fc92b23f1b34e4 Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Wed, 17 Dec 2025 01:07:24 -0600 Subject: [PATCH] fix some stuff --- hosts/i001/hardware-mounts.nix | 25 +++++++++---------------- hosts/i001/preservation.nix | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/hosts/i001/hardware-mounts.nix b/hosts/i001/hardware-mounts.nix index b687fe78..1d6bf6fd 100644 --- a/hosts/i001/hardware-mounts.nix +++ b/hosts/i001/hardware-mounts.nix @@ -139,14 +139,11 @@ lib.mkMerge [ # Make this part of the root-fs chain, not just initrd.target wantedBy = [ - # "initrd.target" "sysroot.mount" - "persist.mount" "initrd-root-fs.target" ]; before = [ "sysroot.mount" - "persist.mount" "initrd-root-fs.target" ]; @@ -229,7 +226,7 @@ lib.mkMerge [ # TODO rotate root } # Reset root for erase your darlings/impermanence/preservation - (lib.mkIf false { + (lib.mkIf true { boot.initrd.systemd.services.bcachefs-reset-root = { description = "Reset bcachefs root subvolume before pivot"; @@ -251,7 +248,6 @@ lib.mkMerge [ "unlock-bcachefs-custom.service" ]; wantedBy = [ - "initrd-root-fs.target" "sysroot.mount" "initrd.target" @@ -268,15 +264,11 @@ lib.mkMerge [ }; script = '' - # 1. Enable Debugging - set -x - - # 2. Define Cleanup Trap (Robust) cleanup() { - if [[ ! -e /primary_tmp/@root ]]; then - echo "Cleanup: Creating new @root" - bcachefs subvolume create /primary_tmp/@root - fi + # if [[ ! -e /primary_tmp/@root ]]; then + # echo "Cleanup: Creating new @root" + # bcachefs subvolume create /primary_tmp/@root + # fi echo "Cleanup: Unmounting /primary_tmp" umount /primary_tmp || true } @@ -288,7 +280,8 @@ lib.mkMerge [ echo "Mounting ${PRIMARY}..." if ! mount "${PRIMARY}" /primary_tmp; then echo "Mount failed. Cannot reset root." - exit 1 + # TODO change to exit 1 + exit 0 fi if [[ -e /primary_tmp/@root ]]; then @@ -300,8 +293,8 @@ lib.mkMerge [ echo "Snapshotting @root to .../$timestamp" bcachefs subvolume snapshot /primary_tmp/@root "/primary_tmp/@snapshots/old_roots/$timestamp" - echo "Deleting current @root" - bcachefs subvolume delete /primary_tmp/@root + # echo "Deleting current @root" + # bcachefs subvolume delete /primary_tmp/@root fi # Trap handles creating new root and unmount diff --git a/hosts/i001/preservation.nix b/hosts/i001/preservation.nix index edc49635..85a5efc2 100644 --- a/hosts/i001/preservation.nix +++ b/hosts/i001/preservation.nix @@ -30,8 +30,8 @@ # Files to persist files = [ - # Persist machine-id early (initrd) - { file = "/etc/machine-id"; inInitrd = true; } + # Persist machine-id early (initrd) via symlink for ConditionFirstBoot compatibility + { file = "/etc/machine-id"; inInitrd = true; how = "symlink"; configureParent = true; } # SSH host keys: ensure correct handling with symlinks { file = "/etc/ssh/ssh_host_rsa_key"; how = "symlink"; configureParent = true; } @@ -72,6 +72,19 @@ # Configure intermediate system-wide directories that may need custom modes # (Example: none required beyond defaults here.) + # Let systemd-machine-id-commit write the transient ID to the persistent volume. + # This avoids activation failure when /etc/machine-id is a symlink. + systemd.services.systemd-machine-id-commit = { + unitConfig.ConditionPathIsMountPoint = [ + "" + "/persist/etc/machine-id" + ]; + serviceConfig.ExecStart = [ + "" + "systemd-machine-id-setup --commit --root /persist" + ]; + }; + # If you need custom ownership/modes for parent directories, use tmpfiles: # systemd.tmpfiles.settings.preservation = { # "/foo".d = { user = "foo"; group = "bar"; mode = "0775"; };