lib.makeScope: allow overriding callPackage#500752
Conversation
93c6b91 to
f08c835
Compare
|
rebuilds are {
"rebuildsByKernel": {
"darwin": [
"nixpkgs-manual",
"tests.lib-tests"
],
"linux": [
"extra-container",
"nixos-container",
"nixos-install-tools",
"nixpkgs-manual",
"tests.lib-tests",
"tests.nixos-functions.nixos-test"
]
}
} |
philiptaron
left a comment
There was a problem hiding this comment.
Lgtm; @ShamrockLee or @hsjobeki what think you?
|
The diff seems reasonable. I haven't got a chance to test it. Is it possible to guard this feature with some test cases? Pinging Nixpkgs library experts: @infinisil @roberth @emilazy |
Yes. A little bit out of my comfort zone here. I would ask robert or infinisil if they see problems here. Unfortunately didn't have enough time to dig into this area deep enough. |
Test that: - makeScope provides a default callPackage - the scope function can override callPackage - the override persists through overrideScope
|
I pushed a commit with three tests for the new behavior:
I also verified that test 2 fails with the old makeScope, as the right-hand |
|
do we need release notes for this? lib.makeScope lib.callPackageWith (self: {
inherit (self) callPackage;
})now throws an infinite recursion error i mean inheriting from self in a fixed point attrset is generally stupid but there was one case in nixpkgs (octave packages) so it might break stuff for people. Also thanks for adding the tests. |
This is how I feel... but the release note seem so in the weeds that I hesitate to even draft it. I think I just want to merge this. |
|
Hello this PR has made my let
pkgs = import ./. { };
in
pkgs.lib.makeScope pkgs.newScope (final: {
inherit (final) callPackage newScope;
})Here I am using this invocation in a project of mine: https://github.com/9999years/npingler/blob/570a77e2e7831ec42a84c29e9908b729e2fd91e7/lib/default.nix I thought this was the 'normal' way to use I see similar patterns around GitHub: It seems like |
|
tldr let
pkgs = import ./. { };
in
pkgs.lib.makeScope pkgs.newScope (final: {
}) |
I'm not sure this was ever needed, but it causes problems with the lastest Nixpkgs. See: NixOS/nixpkgs#500752 (comment)
this is probably needed for NixOS/nixpkgs-vet#206
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.