refactor(host/orion): improve fs layout

This commit is contained in:
Price Hiller 2025-01-09 16:48:02 -06:00
parent df18b44c4b
commit bd4ed609c9
Signed by: Price
GPG Key ID: C3FADDE7A8534BEB

View File

@ -1,4 +1,7 @@
{ lib, ... }: {
lib ? (import <nixpkgs> { }).lib,
...
}:
let let
root-disk = "/dev/nvme0n1"; root-disk = "/dev/nvme0n1";
persist-dir = "/persist"; persist-dir = "/persist";
@ -38,18 +41,13 @@ in
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
esp = esp = {
let
label = "NixOS-Boot";
in
{
priority = 1; priority = 1;
size = "512M"; size = "512M";
type = "EF00"; type = "EF00";
content = { content = {
extraArgs = [ extraArgs = [
"-n ${label}" "-n 'NixOS-Boot'"
"-F 32"
]; ];
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
@ -60,11 +58,7 @@ in
]; ];
}; };
}; };
root = root = {
let
label = "NixOS-Primary";
in
{
size = "100%"; size = "100%";
content = { content = {
type = "luks"; type = "luks";
@ -77,13 +71,10 @@ in
type = "btrfs"; type = "btrfs";
extraArgs = [ extraArgs = [
"-f" "-f"
"--label ${label}" "-L NixOS-Primary"
]; ];
postCreateHook = '' preUnmountHook = ''
MOUNT="$(mktemp -d)" btrfs subvolume snapshot -r "root" "root-base"
mount "/dev/disk/by-label/${label}" "$MOUNT" -o subvol=/
trap 'umount $MOUNT; rm -rf $MOUNT' EXIT
btrfs subvolume snapshot -r "$MOUNT/root" "$MOUNT/root-base"
''; '';
subvolumes = { subvolumes = {
"/root" = { "/root" = {