mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-12-06 21:17:14 -06:00
feat: added impermanence to ceres
This commit is contained in:
parent
a2f229e05f
commit
5d80a9f7b0
4 changed files with 96 additions and 8 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
flake,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
|
@ -9,16 +10,82 @@ in
|
|||
{
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
device = "/dev/disk/by-uuid/4b740a8e-8123-4d29-8ec2-132aebb0583d";
|
||||
fsType = "ext4";
|
||||
device = "/dev/disk/by-label/root";
|
||||
fsType = "btrfs";
|
||||
options = [
|
||||
"subvol=@"
|
||||
];
|
||||
};
|
||||
|
||||
"/nix" = {
|
||||
device = "/dev/disk/by-label/root";
|
||||
fsType = "btrfs";
|
||||
options = [
|
||||
"subvol=@nix"
|
||||
];
|
||||
};
|
||||
|
||||
"/persistent" = {
|
||||
device = "/dev/disk/by-label/root";
|
||||
fsType = "btrfs";
|
||||
neededForBoot = true;
|
||||
options = [
|
||||
"subvol=@persistent"
|
||||
];
|
||||
};
|
||||
|
||||
"/boot" = {
|
||||
device = "/dev/disk/by-uuid/34BA-5602";
|
||||
device = "/dev/disk/by-label/BOOT";
|
||||
fsType = "vfat";
|
||||
};
|
||||
|
||||
"/mnt/storage" = {
|
||||
device = "dev/disk/by-label/storage";
|
||||
fsType = "xfs";
|
||||
device = "/dev/disk/by-label/storage";
|
||||
fsType = "ext4";
|
||||
};
|
||||
};
|
||||
|
||||
boot.initrd.postResumeCommands = lib.mkAfter ''
|
||||
mkdir -p /mnt
|
||||
mount -o subvol=/ /dev/disk/by-label/root /mnt
|
||||
|
||||
if [[ -e /mnt/@ ]]; then
|
||||
mkdir -p /mnt/@old_roots
|
||||
timestamp=$(date --date="@$(stat -c %Y /mnt/@)" "+%Y-%m-%d_%H:%M:%S")
|
||||
mv /mnt/@ "/mnt/@old_roots/$timestamp"
|
||||
fi
|
||||
|
||||
delete_subvolume_recursively() {
|
||||
IFS=$'\n'
|
||||
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||
delete_subvolume_recursively "/mnt/$i"
|
||||
done
|
||||
btrfs subvolume delete "$1"
|
||||
}
|
||||
|
||||
for i in $(find /mnt/@old_roots/ -maxdepth 1 -mtime +30); do
|
||||
delete_subvolume_recursively "$i"
|
||||
done
|
||||
|
||||
btrfs subvolume create /mnt/@
|
||||
umount /mnt
|
||||
'';
|
||||
|
||||
environment.persistence."/persistent" = {
|
||||
hideMounts = true;
|
||||
directories = [
|
||||
"/var/log"
|
||||
"/var/lib"
|
||||
"/var/cache"
|
||||
"/etc/ssh"
|
||||
];
|
||||
files = [
|
||||
"/etc/machine-id"
|
||||
];
|
||||
users.${user0} = {
|
||||
directories = [
|
||||
".ssh"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue