From 232b89609b9ed64a1b3a4f1596ea162f673721c0 Mon Sep 17 00:00:00 2001 From: Tristan Schrader Date: Mon, 1 Jul 2024 16:46:47 -0700 Subject: [PATCH] fix: patch kubenix Relax requirement of required protocol in Container.ports because some upstream sources, like Prometheus charts, don't actually specify it. https://github.com/hall/kubenix/issues/52 --- modules/kubenix.nix | 17 ++++++++++++++--- modules/kubenix.patch | 5 +++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 modules/kubenix.patch diff --git a/modules/kubenix.nix b/modules/kubenix.nix index 85f1fa4..21af843 100644 --- a/modules/kubenix.nix +++ b/modules/kubenix.nix @@ -9,7 +9,18 @@ with nix; { pkgs, system, ... - }: { + }: let + # TODO is there an even simpler way to do this? + kubenix-patched = pkgs.stdenv.mkDerivation rec { + inherit (src) name; + src = inputs.kubenix; + patches = [./kubenix.patch]; + buildPhase = '' + mkdir -p $out + cp -r $src/* $out + ''; + }; + in { config.canivete.devShell.apps.kubectl.script = "nix run \".#canivete.${system}.kubenix.clusters.$1.script\" -- \"\${@:2}\""; config.canivete.opentofu.workspaces = mapAttrs (_: getAttr "opentofu") config.canivete.kubenix.clusters; options.canivete.kubenix.clusters = mkOption { @@ -39,7 +50,7 @@ with nix; { type = package; description = "Kubernetes configuration file for cluster"; default = - (inputs.kubenix.evalModules.${system} { + (kubenix-patched.evalModules.${system} { specialArgs = {inherit nix;}; module = { kubenix, @@ -77,7 +88,7 @@ with nix; { # Generate resource definitions with IFD x 2 definitions = let - generated = import "${inputs.kubenix}/pkgs/generators/k8s" { + generated = import "${kubenix-patched}/pkgs/generators/k8s" { name = "kubenix-generated-for-crds"; inherit pkgs lib; # Mirror K8s OpenAPI spec diff --git a/modules/kubenix.patch b/modules/kubenix.patch new file mode 100644 index 0000000..4de4821 --- /dev/null +++ b/modules/kubenix.patch @@ -0,0 +1,5 @@ +--- a/modules/generated/v1.30.nix ++++ a/modules/generated/v1.30.nix +@@ -6305,1 +6305,1 @@ +- type = (types.nullOr (coerceAttrsOfSubmodulesToListByKey "io.k8s.api.core.v1.ContainerPort" "name" [ "containerPort" "protocol" ])); ++ type = (types.nullOr (coerceAttrsOfSubmodulesToListByKey "io.k8s.api.core.v1.ContainerPort" "name" [ "containerPort" ]));