Issue installing corefonts

Hello,
I face an issue I don’t get.
in my config.nix file, I have

  nixpkgs = {
    config = {
      allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
        "corefonts"
      ];
    };
  };

  fonts.packages = with pkgs; [
    corefonts
  ];

but when I do sudo nixos-rebuild switch --show-trace --flake .#thatoo, I get this error :

       error: Package ‘corefonts-1’ in /nix/store/f30jn7l0bf7a01qj029fq55i466vmnkh-source/pkgs/by-name/co/corefonts/package.nix:142 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

          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) [
             "corefonts"
           ];
         }

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

even though I feel I’m doing the solution b) already. That’s why i don’t get how to solve my issue.
What should I do?

Hello so the issue here is that the package you want to install is not Open Source. Therefore I would recommend to just put nixpkgs.config.allowUnfree = true; in your configuration.

Do you have your allowUnfreePredicate defined in multiple places? IIRC it can only be defined once.

1 Like

You were right @waffle8946 I forgot I defined allowUnfreePredicate in an other .nix file.
I correct my mistake and it works.
Thank you.

Yeah, it’s a quirk of function-type options.

If you want to define such a list across multiple files, you can make your own option with mkOption, then using config.whatever.your.option.is in the allowUnfreePredicate. Lists should merge just fine. See https://nixos.org/manual/nixos/unstable/#sec-writing-modules