nixos-servers/nixos-modules/storage.nix

123 lines
2.6 KiB
Nix
Raw Normal View History

2024-01-28 10:48:13 +00:00
{ lib, config, machine, ... }:
2024-01-06 23:22:44 +00:00
let cfg = config.lab.storage;
in {
options.lab.storage = {
osDisk = lib.mkOption {
2024-02-29 19:59:48 +00:00
type = with lib.types; nullOr str;
2024-01-06 23:22:44 +00:00
description = ''
The disk to be used for the machine's operating system.
'';
};
};
2024-02-27 22:28:52 +00:00
config = {
fileSystems."/" = lib.mkIf machine.isRaspberryPi {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
options = [ "noatime" ];
};
disko = lib.mkIf (! machine.isRaspberryPi) {
devices = {
disk = {
nvme = {
device = "/dev/nvme0n1";
type = "disk";
content = {
type = "gpt";
partitions = {
boot = {
type = "EF00";
size = "500M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
pv_os = {
size = "79G";
content = {
type = "lvm_pv";
vg = "vg_os";
};
};
pv_nvme_extra = {
size = "100%";
content = {
type = "lvm_pv";
vg = "vg_data";
};
};
};
};
};
sata = {
device = "/dev/sda";
type = "disk";
content = {
type = "gpt";
partitions.pv_sata = {
size = "100%";
content = {
type = "lvm_pv";
vg = "vg_data";
};
};
};
};
2024-02-27 22:28:52 +00:00
};
2024-01-06 23:22:44 +00:00
lvm_vg = {
vg_os = {
type = "lvm_vg";
lvs = {
root = {
size = "75G";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
mountOptions = [ "defaults" ];
};
};
swap = {
size = "100%FREE";
content.type = "swap";
};
};
};
vg_data = {
type = "lvm_vg";
lvs.longhorn = {
size = "100%FREE";
content = {
type = "filesystem";
format = "xfs";
mountpoint = "/mnt/longhorn";
};
};
};
};
};
};
2024-01-06 23:22:44 +00:00
};
}