Every krew plugin for kubectl as a flake.nix

Why not just make an overlay that your flake.nix consumes/reexports so the project is stable Nix-compatible?

2 Likes

How would that be done?

Do you mean like this?

  # overlay.nix
  final: prev: {
    krewPlugins = prev.lib.mapAttrs
      (name: spec: prev.callPackage ./plugin.nix { inherit name spec; })
      (prev.lib.importJSON ./plugins.json);   # whatever your generated data is
  }

  # flake.nix
  {
    outputs = { self, nixpkgs }: {
      overlays.default = import ./overlay.nix;
    } // nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-darwin" /* ... */ ] (system: {
      packages.${system} = (import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }).krewPlugins;
    });
  }
1 Like

I just updated it to support the following syntax, if that’s what you mean.

nixpkgs.overlays = [ inputs.krew-nix.overlays.default ];
environment.systemPackages = [ pkgs.krew-plugins.popeye ];
1 Like

This makes me so happy. I built my own implementation to scratch a personal itch, but yours is far better in every way :trophy: