writeClosure: add paths pre-instantiation filtering and sorting#300722
writeClosure: add paths pre-instantiation filtering and sorting#300722ShamrockLee wants to merge 1 commit intoNixOS:masterfrom
paths pre-instantiation filtering and sorting#300722Conversation
Pre-process paths before feeding to `exportReferencesGraph`. - Remove null. - Manually string-interpolate for sorting. - Sort alphabetically to reduce unnecessary rebuilds.
I guess the question I rather wanted to ask is (I'm not particularly familiar with lazy languages, this is probably very basic): does |
AFAIK, evaluation is independent from realization (build) as long as "import from derivation" (IFD) is not used. For example, if we would like to build After all the evaluation is finished, Nix reads the store derivation of The only read/write things evaluation can affect, when IFD is not involved, is
Those are unfortunately done sequentially, as Nix evaluation doesn't seem to support paralellism. That's probably why built-in fetchers are not used often in Nixpkgs. |
Indeed. I guess I was just blabbering something without giving it any actually thought. Looking back, However, I still don't like the idea of sorting by hashes (squinting an eye, this should be equivalent to a random shuffle, when perturbing any inputs). I'd rather sort by names first and then by hashes, just to have stable layouts. |
It turns out that the order of the paths taken by If we want to change the output order, we'll need to add custom sorting to the |
Nice. It would change the IA outPath of
Hello myself from a year back, you were lazy and also wrong about most things. In normal Nix, this would sort by IA hashes. Even in CA Nix this would sort by the unresolved outPaths, which functionally behave same as IA hashes. Sorting does is a synchronization point, but it hardly matters because (1) Nixpkgs already big, (2) Nix already slow. To conclude, I'm now in favour of sorting and deduping. Out of aesthetic considerations, I would have preferred |
Description of changes
Pre-process paths before feeding to
exportReferencesGraph.null.nullis a common approach to "cancel" a dependency from the override interface. However,exportReferencesGraphdoesn't handlenullcorrectly (with or without__structuredAttrs = true), hence the removal.buildInputsandnativeBuildInputsautomatically for similar purposes, but such proposal faced the challenge of a few packages' relying on the order of dependency package to determine the order ofPATHs. Thepathsattribute ofwriteClosuredoesn't have such issue, as the closure is, by definition, independent to the permutation ofpaths.Regarding the concern about manual string interpolation, the paths will eventually go through string interpolation before being serialized into a store derivation (
/nix/store/*.drv) and form$NIX_ATTRS_JSON_FILEand$NIX_ATTRS_SH_FILE. Manual string interpolation doesn't change any of thedrvPathoroutPath, nor does it introduce extra dependencies or affects realization.Proof:
The following Nix expression evaluates to
true.Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.