mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-03-31 22:53:06 +02:00
refactor: Use hyphen(`-`) for variable names & folder names(except Python), replace all unserscore(`_`) with hyphen(`-`).
103 lines
3.4 KiB
Nix
103 lines
3.4 KiB
Nix
{
|
|
# required by impermanence
|
|
fileSystems."/persistent".neededForBoot = true;
|
|
|
|
disko.devices = {
|
|
nodev."/" = {
|
|
fsType = "tmpfs";
|
|
mountOptions = [
|
|
"size=2G"
|
|
"defaults"
|
|
# set mode to 755, otherwise systemd will set it to 777, which cause problems.
|
|
# relatime: Update inode access times relative to modify or change time.
|
|
"mode=755"
|
|
];
|
|
};
|
|
|
|
# TODO: rename to main
|
|
disk.sda = {
|
|
type = "disk";
|
|
# When using disko-install, we will overwrite this value from the commandline
|
|
device = "/dev/nvme0n1"; # The device to partition
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
# The EFI & Boot partition
|
|
ESP = {
|
|
size = "630M";
|
|
type = "EF00";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "vfat";
|
|
mountpoint = "/boot";
|
|
mountOptions = [
|
|
"defaults"
|
|
];
|
|
};
|
|
};
|
|
# The root partition
|
|
luks = {
|
|
size = "100%";
|
|
content = {
|
|
type = "luks";
|
|
name = "crypted";
|
|
settings = {
|
|
keyFile = "/dev/disk/by-label/OPI5_DSC"; # The keyfile is stored on a USB stick
|
|
# The maxium size of the keyfile is 8192 bytes
|
|
keyFileSize = 512 * 64; # match the `bs * count` of the `dd` command
|
|
keyFileOffset = 512 * 128; # match the `bs * skip` of the `dd` command
|
|
fallbackToPassword = true;
|
|
allowDiscards = true;
|
|
};
|
|
# Whether to add a boot.initrd.luks.devices entry for the specified disk.
|
|
initrdUnlock = true;
|
|
|
|
# encrypt the root partition with luks2 and argon2id, will prompt for a passphrase, which will be used to unlock the partition.
|
|
# cryptsetup luksFormat
|
|
extraFormatArgs = [
|
|
"--type luks2"
|
|
"--cipher aes-xts-plain64"
|
|
"--hash sha512"
|
|
"--iter-time 5000"
|
|
"--key-size 256"
|
|
"--pbkdf argon2id"
|
|
# use true random data from /dev/random, will block until enough entropy is available
|
|
"--use-random"
|
|
];
|
|
extraOpenArgs = [
|
|
"--timeout 10"
|
|
];
|
|
content = {
|
|
type = "btrfs";
|
|
extraArgs = ["-f"];
|
|
subvolumes = {
|
|
"@nix" = {
|
|
mountpoint = "/nix";
|
|
mountOptions = ["compress-force=zstd:1" "noatime"];
|
|
};
|
|
"@persistent" = {
|
|
mountpoint = "/persistent";
|
|
mountOptions = ["compress-force=zstd:1" "noatime"];
|
|
};
|
|
"@tmp" = {
|
|
mountpoint = "/tmp";
|
|
mountOptions = ["compress-force=zstd:1" "noatime"];
|
|
};
|
|
"@snapshots" = {
|
|
mountpoint = "/snapshots";
|
|
mountOptions = ["compress-force=zstd:1" "noatime"];
|
|
};
|
|
"@swap" = {
|
|
mountpoint = "/swap";
|
|
swap.swapfile.size = "8192M";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|