Open lilyball opened 1 year ago
This also appears broken on Linux.
$ nix run nixpkgs#nix-info -- -m
- system: `"x86_64-linux"`
- host os: `Linux 6.1.41, NixOS, 22.11 (Raccoon), 22.11.20230703.ea4c80b`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.11.1`
- nixpkgs: `/etc/nix/inputs/nixpkgs`
$ git rev-list a845397 -n 1
a845397040d1b85cec4ee41edb8598d8086c3d95
$ NIXPKGS_CONFIG=$(pwd)/../bug/config.nix nix-instantiate --eval --expr 'with import ./. {}; hello.version' --show-trace
error: infinite recursion encountered
at /home/reckenrode/nixpkgs/../bug/config.nix:4:30:
3| {
4| blocklistedLicenses = with pkgs.lib.licenses; [ agpl3Only agpl3Plus ];
| ^
5| }
… while evaluating anonymous lambda
at /home/reckenrode/nixpkgs/pkgs/stdenv/generic/check-meta.nix:41:40:
40| hasBlocklistedLicense = assert areLicenseListsValid; attrs:
41| hasLicense attrs && lib.lists.any (l: builtins.elem l blocklist) (lib.lists.toList attrs.meta.license);
| ^
42|
… from call site
# etc
The nixos-22.11 channel works, so I’m using that as a known good commit to do a git bisect
on Linux.
git bisect
points to d7aad245314ef6b026707bf41c36461d450ef3ab, which is the logic the Darwin stdenv rework copied. 😫
I'm curious if anyone actually has any use for referencing anything other than lib
from pkgs
in the config file. In theory we could just hand the config file { pkgs = { inherit lib; }; }
and call it a day. Though I'm guessing there's at least one person out there who's actually accessing other things from pkgs for whatever reason (I suppose there's a potential use of e.g. permittedInsecurePackages = [ pkgs.someInsecurePackage.name ]
).
Describe the bug
When using
~/.config/nixpkgs/config.nix
to configure nixpkgs, this file may optionally be a function that takes a single{ pkgs }:
parameter. This is necessary when adding configuration forblocklistedLicenses
in order to reference the licenses in question. Example usage:As of https://github.com/NixOS/nixpkgs/pull/240433 (darwin.stdenv: Darwin stdenv rework), the reference to
pkgs
within this file produces an infinite recursion error:Steps To Reproduce
Steps to reproduce the behavior:
~/.config/nixpkgs/config.nix
contains the contents listed above and that there is noNIXPKGS_CONFIG
env var (or setNIXPKGS_CONFIG
to the path of a file containing the above)nix-instantiate --eval --expr 'with import ./. {}; hello.version'
(if from a nixpkgs checkout, or import<nixpkgs>
if appropriate).Expected behavior
This should run successfully (in this case, printing the version of the
hello
package).Additional context
Merely doing something like
blocklistedLicenses = assert builtins.isAttrs pkgs; [];
is sufficient to cause this issue. Sticking this in some of the other config values (likeallowUnfree
) doesn't cause a problem, though I didn't test all of them. Looking at the full stack trace I think it's because it's trying to test the validity of../../build-support/cc-wrapper
during bootstrap, so it's likely just the allowlisted/blocklisted licenses that will end up evaluated here.I really wish the config here was given
{ lib }
instead, but that's a backwards-incompatible change.Notify maintainers
Folks involved in the relevant PR: @reckenrode @viraptor @veprbl @emilazy @Atemu @tjni @willcohen @siraben @uri-canva
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.