2024-02-17 18:39:09 +01:00
|
|
|
{ pkgs, lib, config, ... }:
|
2023-12-16 14:37:23 +01:00
|
|
|
# TODO Find a way to use keys in filesystem
|
2023-12-11 22:37:58 +01:00
|
|
|
# TODO Not relatime everywhere, thank you
|
|
|
|
# TODO Default options
|
|
|
|
let
|
|
|
|
btrfs_args_hdd = [
|
|
|
|
"rw"
|
|
|
|
"relatime"
|
|
|
|
"compress=zstd:3"
|
|
|
|
"space_cache"
|
|
|
|
];
|
|
|
|
btrfs_args_ssd = btrfs_args_hdd ++ [ "ssd" ];
|
2024-02-17 18:39:09 +01:00
|
|
|
passwordFile = "/tmp/dotfiles_${config.networking.hostName}_password";
|
2023-12-11 22:37:58 +01:00
|
|
|
in
|
|
|
|
{
|
2024-02-17 18:39:09 +01:00
|
|
|
boot.loader.efi.efiSysMountPoint = config.disko.devices.disk.razmo.content.partitions.esp.content.mountpoint;
|
2023-12-11 22:37:58 +01:00
|
|
|
disko.devices = {
|
|
|
|
disk = {
|
|
|
|
razmo = {
|
|
|
|
type = "disk";
|
|
|
|
device = "/dev/disk/by-id/ata-ST1000LM048-2E7172_WKP8925H";
|
|
|
|
content = {
|
|
|
|
type = "gpt";
|
|
|
|
partitions = {
|
2023-12-12 20:59:31 +01:00
|
|
|
swap = {
|
2023-12-16 13:51:53 +01:00
|
|
|
priority = 10;
|
2023-12-11 22:37:58 +01:00
|
|
|
start = "2048";
|
2023-12-16 13:51:53 +01:00
|
|
|
size = "6G";
|
2023-12-11 22:37:58 +01:00
|
|
|
content = {
|
|
|
|
type = "swap";
|
|
|
|
randomEncryption = true;
|
|
|
|
# TODO NixOS documentation says not to use this with
|
|
|
|
# hibernation, as it can't set the partition where the
|
|
|
|
# hibernation image is saved. That's what I'm doing with Arch,
|
|
|
|
# but I'm setting resume=, should test if it actually works?
|
|
|
|
# Untranslated options from /etc/crypttab: swap,cipher=aes-xts-plain64,size=256
|
|
|
|
};
|
|
|
|
};
|
2023-12-16 13:51:53 +01:00
|
|
|
nixosboot = {
|
|
|
|
priority = 15;
|
|
|
|
size = "2G";
|
|
|
|
content = {
|
|
|
|
type = "filesystem";
|
|
|
|
format = "vfat";
|
|
|
|
mountpoint = "/boot";
|
|
|
|
};
|
|
|
|
};
|
2023-12-12 20:59:31 +01:00
|
|
|
esp = {
|
2023-12-16 13:51:53 +01:00
|
|
|
priority = 20;
|
2023-12-11 22:37:58 +01:00
|
|
|
size = "128M";
|
|
|
|
type = "EF00"; # EFI system partition
|
|
|
|
content = {
|
|
|
|
type = "filesystem";
|
|
|
|
format = "vfat";
|
|
|
|
mountpoint = "/efi";
|
|
|
|
mountOptions = [
|
|
|
|
"rw"
|
|
|
|
"relatime"
|
|
|
|
"fmask=0022"
|
|
|
|
"dmask=0022"
|
|
|
|
"codepage=437"
|
|
|
|
"iocharset=iso8859-1"
|
|
|
|
"shortname=mixed"
|
|
|
|
"utf8"
|
|
|
|
"errors=remount-ro"
|
|
|
|
"noauto"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2023-12-12 20:59:31 +01:00
|
|
|
boot = {
|
2023-12-16 13:51:53 +01:00
|
|
|
priority = 30;
|
2023-12-11 22:37:58 +01:00
|
|
|
size = "128M";
|
|
|
|
content = {
|
|
|
|
type = "luks";
|
|
|
|
name = "boot";
|
|
|
|
extraFormatArgs = [ "--type luks1" ];
|
2024-01-06 19:10:47 +01:00
|
|
|
passwordFile = passwordFile;
|
2023-12-11 22:37:58 +01:00
|
|
|
settings = {
|
2023-12-16 14:37:23 +01:00
|
|
|
# keyFile = "/etc/keys/boot";
|
2023-12-11 22:37:58 +01:00
|
|
|
};
|
|
|
|
content = {
|
|
|
|
type = "filesystem";
|
|
|
|
format = "ext2";
|
2023-12-12 22:03:36 +01:00
|
|
|
mountpoint = "/mnt/old/boot";
|
2023-12-11 22:37:58 +01:00
|
|
|
mountOptions = [
|
|
|
|
"rw"
|
|
|
|
"relatime"
|
2023-12-16 17:04:29 +01:00
|
|
|
# "stripe=4" # For some reason doesn't work on NixOS
|
2023-12-11 22:37:58 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-12-12 20:59:31 +01:00
|
|
|
main = {
|
2023-12-16 13:51:53 +01:00
|
|
|
priority = 40;
|
2023-12-11 22:37:58 +01:00
|
|
|
content = {
|
|
|
|
type = "luks";
|
|
|
|
name = "razmo";
|
2024-01-06 19:10:47 +01:00
|
|
|
passwordFile = passwordFile;
|
2023-12-11 22:37:58 +01:00
|
|
|
settings = {
|
2023-12-16 14:37:23 +01:00
|
|
|
# keyFile = "/etc/keys/razmo";
|
2023-12-11 22:37:58 +01:00
|
|
|
};
|
|
|
|
content = {
|
|
|
|
type = "btrfs";
|
|
|
|
# extraArgs = [ "-f" ];
|
|
|
|
mountpoint = "/mnt/razmo";
|
|
|
|
mountOptions = btrfs_args_hdd;
|
|
|
|
subvolumes = {
|
|
|
|
"home.razmo" = {
|
|
|
|
mountpoint = "/home.heavy";
|
|
|
|
mountOptions = btrfs_args_hdd;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
rapido = {
|
|
|
|
type = "disk";
|
|
|
|
device = "/dev/disk/by-id/nvme-GIGABYTE_GP-GSM2NE3256GNTD_SN204508906665";
|
|
|
|
content = {
|
|
|
|
type = "gpt";
|
|
|
|
partitions = {
|
2023-12-12 20:59:31 +01:00
|
|
|
swap = {
|
2023-12-16 13:51:53 +01:00
|
|
|
priority = 10;
|
2023-12-11 22:37:58 +01:00
|
|
|
start = "2048";
|
|
|
|
size = "8G";
|
|
|
|
type = "8200"; # Linux swap
|
|
|
|
content = {
|
|
|
|
type = "luks";
|
|
|
|
name = "rapswap";
|
2024-01-06 19:10:47 +01:00
|
|
|
passwordFile = passwordFile;
|
2023-12-11 22:37:58 +01:00
|
|
|
settings = {
|
2023-12-16 14:37:23 +01:00
|
|
|
# keyFile = "/etc/keys/rapswap";
|
2023-12-11 22:37:58 +01:00
|
|
|
allowDiscards = true;
|
|
|
|
};
|
|
|
|
content = {
|
|
|
|
type = "swap";
|
|
|
|
resumeDevice = true;
|
|
|
|
# Untranslated options from /etc/fstab: defaults,pri=100
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-12-12 20:59:31 +01:00
|
|
|
main = {
|
2023-12-16 13:51:53 +01:00
|
|
|
priority = 20;
|
2023-12-11 22:37:58 +01:00
|
|
|
content = {
|
|
|
|
type = "luks";
|
|
|
|
name = "rapido";
|
|
|
|
initrdUnlock = true;
|
2024-01-06 19:10:47 +01:00
|
|
|
passwordFile = passwordFile;
|
2023-12-11 22:37:58 +01:00
|
|
|
settings = {
|
2023-12-16 14:04:24 +01:00
|
|
|
# keyFile = "/etc/keys/rapido";
|
2023-12-11 22:37:58 +01:00
|
|
|
allowDiscards = true;
|
|
|
|
};
|
|
|
|
content = {
|
|
|
|
type = "btrfs";
|
|
|
|
# extraArgs = [ "-f" ];
|
|
|
|
mountpoint = "/mnt/rapido";
|
|
|
|
mountOptions = btrfs_args_ssd;
|
|
|
|
subvolumes = {
|
2023-12-12 22:03:36 +01:00
|
|
|
# Should be temporary, to make sure we can revert to Arch anytime
|
|
|
|
"home.nixos" = {
|
2023-12-11 22:37:58 +01:00
|
|
|
mountpoint = "/home";
|
|
|
|
mountOptions = btrfs_args_ssd;
|
|
|
|
};
|
2023-12-12 22:03:36 +01:00
|
|
|
"home.rapido" = {
|
2023-12-16 13:51:53 +01:00
|
|
|
mountpoint = "/mnt/old/home";
|
2023-12-12 22:03:36 +01:00
|
|
|
mountOptions = btrfs_args_ssd;
|
|
|
|
};
|
2023-12-11 22:37:58 +01:00
|
|
|
nix = {
|
|
|
|
mountpoint = "/nix";
|
|
|
|
mountOptions = btrfs_args_ssd;
|
|
|
|
};
|
2023-12-12 22:03:36 +01:00
|
|
|
nixos = {
|
|
|
|
mountpoint = "/";
|
|
|
|
};
|
2023-12-11 22:37:58 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-03-26 18:28:21 +01:00
|
|
|
services.btrfs.autoScrub = {
|
|
|
|
enable = true;
|
|
|
|
fileSystems = [ "/mnt/razmo" "/mnt/rapido" ];
|
|
|
|
# TODO Should be generable from disko config, right?
|
|
|
|
};
|
2023-12-11 22:37:58 +01:00
|
|
|
}
|