nix/nixos/hosts/nixos-framework/disks.nix

79 lines
2.6 KiB
Nix

{
imports = [ ../../common/services/snapper.nix ];
services.btrfs.autoScrub.enable = true;
services.btrfs.autoScrub.interval = "weekly";
boot.resumeDevice = "/dev/mapper/ROOT";
# https://sawyershepherd.org/post/hibernating-to-an-encrypted-swapfile-on-btrfs-with-nixos/
boot.kernelParams = [ "resume_offset=533760" ];
disko.devices.disk.nvme0n1 = {
type = "disk";
device = "/dev/nvme0n1";
content = {
type = "gpt";
partitions = {
BOOT = {
priority = 1;
name = "BOOT";
start = "0%";
end = "550MiB";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
# https://github.com/nix-community/disko/issues/527
mountOptions = [ "umask=0077" ];
mountpoint = "/boot";
};
}; # partition 1 (ESP)
LUKS-ROOT = {
start = "550MiB";
end = "100%";
content = {
type = "luks";
name = "ROOT";
extraOpenArgs = [ "--allow-discards" ];
content = {
type = "btrfs";
extraArgs = [ "-f" ];
subvolumes = {
"/root" = {
mountpoint = "/";
mountOptions = [ "compress=zstd" "noatime" ];
}; # root
"/home" = {
mountpoint = "/home";
mountOptions = [ "compress=zstd" "noatime" ];
}; # home
"/nix" = {
mountpoint = "/nix";
mountOptions = [ "compress=zstd" "noatime" ];
}; # nix
# SNAPSHOT SUBVOLS
"/root/.snapshots" = {
mountpoint = "/.snapshots";
mountOptions = [ "compress=zstd" "noatime" ];
}; # root
"/home/.snapshots" = {
mountpoint = "/home/.snapshots";
mountOptions = [ "compress=zstd" "noatime" ];
}; # home
"/nix/.snapshots" = {
mountpoint = "/nix/.snapshots";
mountOptions = [ "compress=zstd" "noatime" ];
}; # nix
# Swap partition
"/swap" = {
mountpoint = "/swap";
swap.swapfile.size = "64G";
}; # swap
}; # subvolumes
}; # content.content
}; # content
}; # partition 2 (/ BTRFS)
}; # partitions
}; # content
}; # disko.devices.disk.nvme0
} # nix