farcaller/nixhelm

Support for paths within Git repos

heywoodlh opened this issue · 3 comments

First off, thanks for the awesome repo!

Was wondering how feasible it would be to add subpaths to Helm charts within a Git repo. For example, the Tailscale Kubernetes Operator lives in the tailscale/tailscale repo in the (annoyingly deep) path cmd/k8s-operator/deploy/chart.

Is there any way that helmupdater could be updated to also support paths within a git repository?

Thanks! 😄

nixhelm only supports the [legacy] http chart repos. But with tailscale chart in git it might be actually simpler to use it directly.

You don't need to call into downloadHelmChart, instead you can pull in the tailscale repo as your flake input, (with flake = false). This way you pin the chart against your flake and you can update it using nix. If you pass the target directory to buildHelmChart, that should be sufficient for it to build.

Awesome, that worked perfectly! Thanks for the suggestion. Here's a snippet for anyone interested in what it looks like in implementation:

{
  description = "heywoodlh kubernetes flake";

  inputs.nixpkgs.url = "github:NixOS/nixpkgs";
  inputs.flake-utils.url = "github:numtide/flake-utils";
  inputs.nix-kube-generators.url = "github:farcaller/nix-kube-generators";
  inputs.nixhelm.url = "github:farcaller/nixhelm";
  inputs.tailscale.url = "github:tailscale/tailscale";

  outputs = inputs @ {
    self,
    nixpkgs,
    flake-utils,
    nix-kube-generators,
    nixhelm,
    tailscale,
  }:
    flake-utils.lib.eachDefaultSystem (system: let
      pkgs = import nixpkgs {
        inherit system;
        config.allowUnfree = true;
      };
      kubelib = nix-kube-generators.lib { inherit pkgs; };
    in {
      packages = {
        tailscale-operator = (kubelib.buildHelmChart {
          name = "tailscale-operator";
          chart = "${tailscale}/cmd/k8s-operator/deploy/chart";
          namespace = "kube-system";
        });
      };

      devShell = pkgs.mkShell {
        name = "kubernetes-shell";
        buildInputs = with pkgs; [
          kubectl
          kubernetes-helm
        ];
      };
      formatter = pkgs.alejandra;
    });
}

Thanks for the snippet, added the reference to the README in 9a82c80.