Adding an extend example (helm+oci)

This commit is contained in:
Patrick MARIE 2024-03-24 09:33:05 +01:00
parent 6f0834519e
commit 78894bd3b1
5 changed files with 60 additions and 4 deletions

View File

@ -10,9 +10,10 @@ let
url,
hash ? lib.fakeSha25,
namespace ? "",
patches ? []
patches ? [],
values ? ""
}:
pkgs.stdenv.mkDerivation {
pkgs.stdenv.mkDerivation rec {
inherit name patches;
src = pkgs.fetchurl {
@ -25,12 +26,14 @@ let
"build"
];
namespace = if namespace != "" then "--namespace ${namespace}" else "";
namespaceOpts = if namespace != "" then "--namespace ${namespace}" else "";
valuesOpts = if values != "" then "--values ${values}" else "";
build = ''
mkdir -p $out
${helm} template \
--namespace ${namespace} \
${namespaceOpts} \
${valuesOpts} \
${name} ./ > $out/${name}-${version}.yaml
${helm} version > $out/VERSION
'';

14
poc-helm-oci/default.nix Normal file
View File

@ -0,0 +1,14 @@
{
pkgs ? import <nixpkgs> {}
, lib ? pkgs.lib
, extend ? pkgs.extend
}:
let
extendedAttrs = extend (final: prev: {
localOutputs = {
manifests = final.callPackage ./packages/manifests {};
oci-image = final.callPackage ./packages/oci-image {};
};
});
in
extendedAttrs.localOutputs

View File

@ -0,0 +1,20 @@
{
pkgs
, lib
, helmnix ? import ../../../helm-poc/nix/helm.nix {}
}:
helmnix.mkHelm rec {
name = "cert-manager";
version = "v1.14.4";
url = "https://charts.jetstack.io/charts/${name}-${version}.tgz";
hash = "sha256-V3X9vBiB1uUQ33bTh1OvVLhr0Uyqjtso/bt5UnBC3t4=";
values = ./../../values/cert-manager.yaml;
}
#pkgs.dockerTools.streamLayeredImage {
# name = "oci-image";
# includeStorePaths = false;
# fakeRootCommands = ''
# cp -Lr ${localOutputs.charts}/* .
# rm -fr nix
# '';

View File

@ -0,0 +1,18 @@
{
pkgs,
lib,
localOutputs,
}:
pkgs.dockerTools.streamLayeredImage {
name = "oci-image";
includeStorePaths = false;
fakeRootCommands = ''
cp -Lr ${localOutputs.manifests}/* .
rm -fr nix
'';
# config.Entrypoint = ["${lib.getExe localOutputs.binaries.simple-package}"];
# contents = [
# pkgs.hello
# ];
}

View File

@ -0,0 +1 @@
namespace: testaroo