-
Notifications
You must be signed in to change notification settings - Fork 80
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
Add a nixpkgs_packageset
rule
#49
Comments
I think this is a good idea. Though to be useful the json file you mention should be checked into the source, right? So that even the initial checkout isn't too slow? @zimbatm pointed out to me yesterday that this would be similar to Yarn lock files. And it so happens that @aehlig proposed to do something similar here and here. |
I didn't think of checking it. I think it would be a benefit even without doing it. Some really quick tests I've done indicate that for Checking that into the repo would make it almost instantaneous, at the cost of having to handle a generated file. |
@regnat how many calls to Pardon my bazel:
Then I imagine that this rule would have multiple outputs, one for each attribute. This approach should be faster even on a fresh install with anything > 2 packages. |
Can we assume the output is stable and is going to stay so over nix releases?
I’d go a step further and make this possible:
So users can reference whole attribute sets (recursively?) and it will cache all subderivations. |
Sounds great! I think the You probably know already, --- EDIT --- Oops forgot to answer:
Since nix doesn't give any other output mapping capability than the ordering I would be the first to complain if that started to break. |
Only one: I with import <nixpkgs> {};
let
evaluateElement = x:
let result = builtins.tryEval (x.drvPath or null); in
if result.success == true then result.value else null;
in
(builtins.mapAttrs (_: evaluateElement) haskellPackages) @Profpatsch If I understand correctly you suggest saving the |
Conceivably, Hydra could generate that for all of Nixpkgs though. Then we don't even need to checkin anything. @zimbatm isn't that what you have setup in some private Hydra instance? |
Unless I'm mistaken, the time taken by |
Nope, that would stumble over packages marked as broken (run |
@Profpatsch's approach seems the best as it's independent of any infrastructure requirements. For example if the user wants to provide it's own overrides it wouldn't be able to fetch things from the public Hydra anyways. |
I have a POC implementation in #50, feel free to take a look and criticize it |
Since tweag/rules_haskell#442, the evaluation of the workspace of a rules_haskell-enabled repository takes an insane amount of time because it requires
nix-build
-ing every transitive haskell dependency, which easily means more than 200nix-build
calls.We could speed things a lot by first
nix-instantiate
-ing a big json file mapping each haskell package to its.drv
, and then just realize as needed these pre-intstantiated derivations. This would avoid the cost of evaluating nixpkgs 200 times (which is by far the bottleneck when everything is already built).This trick can probably be used for more than just the
haskellPackages
case, so I propose we add anixpkgs_packages_set
rule torules_nixpkgs
which would be used like:This would generate
@haskellPackages-base
,@haskellPackages-streaming
,@haskellPackages-foobar
, … (and possibly one@haskellPackages
with aliasesin it for all of these.
Internally this rule would
nix-instantiate
a json file of the formLoad this into a starlark dict one way or another
For each element of this dict, generate a call to a rule which would
nix-store --realize
the corresponding derivationAll this would require extending a bit the scope of nixpkgs (or doing thing in an ad-hoc way, not sure what's the best choice), to add
nix_instantiate
rule allowing to import the result ofnix-instantiate
nix_realize
rule which would wrapnix-store --realize
Thoughs?
The text was updated successfully, but these errors were encountered: