From 0c52c5655e917ca4afede2a4b0b4dee15e0d5a5e Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 10 Feb 2023 01:17:10 +0100 Subject: [PATCH] use deployment flake for cluster options --- flake.lock | 21 ++++++++ flake.nix | 10 +++- modules/cluster/customization/default.nix | 2 - .../cluster/customization/option-types.nix | 42 --------------- modules/cluster/customization/options.nix | 53 ------------------- 5 files changed, 29 insertions(+), 99 deletions(-) delete mode 100644 modules/cluster/customization/option-types.nix delete mode 100644 modules/cluster/customization/options.nix diff --git a/flake.lock b/flake.lock index 03a7e805..262606f4 100644 --- a/flake.lock +++ b/flake.lock @@ -208,6 +208,26 @@ "url": "https://gitea.c3d2.de/astro/caveman.git" } }, + "deployment": { + "inputs": { + "zentralwerk": [ + "zentralwerk" + ] + }, + "locked": { + "lastModified": 1675987794, + "narHash": "sha256-3R2+WvqIYFNGxeuIXDRFCfHVYtHmJZ8oTVcp/b6YQZA=", + "ref": "refs/heads/main", + "rev": "631c31f921e13c8373d39e74f99e45d5c47e4c4d", + "revCount": 1, + "type": "git", + "url": "https://gitea.c3d2.de/C3D2/deployment.git" + }, + "original": { + "type": "git", + "url": "https://gitea.c3d2.de/C3D2/deployment.git" + } + }, "fenix": { "inputs": { "nixpkgs": [ @@ -512,6 +532,7 @@ "buzzrelay": "buzzrelay", "c3d2-user-module": "c3d2-user-module", "caveman": "caveman", + "deployment": "deployment", "fenix": "fenix", "flake-parts": "flake-parts", "flake-utils": "flake-utils", diff --git a/flake.nix b/flake.nix index 3ee14b8e..44212961 100644 --- a/flake.nix +++ b/flake.nix @@ -81,6 +81,12 @@ nixpkgs-lib.follows = "nixos"; }; }; + deployment = { + url = "git+https://gitea.c3d2.de/C3D2/deployment.git"; + inputs = { + zentralwerk.follows = "zentralwerk"; + }; + }; fenix = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixos"; @@ -215,7 +221,7 @@ }; }; - outputs = inputs@{ self, alert2muc, c3d2-user-module, fenix, harmonia, heliwatch, microvm, naersk, nixos, nixos-hardware, nixos-modules, buzz2elastic, buzzrelay, caveman, oparl-scraper, scrapers, secrets, skyflake, sshlogd, sops-nix, spacemsg, ticker, tigger, yammat, zentralwerk, ... }: + outputs = inputs@{ self, alert2muc, c3d2-user-module, deployment, fenix, harmonia, heliwatch, microvm, naersk, nixos, nixos-hardware, nixos-modules, buzz2elastic, buzzrelay, caveman, oparl-scraper, scrapers, secrets, skyflake, sshlogd, sops-nix, spacemsg, ticker, tigger, yammat, zentralwerk, ... }: let inherit (nixos) lib; @@ -770,7 +776,7 @@ c3d2.nncp.neigh = import ./modules/nncp-relays.nix; }; cluster = ./modules/cluster; - cluster-options = ./modules/cluster/customization/options.nix; + cluster-options = deployment.nixosModules.deployment-options; cluster-network = ./modules/cluster/network.nix; microvm.imports = [ microvm.nixosModules.microvm diff --git a/modules/cluster/customization/default.nix b/modules/cluster/customization/default.nix index f448386a..5bae7c7b 100644 --- a/modules/cluster/customization/default.nix +++ b/modules/cluster/customization/default.nix @@ -29,8 +29,6 @@ let in { - imports = [ ./option-types.nix ]; - microvm = { inherit (config.deployment) mem vcpu hypervisor; diff --git a/modules/cluster/customization/option-types.nix b/modules/cluster/customization/option-types.nix deleted file mode 100644 index 9de1034a..00000000 --- a/modules/cluster/customization/option-types.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ lib, ... }: - -{ - options.deployment = with lib; { - vcpu = mkOption { - type = types.int; - }; - mem = mkOption { - type = types.int; - }; - hypervisor = mkOption { - type = types.enum [ - "qemu" - "cloud-hypervisor" - "firecracker" - "crosvm" - "kvmtool" - ]; - }; - networks = mkOption { - type = with types; listOf str; - }; - persistedShares = mkOption { - type = with types; listOf str; - }; - extraShares = mkOption { - type = with types; listOf (submodule { - options = { - source = mkOption { - type = str; - }; - mountPoint = mkOption { - type = str; - }; - }; - }); - }; - needForSpeed = mkOption { - type = types.bool; - }; - }; -} diff --git a/modules/cluster/customization/options.nix b/modules/cluster/customization/options.nix deleted file mode 100644 index 887550d1..00000000 --- a/modules/cluster/customization/options.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ zentralwerk, config, lib, ... }: -# our custom options -# -# IF ANYBODY changes anything in this customization for skyflake -# please give notice in the admins chat prior to doing so -{ - options.deployment = with lib; { - vcpu = mkOption { - default = 4; - }; - mem = mkOption { - default = 512; - }; - hypervisor = mkOption { - default = "cloud-hypervisor"; - }; - 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 - ); - }; - persistedShares = mkOption { - default = [ "/etc" "/home" "/var" ]; - }; - extraShares = mkOption { - default = []; - description = '' - Extra shares. THESE MUST BE AVAILABLE ON ALL MICROVM HOSTS! - ''; - }; - needForSpeed = mkOption { - default = false; - description = '' - Prefer deployment on Nomad clients with a higher c3d2.cpuSpeed - ''; - }; - }; - - config = { - # HACK: Avoid conflicts when building a NixOS configuration on Hydra - boot.loader.grub.enable = false; - fileSystems."/" = lib.mkDefault { - device = "rootfs"; - fsType = "tmpfs"; - options = [ "size=50%,mode=0755" ]; - }; - }; -}