modules/nixpkgs: add setting nixpkgs.config.allowUnfreePackages = ["list" "of "packages"]

Inspired by https://github.com/NixOS/nixpkgs/issues/197325 this adds a
new option `nixpkgs.allowUnfreePackages`, which merges additively and can
thus be defined in multiple modules close to where the unfree package is
installed.

I would have liked to name this option
`nixpkgs.config.allowUnfreePackages`, to define it closer to where the
`allowUnfree` and `allowUnfreePredicate` are defined, but I didn't see how
this could be achieved. I would welcome some guidance on how to do this.

Cherry-picks a3c9221d64
This commit is contained in:
‮rekcäH nitraM‮ 2025-04-06 18:36:51 +02:00 committed by Matt Sturgeon
parent ff3cd5fa14
commit a3dffa03ad

View file

@ -23,6 +23,9 @@ let
rhs = optCall rhs_ { inherit pkgs; };
in
lib.recursiveUpdate lhs rhs
// lib.optionalAttrs (lhs ? allowUnfreePackages) {
allowUnfreePackages = lhs.allowUnfreePackages ++ (lib.attrByPath [ "allowUnfreePackages" ] [ ] rhs);
}
// lib.optionalAttrs (lhs ? packageOverrides) {
packageOverrides =
pkgs: