fix some stuff
This commit is contained in:
parent
297bbc54ed
commit
a483dd3765
2 changed files with 24 additions and 18 deletions
|
|
@ -139,14 +139,11 @@ lib.mkMerge [
|
||||||
|
|
||||||
# Make this part of the root-fs chain, not just initrd.target
|
# Make this part of the root-fs chain, not just initrd.target
|
||||||
wantedBy = [
|
wantedBy = [
|
||||||
# "initrd.target"
|
|
||||||
"sysroot.mount"
|
"sysroot.mount"
|
||||||
"persist.mount"
|
|
||||||
"initrd-root-fs.target"
|
"initrd-root-fs.target"
|
||||||
];
|
];
|
||||||
before = [
|
before = [
|
||||||
"sysroot.mount"
|
"sysroot.mount"
|
||||||
"persist.mount"
|
|
||||||
"initrd-root-fs.target"
|
"initrd-root-fs.target"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -229,7 +226,7 @@ lib.mkMerge [
|
||||||
# TODO rotate root
|
# TODO rotate root
|
||||||
}
|
}
|
||||||
# Reset root for erase your darlings/impermanence/preservation
|
# Reset root for erase your darlings/impermanence/preservation
|
||||||
(lib.mkIf false {
|
(lib.mkIf true {
|
||||||
boot.initrd.systemd.services.bcachefs-reset-root = {
|
boot.initrd.systemd.services.bcachefs-reset-root = {
|
||||||
description = "Reset bcachefs root subvolume before pivot";
|
description = "Reset bcachefs root subvolume before pivot";
|
||||||
|
|
||||||
|
|
@ -251,7 +248,6 @@ lib.mkMerge [
|
||||||
"unlock-bcachefs-custom.service"
|
"unlock-bcachefs-custom.service"
|
||||||
];
|
];
|
||||||
wantedBy = [
|
wantedBy = [
|
||||||
|
|
||||||
"initrd-root-fs.target"
|
"initrd-root-fs.target"
|
||||||
"sysroot.mount"
|
"sysroot.mount"
|
||||||
"initrd.target"
|
"initrd.target"
|
||||||
|
|
@ -268,15 +264,11 @@ lib.mkMerge [
|
||||||
};
|
};
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
# 1. Enable Debugging
|
|
||||||
set -x
|
|
||||||
|
|
||||||
# 2. Define Cleanup Trap (Robust)
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
if [[ ! -e /primary_tmp/@root ]]; then
|
# if [[ ! -e /primary_tmp/@root ]]; then
|
||||||
echo "Cleanup: Creating new @root"
|
# echo "Cleanup: Creating new @root"
|
||||||
bcachefs subvolume create /primary_tmp/@root
|
# bcachefs subvolume create /primary_tmp/@root
|
||||||
fi
|
# fi
|
||||||
echo "Cleanup: Unmounting /primary_tmp"
|
echo "Cleanup: Unmounting /primary_tmp"
|
||||||
umount /primary_tmp || true
|
umount /primary_tmp || true
|
||||||
}
|
}
|
||||||
|
|
@ -288,7 +280,8 @@ lib.mkMerge [
|
||||||
echo "Mounting ${PRIMARY}..."
|
echo "Mounting ${PRIMARY}..."
|
||||||
if ! mount "${PRIMARY}" /primary_tmp; then
|
if ! mount "${PRIMARY}" /primary_tmp; then
|
||||||
echo "Mount failed. Cannot reset root."
|
echo "Mount failed. Cannot reset root."
|
||||||
exit 1
|
# TODO change to exit 1
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -e /primary_tmp/@root ]]; then
|
if [[ -e /primary_tmp/@root ]]; then
|
||||||
|
|
@ -300,8 +293,8 @@ lib.mkMerge [
|
||||||
echo "Snapshotting @root to .../$timestamp"
|
echo "Snapshotting @root to .../$timestamp"
|
||||||
bcachefs subvolume snapshot /primary_tmp/@root "/primary_tmp/@snapshots/old_roots/$timestamp"
|
bcachefs subvolume snapshot /primary_tmp/@root "/primary_tmp/@snapshots/old_roots/$timestamp"
|
||||||
|
|
||||||
echo "Deleting current @root"
|
# echo "Deleting current @root"
|
||||||
bcachefs subvolume delete /primary_tmp/@root
|
# bcachefs subvolume delete /primary_tmp/@root
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Trap handles creating new root and unmount
|
# Trap handles creating new root and unmount
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@
|
||||||
|
|
||||||
# Files to persist
|
# Files to persist
|
||||||
files = [
|
files = [
|
||||||
# Persist machine-id early (initrd)
|
# Persist machine-id early (initrd) via symlink for ConditionFirstBoot compatibility
|
||||||
{ file = "/etc/machine-id"; inInitrd = true; }
|
{ file = "/etc/machine-id"; inInitrd = true; how = "symlink"; configureParent = true; }
|
||||||
|
|
||||||
# SSH host keys: ensure correct handling with symlinks
|
# SSH host keys: ensure correct handling with symlinks
|
||||||
{ file = "/etc/ssh/ssh_host_rsa_key"; how = "symlink"; configureParent = true; }
|
{ 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
|
# Configure intermediate system-wide directories that may need custom modes
|
||||||
# (Example: none required beyond defaults here.)
|
# (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:
|
# If you need custom ownership/modes for parent directories, use tmpfiles:
|
||||||
# systemd.tmpfiles.settings.preservation = {
|
# systemd.tmpfiles.settings.preservation = {
|
||||||
# "/foo".d = { user = "foo"; group = "bar"; mode = "0775"; };
|
# "/foo".d = { user = "foo"; group = "bar"; mode = "0775"; };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue