hall / kubenix

Kubernetes management with Nix
https://kubenix.org/
MIT License
316 stars 29 forks source link

`nix run .#kubenix`, `error: cannot coerce null to a string` #64

Closed BrainWart closed 5 months ago

BrainWart commented 5 months ago

I am getting the following error when trying to follow the samples in the docs. I was attempting to do everything in a single file as I learned how things work. I've included the flake I created as well.

System:

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'kubenix'
         whose name attribute is located at /nix/store/rbiwpy57k5wag6mvac1s0bh482q79wm1-source/pkgs/stdenv/generic/make-derivation.nix:303:7

       … while evaluating attribute 'buildCommand' of derivation 'kubenix'

         at /nix/store/rbiwpy57k5wag6mvac1s0bh482q79wm1-source/pkgs/build-support/trivial-builders/default.nix:87:14:

           86|       enableParallelBuilding = true;
           87|       inherit buildCommand name;
             |              ^
           88|       passAsFile = [ "buildCommand" ]

       error: cannot coerce null to a string

flake.nix

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/9401a0c780b49faf6c28adf55764f230301d0dce";
    kubenix = {
      url = "github:hall/kubenix";
      inputs = {
        nixpkgs.follows = "nixpkgs";
      };
    };
    systems.url = "github:nix-systems/default-linux";
    flake-utils = {
      url = "github:numtide/flake-utils";
      inputs.systems.follows = "systems";
    };
  };

  outputs = { self, nixpkgs, flake-utils, kubenix, ... } @ inputs:
  flake-utils.lib.eachDefaultSystem (system:
    let pkgs = nixpkgs.legacyPackages.${system}; in
    {
      devShells.default = pkgs.mkShell {
        buildInputs = [
          pkgs.nixd
          pkgs.jq
        ];
      };

      modules.default = { kubenix, ... }: {
        imports = [ kubenix.modules.k8s ];
        kubernetes.resources.pods.example.spec.containers.nginx.image = "nginx";
      };

      packages = {
        default = (kubenix.evalModules.${system} {
          module = self.modules.${system}.default;
        }).config.kubernetes.result;

        kubenix = (kubenix.packages.${system}.default.override {
          module = self.modules.${system}.default;
        });
      };
    }
  );
}
BrainWart commented 5 months ago

took me a good while to figure this out. I dismissed the kubeconfig as an issue because it had been addressed before.