Compare commits

..

2 commits

Author SHA1 Message Date
1e80b36037 Refactor machine logic 2024-11-04 23:35:04 +01:00
fd423b8237 Move kubernetes node labels to k8s repo 2024-11-04 23:17:39 +01:00
11 changed files with 53 additions and 131 deletions

View file

@ -6,14 +6,14 @@
deployArch = "x86_64-linux";
mkDeployNodes = nodeDef:
builtins.mapAttrs
(name: machine: nodeDef name machine)
self.machines.${deployArch};
(name: module: nodeDef name module)
self.machines;
in {
deploy = {
sshUser = "root";
user = "root";
nodes = mkDeployNodes (name: machine: let
nodes = mkDeployNodes (name: _module: let
nixosConfiguration = self.nixosConfigurations.${name};
machineArch = nixosConfiguration.config.facter.report.system;
in {

View file

@ -1,8 +1,4 @@
{
machines.atlas = {
kubernetesNodeLabels.storageType = "slow";
nixosModule = {
facter.reportPath = ./facter.json;
lab = {
@ -14,6 +10,4 @@
serverAddr = "https://jefke.dmz:6443";
};
};
};
};
}

View file

@ -1,51 +1,8 @@
{
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
machineOpts = {config, ...}: {
options = {
nixosModule = lib.mkOption {
default = {...}: {};
type = lib.types.anything;
description = ''
Customized configuration for this machine in the form of a NixOS module.
'';
{...}: {
machines = {
atlas = import ./atlas;
jefke = import ./jefke;
lewis = import ./lewis;
warwick = import ./warwick;
};
kubernetesNodeLabels = lib.mkOption {
default = null;
type = with lib.types; nullOr attrs;
description = ''
Any labels to add to the Kubernetes node.
'';
};
};
};
allOpts = {
options = {
machines = lib.mkOption {
type = with lib.types; attrsOf (submodule machineOpts);
};
};
};
in {
machines =
(lib.modules.evalModules {
modules = [
allOpts
./warwick
./atlas
./jefke
./lewis
# ./talos.nix
];
})
.config
.machines;
})
}

View file

@ -1,8 +1,4 @@
{
machines.jefke = {
kubernetesNodeLabels.storageType = "fast";
nixosModule = {
facter.reportPath = ./facter.json;
lab = {
@ -14,6 +10,4 @@
clusterInit = true;
};
};
};
};
}

View file

@ -1,11 +1,4 @@
{
machines.lewis = {
kubernetesNodeLabels = {
storageType = "fast";
hasMedia = "true";
};
nixosModule = {
facter.reportPath = ./facter.json;
lab = {
@ -19,6 +12,4 @@
serverAddr = "https://jefke.dmz:6443";
};
};
};
};
}

View file

@ -1,9 +0,0 @@
{
machines.talos = {
nixosModule = {lib, ...}: {
lab.storage.profile = "normal";
# boot.loader.systemd-boot.enable = lib.mkForce false;
};
};
}

View file

@ -1,6 +1,4 @@
{
machines.warwick = {
nixosModule = {inputs, ...}: {
{inputs, ...}: {
imports = [inputs.nixos-hardware.nixosModules.raspberry-pi-4];
config = {
@ -16,6 +14,4 @@
};
};
};
};
};
}

View file

@ -3,7 +3,6 @@
pkgs,
lib,
inputs,
machine,
config,
...
}: {
@ -16,7 +15,6 @@
./k3s
./tailscale.nix
./facter.nix
machine.nixosModule
inputs.disko.nixosModules.disko
inputs.sops-nix.nixosModules.sops
inputs.nix-snapshotter.nixosModules.nix-snapshotter

View file

@ -38,7 +38,7 @@ in {
let
generated =
lib.attrsets.mapAttrsToList
(name: machine: {
(name: _module: {
job_name = name;
static_configs = [
{

View file

@ -1,7 +1,6 @@
{
lib,
config,
machine,
...
}: {
config = {

View file

@ -3,22 +3,24 @@
nixpkgs,
...
} @ inputs: let
deployArch = "x86_64-linux";
machines = self.machines.${deployArch};
mkNixosSystems = systemDef:
builtins.mapAttrs
(
name: machine:
nixpkgs.lib.nixosSystem (systemDef name machine)
name: module:
nixpkgs.lib.nixosSystem (systemDef name module)
)
machines;
self.machines;
in {
nixosConfigurations = mkNixosSystems (name: machine: {
specialArgs = {inherit self inputs machine machines;};
nixosConfigurations = mkNixosSystems (name: module: {
specialArgs = {
inherit self inputs;
inherit (self) machines;
};
modules = [
"${self}/modules"
{networking.hostName = name;}
module
];
});
}