flake/nixos/flake-modules/disko.nix

83 lines
2.3 KiB
Nix
Raw Normal View History

2023-10-12 14:21:14 +00:00
{
inputs,
disks ? ["/dev/sda"],
...
}: {
imports = [inputs.disko.nixosModules.disko];
2023-10-12 14:21:14 +00:00
disko.devices = {
disk = {
"one" = {
type = "disk";
device = builtins.elemAt disks 0;
content = {
type = "gpt";
partitions = {
"ESP" = {
2023-10-12 14:21:14 +00:00
size = "2G";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"defaults"
"fmask=0077"
"dmask=0077"
2023-10-12 14:21:14 +00:00
];
};
};
"luks" = {
2023-10-12 14:21:14 +00:00
#size = "100%";
end = "-16G";
content = {
type = "luks";
name = "crypted";
extraOpenArgs = ["--allow-discards"];
2023-10-12 14:21:14 +00:00
# if you want to use the key for interactive login be sure there is no trailing newline
# for example use `echo -n "password" > /tmp/secret.key`
passwordFile = "/tmp/secret.key"; # Interactive
#settings.keyFile = "/tmp/secret.key";
#additionalKeyFiles = [ "/tmp/additionalSecret.key" ];
content = {
type = "btrfs";
extraArgs = ["-f"];
2023-10-12 14:21:14 +00:00
mountpoint = "/btrfs";
subvolumes = {
"/@home" = {
mountpoint = "/home";
mountOptions = ["compress=zstd" "noatime"];
2023-10-12 14:21:14 +00:00
};
"/@nix" = {
mountpoint = "/nix";
mountOptions = ["compress=zstd" "noatime"];
2023-10-12 14:21:14 +00:00
};
};
};
};
};
"swap" = {
2023-10-12 14:21:14 +00:00
size = "100%";
content = {
type = "swap";
randomEncryption = true;
resumeDevice = true; # resume from hiberation from this device
};
};
};
};
};
};
nodev = {
"/" = {
fsType = "tmpfs";
mountOptions = [
"size=2G"
"defaults"
"mode=755"
];
};
};
};
}