Files
sydnix/hosts/nixos-testbed/disko-config.nix
Madeleine Sydney 3f846d783a Large refactor
2024-12-12 13:54:17 -07:00

92 lines
2.7 KiB
Nix

# sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode disko /nixos/hosts/nixos-testbed/disko-config.nix
# time sudo nixos-install --flake /nixos#nixos-testbed
{ lib, ... }:
{
# imports = [ disko.nixosModules.disko ];
boot.zfs.extraPools = [ "rpool" ];
boot.zfs.devNodes = "/dev/disk/by-path";
boot.initrd.supportedFilesystems = [ "zfs" ];
boot.supportedFilesystems = [ "zfs" ];
disko.devices = {
disk = {
broot = {
type = "disk";
device = "/dev/vda";
content = {
type = "gpt";
partitions = {
ESP = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
root = {
size = "100%";
content = {
type = "zfs";
pool = "rpool";
};
};
};
};
};
};
zpool = {
rpool = {
type = "zpool";
datasets =
let dataset = options:
let default = {
type = "zfs_fs";
mountOptions = [ "noauto" ];
options = {
"com.sun:auto-snapshot" = "false";
};
};
in lib.recursiveUpdate default options;
in
{
"local" = dataset {};
"darlings" = dataset {};
"local/root" = dataset {
mountpoint = "/";
postCreateHook = ''
zfs list -t snapshot -H -o name \
| grep -E '^rpool/local/root@blank$' \
|| zfs snapshot rpool/local/root@blank
'';
};
"local/nix" = dataset { mountpoint = "/nix"; };
"local/home" = dataset {
mountpoint = "/home";
postCreateHook = ''
zfs list -t snapshot -H -o name \
| grep -E '^rpool/local/home@blank$' \
|| zfs snapshot rpool/local/home@blank
'';
};
"darlings/persist" = dataset { mountpoint = "/persist"; };
"darlings/home" = dataset {
mountpoint = "/persist/home";
};
"reserved" = dataset {
options = {
canmount = "off";
mountpoint = "none";
reservation = "5GiB";
};
};
};
};
};
};
fileSystems."/persist".neededForBoot = true;
}