Refactor storage module
Add talos and pikvm machines
This commit is contained in:
parent
0539d35678
commit
55b18ef450
12 changed files with 234 additions and 123 deletions
|
@ -1,27 +1,126 @@
|
|||
{ lib, config, machine, ... }:
|
||||
let cfg = config.lab.storage;
|
||||
in {
|
||||
options.lab.storage = {
|
||||
osDisk = lib.mkOption {
|
||||
type = with lib.types; nullOr str;
|
||||
description = ''
|
||||
The disk to be used for the machine's operating system.
|
||||
'';
|
||||
};
|
||||
};
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
cfg = config.lab.storage;
|
||||
modules = [
|
||||
{
|
||||
config = lib.mkIf (cfg.profile == "pi") {
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/NIXOS_SD";
|
||||
fsType = "ext4";
|
||||
options = [ "noatime" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
config = {
|
||||
fileSystems."/" = lib.mkIf machine.isRaspberryPi {
|
||||
device = "/dev/disk/by-label/NIXOS_SD";
|
||||
fsType = "ext4";
|
||||
options = [ "noatime" ];
|
||||
};
|
||||
{
|
||||
config = lib.mkIf (cfg.profile == "kubernetes") {
|
||||
disko.devices = {
|
||||
disk = {
|
||||
nvme = {
|
||||
device = "/dev/nvme0n1";
|
||||
type = "disk";
|
||||
|
||||
disko = lib.mkIf (! machine.isRaspberryPi) {
|
||||
devices = {
|
||||
disk = {
|
||||
nvme = {
|
||||
device = "/dev/nvme0n1";
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
config = lib.mkIf (cfg.profile == "normal") {
|
||||
disko.devices = {
|
||||
disk.sata = {
|
||||
device = "/dev/sda";
|
||||
type = "disk";
|
||||
|
||||
content = {
|
||||
|
@ -39,84 +138,30 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
pv_os = {
|
||||
size = "79G";
|
||||
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "vg_os";
|
||||
};
|
||||
};
|
||||
|
||||
pv_nvme_extra = {
|
||||
root = {
|
||||
size = "100%";
|
||||
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "vg_data";
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = [ "defaults" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
sata = {
|
||||
device = "/dev/sda";
|
||||
type = "disk";
|
||||
|
||||
content = {
|
||||
type = "gpt";
|
||||
|
||||
partitions.pv_sata = {
|
||||
size = "100%";
|
||||
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "vg_data";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
in
|
||||
{
|
||||
imports = modules;
|
||||
|
||||
options.lab.storage = {
|
||||
profile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Reference in a new issue