-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stage: use fix' to allow deep overriding of pkgs
from within Nixpkgs
#43828
Conversation
Motivation for this change is the overriding required for Sage (#43755) |
Statistics:
|
Don't you really want |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using packageOverride
in Nixpkgs should have been banned before, and identically for re-importing Nixpkgs within Nixpkgs evaluation.
You should not need a re-evaluation of Nixpkgs for doing this kind of operations. What you are looking for is what the bootstrap mechanism should have been instead of being an additional fix-point, which is a duplicated and isolated sub-set of overriden packages within Nixpkgs fix-point.
You will have to add an overrideWith
attribute to makeOverridable
, which redo the argument intersection logic of callPackageWith
.
self: super:
{
sageDeps = (super.sageDeps or {}) // {
foo = super.foo.overrideWith self.sageDeps;
# take foo from self.sageDeps.foo instead of self.foo
bar = super.bar.overrideWith self.sageDeps;
};
}
I will also note that this self: super:
{
pythonPackagesRaw = {
foo = callPackages import ./foo.nix {};
bar = callPackages import ./bar.nix {};
baz = callPackages import ./baz.nix {};
};
python27Packages =
let scope = self.python27Packages // { python = self.python27; }; in
lib.mapAttrs (n: v: v.overrideWith scope)) pythonPackagesRaw;
python35Packages =
let scope = self.python35Packages // { python = self.python35; }; in
lib.mapAttrs (n: v: v.overrideWith scope)) pythonPackagesRaw;
} |
Thank you @nbp. Let's see if I understand this. The following expression represents self: super:
{
sageDeps = (super.sageDeps or {}) // {
foo = super.foo.overrideWith self.sageDeps;
# take foo from self.sageDeps.foo instead of self.foo
bar = super.bar.overrideWith self.sageDeps;
};
} Because having to write self: super:
{
sageDeps = let scope = self.sageDeps; in lib.mapAttrs (n: v: v.overrideWith scope)
((super.sageDeps or {}) // {
foo = super.foo;
# take foo from self.sageDeps.foo instead of self.foo
bar = super.bar;
});
} Now, I want to call a package. Typically I would use ExampleI would very much like to see an example representing three files:
Let's see how we could do that.
|
There are of course different sets to consider:
Not sure where to put |
Closing because this won't go in. |
What about the alternative? |
This is an example short-cut for a new package definition. For the example you are looking for, putting things in a different file involve some extra naming, and you should not just give one argument to the (side-note: Why is all-packages.nix# There is no super argument to all-packages.nix, which is a shame as this is not a proper overlay.
rec_: fixPkgs: # today named `self: pkgs:`
{
packageSet =
# This does not include (super.packageSet or {}) because we have no `super`.
# The last fixPkgs, should be the `super` attribute of all-packages.nix for
let raw = import ./package-set.nix fixPkgs rec_ fixPkgs; in
# overrideWith fixPkgs.___ such that overlay modification of packageSet.foo
# are visible by packageSet.foobar.
lib.mapAttrs (n: v: v.overrideWith fixPkgs.packageSet) raw;
} package-set.nix# We need this extra argument because instead of making an overlay as I suggested in the previous
# example, we are making it part of all-packages.nix, which implies that all packages added in
# all-packages.nix are not (supposed to be) available from the super attribute. Also, it comes from
# the nixpkgs fix-point today, using `override` or `overrideWith` might lead to an infinite loop later.
self: allPkgs: super:
let
inherit (super) callPackage;
in
{
# Override package explicitly with given parameters
foo = allPkgs.foo.override { enableToto = true; };
# Call our package
bar = callPackage package.nix { };
# Expect foo and bar as inputs. With the mapAttrs from all-packages.nix, the foo and bar
# would be overwritten with the foo and bar from this set.
foobar = allPkgs.foobar;
} |
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)