machines/renoir: change disko layout

Remove impermanence since it takes too much time to configure
This commit is contained in:
Romain Paquet 2026-03-22 19:21:31 +01:00
parent c394bd7d5e
commit 6b0cc09fa9

View file

@ -1,15 +1,10 @@
# --- # ---
# schema = "btrfs-single-disk-subvolumes-impermanance-rollback" # schema = "btrfs-single-disk-subvolumes"
# [placeholders] # [placeholders]
# mainDisk = "/dev/disk/by-id/nvme-CT1000P3PSSD8_2313E6C35BC1" # mainDisk = "/dev/disk/by-id/nvme-CT1000P3PSSD8_2313E6C35BC1"
# --- # ---
# This file was automatically generated! # This file was automatically generated!
# CHANGING this configuration requires wiping and reinstalling the machine # CHANGING this configuration requires wiping and reinstalling the machine
{ config, ... }:
let
# Adjust, to match the partition's priority.
rootPartition = "${config.disko.devices.disk."main".device}-part3";
in
{ {
boot.loader.grub = { boot.loader.grub = {
efiInstallAsRemovable = true; efiInstallAsRemovable = true;
@ -19,7 +14,7 @@ in
disko.devices = { disko.devices = {
disk = { disk = {
"main" = { "main" = {
name = "main-af36cf221b9a469888f67f3404be01a5"; name = "main-d15332ecbf8b4063adcbfbebda63a3a8";
device = "/dev/disk/by-id/nvme-CT1000P3PSSD8_2313E6C35BC1"; device = "/dev/disk/by-id/nvme-CT1000P3PSSD8_2313E6C35BC1";
type = "disk"; type = "disk";
content = { content = {
@ -33,7 +28,6 @@ in
"ESP" = { "ESP" = {
type = "EF00"; type = "EF00";
size = "500M"; size = "500M";
priority = 2;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
@ -41,9 +35,15 @@ in
mountOptions = [ "umask=0077" ]; mountOptions = [ "umask=0077" ];
}; };
}; };
#"swap" = {
# size = "8G"; # adjust
# content = {
# type = "swap";
# discardPolicy = "both";
# };
#};
"root" = { "root" = {
size = "100%"; size = "100%";
priority = 3;
content = { content = {
type = "btrfs"; type = "btrfs";
extraArgs = [ extraArgs = [
@ -66,74 +66,15 @@ in
mountpoint = "/home"; mountpoint = "/home";
mountOptions = [ "compress=zstd" ]; mountOptions = [ "compress=zstd" ];
}; };
"@persist" = {
mountpoint = "/persist";
mountOptions = [ "compress=zstd" ];
};
}; };
}; };
}; };
#"swap" = {
# size = "8G"; # adjust
# content = {
# type = "swap";
# discardPolicy = "both";
# };
#};
}; };
}; };
}; };
}; };
}; };
fileSystems."/persist".neededForBoot = true;
# https://www.notashelf.dev/posts/impermanence/#impermanence
boot.initrd.systemd = {
enable = true;
services.rollback = {
description = "Rollback BTRFS root drive to a pristine state";
wantedBy = [ "initrd.target" ];
after = [ "initrd-root-device.target" ];
before = [ "sysroot.mount" ];
unitConfig.DefaultDependencies = "no";
serviceConfig.Type = "oneshot";
script = ''
echo "Mounting root btrfs drive..."
mkdir --parents /mnt
mount --options "subvol=/" ${rootPartition} /mnt
if [[ -e /mnt/@root ]]; then
mkdir --parents /mnt/root.old.d
timestamp=$(date --date="@$(stat --format=%Y /mnt/@root)" "+%Y-%m-%dT%H:%M:%S")
echo "Moving @root to 'root.old.d/$timestamp'..."
mv /mnt/@root "/mnt/root.old.d/$timestamp"
fi
delete_subvolume_recursively() {
IFS=$'\n'
for subvolume in $(btrfs subvolume list -o "$1" | cut --fields 9- --delimiter ' '); do
delete_subvolume_recursively "/mnt/$subvolume"
done
echo "Deleting subvolume '$subvolume'..."
btrfs subvolume delete "$1"
}
echo "Deleting very old subvolumes..."
for subvolume in $(find /mnt/root.old.d/ -maxdepth 1 -mtime +30); do
delete_subvolume_recursively "$subvolume"
done
echo "Creating new empty subvolume @root..."
btrfs subvolume create /mnt/@root
echo "Finished successfully. Unmounting..."
umount /mnt
'';
};
};
# Automatic local snapshots # Automatic local snapshots
# https://digint.ch/btrbk/doc/readme.html # https://digint.ch/btrbk/doc/readme.html
#$ systemctl start btrbk-<instance> #$ systemctl start btrbk-<instance>
@ -152,20 +93,10 @@ in
onCalendar = "*/2:00"; onCalendar = "*/2:00";
settings = { settings = {
subvolume = "/home"; subvolume = "/home";
snapshot_create = "onchange";
snapshot_dir = "/home"; snapshot_dir = "/home";
snapshot_preserve = "16h 7d 3w 2m"; snapshot_preserve = "16h 7d 3w 2m";
snapshot_preserve_min = "3d"; snapshot_preserve_min = "3d";
}; };
}; };
instances."persist" = {
onCalendar = "*/2:00";
settings = {
subvolume = "/persist";
snapshot_dir = "/persist";
snapshot_preserve = "16h 7d 3w 2m";
snapshot_preserve_min = "3d";
};
};
}; };
} }