nixos-configuration/hosts/jalr-t520/disko.nix
2025-08-15 14:20:11 +02:00

65 lines
2 KiB
Nix

{ config, ... }:
let
cfg = config.disko;
in
{
disko.devices = {
disk = {
system = {
type = "disk";
device = "/dev/disk/by-id/ata-Samsung_SSD_850_EVO_120GB_S21UNSAG200527E";
content = {
type = "gpt";
partitions = {
esp = {
type = "EF00";
size = "1024M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "uid=0" "gid=0" "fmask=0077" "dmask=0077" "nodev" "nosuid" "noexec" ];
};
};
nixos = {
size = "100%";
content = {
type = "btrfs";
extraArgs = [ "-f" ];
subvolumes = {
"/root" = {
mountpoint = "/";
mountOptions = [ "compress-force=zstd:1" "noatime" ];
};
"/home" = {
mountpoint = "/home";
mountOptions = [ "compress-force=zstd:1" "noatime" "nodev" "nosuid" ];
};
"/home/.snapshots" = {
mountOptions = [ "compress-force=zstd:1" "noatime" "nodev" "nosuid" ];
};
"/nix" = {
mountpoint = "/nix";
mountOptions = [ "compress-force=zstd:1" "noatime" "noatime" "nodev" ];
};
};
postCreateHook =
let
inherit (cfg.devices.disk.system.content.partitions.nixos) device;
in
''
mountpoint="$(mktemp -d)"
mount "${device}" "$mountpoint" -o subvol=/
trap 'umount "$mountpoint"; rmdir "$mountpoint"' EXIT
btrfs subvolume snapshot -r $mountpoint/root $mountpoint/root-blank
'';
};
};
};
};
};
};
};
}