allowUnfreePredicate woking on one machine but not the other

Hello, so I have an issue very similar to this other issue but its solution does not match my circumstances

I have a laptop and a home computer that both share a file called global.nix. This file contains this:

    nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    #Doesnt install, just allows
            "obsidian"
            "spotify"
            "steam"
            "discord"
        ];

That will build just fine on my laptop but will give me errors like this on my pc:

       error: Package ā€˜steam-unwrapped-1.0.0.85’ in /nix/store/g02rq8ap30x3fp8zrz07ip5v1s0pzidn-source/pkgs/by-name/st/steam-unwrapped/package.nix:47 has an unfree license (ā€˜unfreeRedistributable’), 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
...

(I have tried to add steam-unwrapped-1.0.0.85 but that doesn’t work either)

I wouldnt like to rely on nixpkgs.config.allowUnfree = true; as I want to choose what non-free software goes into my computer

Both flakes are almost identical:

reduced flake.nix (pc)
{
    description = "Flake for Home-manager and shi";

    inputs = {
        nixpkgs.url = "nixpkgs/nixos-unstable";
        nixpkgs-stable.url = "nixpkgs/nixos-25.05";

        home-manager = {
            url = "github:nix-community/home-manager/master";
            #url = "github:nix-community/home-manager/release-25.05";
            inputs.nixpkgs.follows = "nixpkgs";
        };

    };

    outputs = {
        self,
        nixpkgs,
        home-manager,
        ...
    } @ inputs: let
        lib = nixpkgs.lib;
        system = "x86_64-linux";
        pkgs = nixpkgs.legacyPackages.${system};
    in {
        nixosConfigurations = {
            yamask = lib.nixosSystem {
                specialArgs = {inherit inputs system;};
                modules = [
                    ./configuration.nix
                ];
            };
        };

        homeConfigurations = {
            yamask = home-manager.lib.homeManagerConfiguration {
                inherit pkgs;
                modules = [
                    ./home.nix
                ];

                extraSpecialArgs = {
                    inputs = builtins.removeAttrs inputs ["self"];
                };
            };
        };
    };
}

and

flake.nix (laptop)
{
    description = "Flake for Home-manager and shi";

    inputs = {
        nixpkgs.url = "nixpkgs/nixos-unstable";
        nixpkgs-stable.url = "nixpkgs/nixos-25.05";

        home-manager = {
            #url = "github:nix-community/home-manager/release-25.05";
            url = "github:nix-community/home-manager/master";
            inputs.nixpkgs.follows = "nixpkgs"; # Check if the versions are the same
        };
    };

    outputs = {
        self,
        nixpkgs,
        home-manager
        ...
    } @ inputs:
    let
        lib = nixpkgs.lib;
        system = "x86_64-linux";
        pkgs = nixpkgs.legacyPackages.${system};
    in {
        nixosConfigurations = {
            dwebble = lib.nixosSystem {
                specialArgs = {inherit inputs system;};
                modules = [
                    ./configuration.nix
                ];
            };
        };

        homeConfigurations = {
            dwebble = home-manager.lib.homeManagerConfiguration {
                inherit pkgs;
                modules = [
                    ./home.nix
                ];

                extraSpecialArgs = {
                    inputs = builtins.removeAttrs inputs ["self"];
                };
            };
        };
    };
}

Each system then has its own files but as far as I can tell they shouln’t have any effect on this

Thanks!

Forgot to mention that I am currently using

(discord.overrideAttrs (old: {
    meta = old.meta // {
      license = lib.licenses.free; # Lie to Nix to bypass the check
    };
  }))

as a workaround but I don’t know how to do this for programs like steam:

programs.steam.enable = true;

There’s a programs.steam.package option, I believe.

As for why it’s not working… have you set nixpkgs.pkgs or _module.args.pkgs?

nvm, the issue is just that steam-unwrapped is a separate package and you haven’t included that, I think. It would normally error out on the direct package first, and never get to its dependency. The fact that it’s reporting it for the unwrapped package (the dependency) suggests the predicate is actually working. I’m assuming you didn’t install steam on the laptop?

You’d need to add steam-unwrapped to that list as mentioned.

If you look at option b) in the error message, it will tell you the actual string to add.

Ok thanks that seem to have fixed it but its very wierd because literally yesterday I had the same error for discord and spotify

I also had an allowUnfreePredicate list specific to my pc so I had 2 in total. Could it be that what caused the isse? I can’t think of anythin else I’ve changed

Did you install discord/spotify through home-manager or nixos?

We can’t answer definitely about code that you wrote in the past or what you may or may not have changed, unless you have a working example where it’s erroring again. Glad it’s working!

Make sure you have the code tracked in git or at least backed up frequently (but git will be better longterm).

1 Like

Through nixos. It was the same thing just one list was for ā€œglobalā€ (meaning both pc and laptop) packages and the other one was steam and discord only (just on my pc)

Anyway thank for the help. I dont want to keep wasting your time