This commit is contained in:
Astro 2023-02-10 01:09:54 +01:00
commit 631c31f921
3 changed files with 164 additions and 0 deletions

85
flake.lock Normal file
View File

@ -0,0 +1,85 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1674242456,
"narHash": "sha256-yBy7rCH7EiBe9+CHZm9YB5ii5GRa+MOxeW0oDEBO8SE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cdead16a444a3e5de7bc9b0af8e198b11bb01804",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "release-22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"openwrt": {
"flake": false,
"locked": {
"lastModified": 1674227662,
"narHash": "sha256-MtkO4sbP+75B9j2oW0/JFvosWQh8H0S95VJ3r0wl+xk=",
"ref": "openwrt-22.03",
"rev": "1bead4c521b6f6cf711fd06398d54b1a6fbbef96",
"revCount": 54502,
"type": "git",
"url": "https://git.openwrt.org/openwrt/openwrt.git"
},
"original": {
"ref": "openwrt-22.03",
"type": "git",
"url": "https://git.openwrt.org/openwrt/openwrt.git"
}
},
"openwrt-imagebuilder": {
"inputs": {
"nixpkgs": [
"zentralwerk",
"nixpkgs"
]
},
"locked": {
"lastModified": 1674207776,
"narHash": "sha256-XfIWLKlpFSBNqzx8Nf0hUZGOK0HhBTaFjmtsdkMnY/A=",
"owner": "astro",
"repo": "nix-openwrt-imagebuilder",
"rev": "f9b70efd4254e905a700361e3052fc4860dda73c",
"type": "github"
},
"original": {
"owner": "astro",
"repo": "nix-openwrt-imagebuilder",
"type": "github"
}
},
"root": {
"inputs": {
"zentralwerk": "zentralwerk"
}
},
"zentralwerk": {
"inputs": {
"nixpkgs": "nixpkgs",
"openwrt": "openwrt",
"openwrt-imagebuilder": "openwrt-imagebuilder"
},
"locked": {
"lastModified": 1675021988,
"narHash": "sha256-cU0DuLUkR+t4H7B5A0ePq0/qvZ0QOxyTkieczSdQU78=",
"ref": "refs/heads/master",
"rev": "f7f3ec5b269116d5cec2e53b492e248331f07688",
"revCount": 1741,
"type": "git",
"url": "https://gitea.c3d2.de/zentralwerk/network.git"
},
"original": {
"type": "git",
"url": "https://gitea.c3d2.de/zentralwerk/network.git"
}
}
},
"root": "root",
"version": 7
}

15
flake.nix Normal file
View File

@ -0,0 +1,15 @@
{
description = "C3D2 cluster deployment options";
inputs = {
zentralwerk = {
url = "git+https://gitea.c3d2.de/zentralwerk/network.git";
};
};
outputs = { self, zentralwerk, ... }: {
nixosModules.deployment-options = import ./options.nix {
inherit zentralwerk;
};
};
}

64
options.nix Normal file
View File

@ -0,0 +1,64 @@
{ zentralwerk }:
{ config, lib, ... }:
{
options.deployment = with lib; {
vcpu = mkOption {
default = 4;
type = types.int;
};
mem = mkOption {
default = 512;
type = types.int;
};
hypervisor = mkOption {
default = "cloud-hypervisor";
type = types.enum [
"qemu"
"cloud-hypervisor"
"firecracker"
"crosvm"
"kvmtool"
];
};
networks = mkOption {
default = builtins.attrNames (
lib.filterAttrs (_: { hosts4, hosts6, ... }:
hosts4 ? ${config.networking.hostName} ||
lib.filterAttrs (_: hosts6:
hosts6 ? ${config.networking.hostName}
) hosts6 != {}
) zentralwerk.lib.config.site.net
);
type = with types; listOf str;
};
persistedShares = mkOption {
default = [ "/etc" "/home" "/var" ];
type = with types; listOf str;
};
extraShares = mkOption {
default = [];
type = with types; listOf (submodule {
options = {
source = mkOption {
type = str;
};
mountPoint = mkOption {
type = str;
};
};
});
description = ''
Extra shares. THESE MUST BE AVAILABLE ON ALL MICROVM HOSTS!
'';
};
needForSpeed = mkOption {
default = false;
type = types.bool;
description = ''
Prefer deployment on Nomad clients with a higher c3d2.cpuSpeed
'';
};
};
}