nix-samples/helm-poc/nix/helm.nix

47 lines
880 B
Nix

{
pkgs ? import <nixpkgs> {}
, helm ? "${pkgs.kubernetes-helm}/bin/helm"
, lib ? pkgs.lib
}:
let
mkHelm = {
name,
version,
url,
hash ? lib.fakeSha25,
namespace ? "",
patches ? [],
values ? ""
}:
pkgs.stdenv.mkDerivation rec {
inherit name patches;
src = pkgs.fetchurl {
inherit url hash;
};
phases = [
"unpackPhase"
"patchPhase"
"build"
];
namespaceOpts = if namespace != "" then "--namespace ${namespace}" else "";
valuesOpts = if values != "" then "--values ${values}" else "";
build = ''
mkdir -p $out
${helm} template \
${namespaceOpts} \
${valuesOpts} \
${name} ./ > $out/${name}-${version}.yaml
${helm} version > $out/VERSION
'';
};
nixHelm = {
inherit mkHelm;
};
in
nixHelm