As of #437723, and in particular f5deefd, it is no longer possible to use a function as the config argument when importing nixpkgs.
As a minimal example, consider the following:
{
pkgs ? import <nixpkgs> {
config =
{ pkgs, ... }:
{
allowlistedLicenses = [ pkgs.lib.licenses.unfree ];
};
},
}:
pkgs.runCommandLocal "demo" { } "touch $out"
This builds just fine prior to f5deefd, but from that commit onwards, I see the below output:
$ nix-build -I nixpkgs="$HOME"/vcs/nixpkgs
error:
… while evaluating a branch condition
at /home/adamdinwoodie/vcs/nixpkgs/pkgs/stdenv/booter.nix:107:9:
106| thisStage =
107| if args.__raw or false then
| ^
108| args'
… in the right operand of the update (//) operator
at /home/adamdinwoodie/vcs/nixpkgs/pkgs/stdenv/booter.nix:90:44:
89| # for the final stage.
90| { allowCustomOverrides = index == 1; } // (stageFun prevStage)
| ^
91| ) (lib.lists.reverseList stageFuns);
… while evaluating the option `allowlistedLicenses':
… while evaluating definitions from `nixpkgs.config':
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: infinite recursion encountered
at /home/adamdinwoodie/vcs/demo/default.nix:6:33:
5| {
6| allowlistedLicenses = [ pkgs.lib.licenses.unfree ];
| ^
7| };
This use case seems to be the intent of the following code, essentially added at e1c1ecf:
|
# Allow both: |
|
# { /* the config */ } and |
|
# { pkgs, ... } : { /* the config */ } |
|
config1 = if lib.isFunction config0 then config0 { inherit pkgs; } else config0; |
Tagging @ConnorBaker.
As of #437723, and in particular f5deefd, it is no longer possible to use a function as the
configargument when importing nixpkgs.As a minimal example, consider the following:
This builds just fine prior to f5deefd, but from that commit onwards, I see the below output:
This use case seems to be the intent of the following code, essentially added at e1c1ecf:
nixpkgs/pkgs/top-level/default.nix
Lines 109 to 112 in 1a19c69
Tagging @ConnorBaker.