create module for disk configuration

This commit is contained in:
Pim Kunis 2023-12-16 23:47:18 +01:00
parent 8a7c1ba6a9
commit 04e9ce3abb
4 changed files with 52 additions and 72 deletions

View file

@ -66,7 +66,7 @@
inherit system; inherit system;
specialArgs = { inherit kubenix; }; specialArgs = { inherit kubenix; };
modules = [ modules = [
machine.specificConfig machine.nixosModule
disko.nixosModules.disko disko.nixosModules.disko
agenix.nixosModules.default agenix.nixosModules.default
./configuration.nix ./configuration.nix

View file

@ -3,51 +3,18 @@
name = "jefke"; name = "jefke";
hostname = "jefke.hyp"; hostname = "jefke.hyp";
specificConfig = { nixosModule = {
custom = { custom = {
dataDisk.enable = true; dataDisk.enable = true;
terraformDatabase.enable = true;
k3s.enable = true;
disko.osDiskDevice = "/dev/nvme0n1";
ssh = { ssh = {
useCertificates = true; useCertificates = true;
hostCert = builtins.readFile ./jefke_host_ed25519-cert.pub; hostCert = builtins.readFile ./jefke_host_ed25519-cert.pub;
userCert = builtins.readFile ./jefke_user_ed25519-cert.pub; userCert = builtins.readFile ./jefke_user_ed25519-cert.pub;
}; };
terraformDatabase.enable = true;
k3s.enable = true;
};
disko.devices = {
disk = {
vdb = {
device = "/dev/nvme0n1";
type = "disk";
content = {
type = "gpt";
partitions = {
ESP = {
type = "EF00";
size = "500M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
end = "-4G";
content = {
type = "filesystem";
format = "btrfs";
mountpoint = "/";
};
};
swap = { size = "100%"; };
};
};
};
};
}; };
}; };
}; };
@ -56,46 +23,16 @@
name = "atlas"; name = "atlas";
hostname = "atlas.hyp"; hostname = "atlas.hyp";
specificConfig = { nixosModule = {
custom = { custom = {
disko.osDiskDevice = "/dev/nvme0n1";
ssh = { ssh = {
useCertificates = true; useCertificates = true;
hostCert = builtins.readFile ./atlas_host_ed25519-cert.pub; hostCert = builtins.readFile ./atlas_host_ed25519-cert.pub;
userCert = builtins.readFile ./atlas_user_ed25519-cert.pub; userCert = builtins.readFile ./atlas_user_ed25519-cert.pub;
}; };
}; };
disko.devices = {
disk = {
vdb = {
device = "/dev/nvme0n1";
type = "disk";
content = {
type = "gpt";
partitions = {
ESP = {
type = "EF00";
size = "500M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
end = "-4G";
content = {
type = "filesystem";
format = "btrfs";
mountpoint = "/";
};
};
swap = { size = "100%"; };
};
};
};
};
};
}; };
}; };
} }

View file

@ -1,3 +1,3 @@
{ {
imports = [ ./terraform-database.nix ./data-disk.nix ./ssh-certificates.nix ./k3s ]; imports = [ ./terraform-database.nix ./data-disk.nix ./ssh-certificates.nix ./k3s ./disko.nix ];
} }

43
modules/custom/disko.nix Normal file
View file

@ -0,0 +1,43 @@
{ lib, config, ... }:
let cfg = config.custom.disko;
in {
options = {
custom = {
disko.osDiskDevice = lib.mkOption {
type = lib.types.str;
description = ''
The disk device to be used for the operating system.
'';
};
};
};
# TODO: rename this to 'osDisk'. Unfortunately, we would need to run nixos-anywhere again then
config.disko.devices.disk.vdb = {
device = cfg.osDiskDevice;
type = "disk";
content = {
type = "gpt";
partitions = {
ESP = {
type = "EF00";
size = "500M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
end = "-4G";
content = {
type = "filesystem";
format = "btrfs";
mountpoint = "/";
};
};
swap = { size = "100%"; };
};
};
};
}