fix some stuff

This commit is contained in:
RingOfStorms (Joshua Bell) 2025-12-17 01:07:24 -06:00
parent 297bbc54ed
commit a483dd3765
2 changed files with 24 additions and 18 deletions

View file

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

View file

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