Files
sydnix/hosts/nixos-testbed/disko-config.nix
Madeleine Sydney 1e5f745767 init
2024-12-11 19:20:45 -07:00

156 lines
4.8 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 = [ inputs.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";
# start = "1MiB";
# end = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
root = {
# start = "512M";
# end = "100%";
size = "100%";
content = {
type = "zfs";
pool = "rpool";
};
};
};
};
};
};
zpool = {
rpool = {
type = "zpool";
# Workaround: cannot import 'rpool': I/O error in disko tests
# options.cachefile = "none";
# rootFsOptions = {
# # I don't know.
# # https://wiki.archlinux.org/title/Systemd#systemd-tmpfiles-setup.service_fails_to_start_at_boot
# acltype = "posixacl";
# # atime = "off";
# # compression = "zstd";
# mountpoint = "none";
# # xattr = "sa";
# "com.sun:auto-snapshot" = "false";
# };
# mountpoint = "/";
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 {
mountpoint = null;
options = {
canmount = "off";
mountpoint = "none";
reservation = "5GiB";
};
};
# "local" = {
# type = "zfs_fs";
# options.mountpoint = "none";
# };
# "safe" = {
# type = "zfs_fs";
# options.mountpoint = "none";
# };
# "local/root" = {
# type = "zfs_fs";
# options.mountpoint = "legacy";
# mountpoint = "/";
# options."com.sun:auto-snapshot" = "false";
# postCreateHook = ''
# zfs list -t snapshot -H -o name \
# | grep -E '^rpool/local/root@blank$' \
# || zfs snapshot rpool/local/root@blank
# '';
# };
# "local/home" = {
# };
# "local/nix" = {
# type = "zfs_fs";
# options.mountpoint = "legacy";
# mountpoint = "/nix";
# options."com.sun:auto-snapshot" = "false";
# };
# "safe/persist" = {
# type = "zfs_fs";
# options.mountpoint = "legacy";
# mountpoint = "/persist";
# options."com.sun:auto-snapshot" = "false";
# };
# # zfs uses copy on write and requires some free space to delete files when the disk is completely filled
# "reserved" = lib.recursiveUpdate (dataset "reserved") {
# mountpoint = null;
# options = {
# canmount = "off";
# mountpoint = "none";
# reservation = "5GiB";
# };
# type = "zfs_fs";
# };
};
};
};
};
}