Unfree package from flake not working

Hi there.

I have an input where I am trying to install.

ALso in my flake I have allowUnfree set with:

nixpkgs.config.allowUnfree = true;

But my rebuild is erroring out with:

error: Package ‘kolide-launcher-1.5.3’ in /nix/store/b3wkw4qyp293wr2m7w5jj62d1i0xx3fm-source/flake.nix:39 has an unfree license (‘unknown’), refusing to evaluate.

       a) To temporarily allow unfree packages, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNFREE=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnfree = true; }
       in configuration.nix to override this.

       Alternatively you can configure a predicate to allow specific packages:
         { nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
             "kolide-launcher-1.5.3"
           ];
         }

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnfree = true; }
       to ~/.config/nixpkgs/config.nix.

I am then rebuilding with sudo nixos-rebuild boot --impure --flake .#\my-host

I cannot figure out why this is failing on this specific package. For example the same config rebuilds the nvidia drivers without error.

Thank you.

Only applies to non-flakes.

What you want to do this is modify this line:

with

specialArgs = { inherit inputs secrets; 
pkgs = import nixpkgs { system = "x86_64-linux"; config.allowUnfree = true;};
};

This will actually override the pkgs attr with the unfree option configured.

So I made the change here on line 71. I am unfortunately still getting the same error.

 # evo = new work laptop hostname
        evo = nixpkgs.lib.nixosSystem {
          # format different due to kolide-launcher
          # nixpkgs.config.allowUnfree = true; only applies to non-flakes.
          specialArgs = {
            inherit inputs secrets;
            pkgs = import nixpkgs {
              system = "x86_64-linux";
              config.allowUnfree = true;
            };
          };
          system = "x86_64-linux";
          modules = [
            ./hosts/evo
            nur.nixosModules.nur
# Snipped

I appreciate the guidance!

I don’t know how to handle this.
It looks like it’s not getting passed down to the kollide flake.

I encountered a similar issue in the past. You don’t want to pass pkgs as specialArgs.

Try moving allowUnfree in a let binding like so:

let
  system = "x86_64-linux";
  pkgs = import nixpkgs {
    inherit system;
    config = { allowUnfree = true; };
  };
in {
  nixosConfigurations = {
    "<yourHostname>" = nixpkgs.lib.nixosSystem {
      inherit system;
      specialArgs = { };
      modules = [
        .configuration.nix
      ];
    };
  };
};

I have yet to test it, but this PR may fix it. It may have been a package issue (I was also working with the vendor on this). When posting here, I wanted to ensure I had not made a dumb mistake with my code.

One option might be to use nixpkgs-unfree by overriding the inputs to it. See 1000 instances of nixpkgs for more info.

1 Like