nixos-demo/os/disks.nix
2025-08-10 22:32:31 +02:00

120 lines
2.8 KiB
Nix

{ config, lib, ... }:
{
disko.devices = {
disk = {
disk0 = {
type = "disk";
device = "/dev/${config.beancloud.disk.device.name}";
content = {
type = "gpt";
partitions = {
ESP = {
size = "256M";
type = "EF00";
priority = 1;
content = {
type = "filesystem";
format = "vfat";
extraArgs = [
"-F"
"32"
"-n"
"BOOT"
];
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
lvm = {
size = "100%";
priority = 2;
content = {
type = "lvm_pv";
vg = "nixos";
};
};
};
};
};
};
lvm_vg = {
nixos = {
type = "lvm_vg";
lvs = lib.mkMerge [
{
swap = {
size = "1GB";
content = {
type = "swap";
resumeDevice = true;
priority = 1;
};
};
}
(lib.mkIf (config.beancloud.persistence.root == "fs") {
root = {
size = "100%FREE";
content = {
type = "filesystem";
format = "ext4";
extraArgs = [
"-L"
"root"
"-T"
"news"
"-m"
"1"
];
mountpoint = "/";
mountOptions = [ "defaults" ];
};
};
})
(lib.mkIf (config.beancloud.persistence.root == "tmpfs") {
nix = {
size = "100%FREE";
content = {
type = "filesystem";
format = "ext4";
extraArgs = [
"-L"
"nix"
"-T"
"news"
"-m"
"1"
];
mountpoint = "/nix";
mountOptions = [ "defaults" ];
};
};
})
];
};
};
nodev = lib.mkMerge [
(lib.mkIf (config.beancloud.persistence.root == "fs") {
tmp = {
fsType = "tmpfs";
mountpoint = "/tmp";
mountOptions = [
"size=25%"
];
};
})
(lib.mkIf (config.beancloud.persistence.root == "tmpfs") {
root = {
fsType = "tmpfs";
mountpoint = "/";
mountOptions = [
"defaults"
"size=50%"
"mode=755"
];
};
})
];
};
}