From 29f9361073051e8d45d14323542059165690d4bc Mon Sep 17 00:00:00 2001 From: Patrick MARIE Date: Wed, 20 Mar 2024 23:30:01 +0100 Subject: [PATCH] Adding a POC around helm --- .gitignore | 3 +-- helm-poc/default.nix | 25 +++++++++++++++++++++++++ helm-poc/nix/helm.nix | 31 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 helm-poc/default.nix create mode 100644 helm-poc/nix/helm.nix diff --git a/.gitignore b/.gitignore index 4c8c616..fcfc4a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -result - +result* diff --git a/helm-poc/default.nix b/helm-poc/default.nix new file mode 100644 index 0000000..f3dfe61 --- /dev/null +++ b/helm-poc/default.nix @@ -0,0 +1,25 @@ +{ + pkgs ? import {} +, helmnix ? import ./nix/helm.nix {} +, lib ? pkgs.lib +}: +let + charts = [ + rec { + name = "kube-prometheus-stack"; + version = "57.0.3"; + url = "https://github.com/prometheus-community/helm-charts/releases/download/${name}-${version}/${name}-${version}.tgz"; + hash = "sha256-oZNaFSfFR2dtf5IMUQ0CnXQeVLvoW22JdRqMmgmdtTs="; + } + rec { + name = "cert-manager"; + version = "v1.14.4"; + url = "https://charts.jetstack.io/charts/${name}-${version}.tgz"; + hash = "sha256-V3X9vBiB1uUQ33bTh1OvVLhr0Uyqjtso/bt5UnBC3t4="; + } + ]; + + packages = builtins.map (chart: helmnix.mkHelm chart) charts; +in + packages + diff --git a/helm-poc/nix/helm.nix b/helm-poc/nix/helm.nix new file mode 100644 index 0000000..d0670af --- /dev/null +++ b/helm-poc/nix/helm.nix @@ -0,0 +1,31 @@ +{ + pkgs ? import {} +, helm ? "${pkgs.kubernetes-helm}/bin/helm" +, lib ? pkgs.lib +}: +let + mkHelm = { name, version, url, hash ? lib.fakeSha256 }: + pkgs.stdenv.mkDerivation { + inherit name; + + src = pkgs.fetchurl { + inherit url hash; + }; + + phases = [ + "unpackPhase" + "build" + ]; + + build = '' + mkdir -p $out + ${helm} template ${name} ./ > $out/${name}-${version}.yaml + #${helm} version > $out/README + ''; + }; + + nixHelm = { + inherit mkHelm; + }; +in + nixHelm