initial attempt at impermance

This commit is contained in:
twoneis 2024-05-08 19:20:06 +02:00
parent bfe077d474
commit 932838f736
5 changed files with 74 additions and 39 deletions

View file

@ -6,10 +6,10 @@
postDeviceCommands = lib.mkAfter ''
mkdir /btrfs_tmp
mount /dev/disk/by-uuid/b6e6bca7-1435-4b41-b174-8550eace7c32 /btrfs_tmp
if [[ -e /btrfs_tmp/root ]]; then
if [[ -e /btrfs_tmp/rootfs ]]; then
mkdir -p /btrfs_tmp/old_roots
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/rootfs)" "+%Y-%m-%-d_%H:%M:%S")
mv /btrfs_tmp/rootfs "/btrfs_tmp/old_roots/$timestamp"
fi
delete_subvolume_recursively() {
@ -24,7 +24,7 @@
delete_subvolume_recursively "$i"
done
btrfs subvolume create /btrfs_tmp/root
btrfs subvolume create /btrfs_tmp/rootfs
umount /btrfs_tmp
'';
};
@ -35,6 +35,7 @@
fileSystems = {
"/boot" = {
device = "/dev/disk/by-uuid/7ABC-9C12";
neededForBoot = true;
fsType = "vfat";
};
"/" = {
@ -45,16 +46,19 @@
"/nix" = {
device = "/dev/disk/by-uuid/b6e6bca7-1435-4b41-b174-8550eace7c32";
fsType = "btrfs";
neededForBoot = true;
options = [ "subvol=nix" "compress=zstd" "noatime" ];
};
"/persist" = {
device = "/dev/disk/by-uuid/b6e6bca7-1435-4b41-b174-8550eace7c32";
fsType = "btrfs";
neededForBoot = true;
options = [ "subvol=persist" "compress=zstd" "noatime" ];
};
"/ext" = {
device = "/dev/disk/by-uuid/3ed92a26-775a-4e39-ac1c-84b2822cd3dd";
fsType = "btrfs";
neededForBoot = true;
options = [ "subvol=ext" "compress=zstd" "noatime" ];
};
};