-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
trivial-builders: replace writeReferencesToFile with writeClosure #178717
trivial-builders: replace writeReferencesToFile with writeClosure #178717
Conversation
45d9b4a
to
40b183f
Compare
40b183f
to
a42a5cc
Compare
@jbedo @SomeoneSerge @GaetanLepage This could replace |
a42a5cc
to
e002fff
Compare
Update: Update: Let's prevent the already-not-working test suite from growing more complex. |
e002fff
to
b9d3ce0
Compare
@ofborg test references |
b9d3ce0
to
6540016
Compare
Awesome. I'll just note that I think bash is on its way of becoming a burden here. I would also really like to run some simple benchmarks because I don't have a very concrete understanding of how much of an issue this |
6540016
to
341c521
Compare
It's still short and understandable, so I think a shift away from bash would have more downsides than advantages. |
I haven't done a serious benchmark yet. The reason why it helps is:
When dealing with large packages like |
You can use a temporary store instead of GC, and rather than a
shell to prime you can just set jobs to 0:
TMPSTORE=$(mktemp -d)
nix-build -A hello --store $TMPSTORE -j 0
time nix-build -A hello --store $TMPSTORE --offline --no-out-link
|
A temporary store would be neat!
I don't understand this part. The purpose of |
Yeah never mind, -j0 will fetch from cache but not build anything, but
the shell might actually be better if there are some dependencies that
are uncached that you don't want to include in the benchmark.
|
2fc722f
to
81cabce
Compare
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.
I think you chose the more extreme name. Personally, I like this better, but I'll wait a bit for someone else to defend "References". I suppose "References" is a more explicit reference (jaja) to the the GC and dependency detection: you "writeReferencesToFile" to retain a runtime dependency on something you've seen at build time
In Nix, we have a default relation we refer to when talking about "the" closure, which is the relation of references, so I think the name
For this use case, taking the direct references is sufficient. The GC knows that the whole closure is reachable from that starting set. |
Replace writeReferencesToFile with writeClosure. Make writeClosure accept a list of paths instead of a path. Re-implement with JSON-based exportReferencesGraph interface provided by __structuredAttrs = true. Reword the documentation. Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> Co-authored-by: Someone Serge <sergei.kozlukov@aalto.fi>
da7c5f1
to
3a6ec57
Compare
Test writeClosure instead of writeReferencesToFile. Add multiple-path test for writeReferenceClosureToFile. Rename variables: - references -> closures (passthru affected) - REFERENCES -> CLOSURES
3a6ec57
to
112c3d5
Compare
Just fixed a commit message. Sorry for the noise. |
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.
(I've been waiting for the darwin check and couldn't resist posting a) Nit: might as well use nixpkgs#nixfmt-rfc-style
for the new files:) But let's maybe not reset Ofborg
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.
That RFC style guide is a long one. Since it doesn't affect evaluation,we could reformat in subsequent PRs.
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.
tests.trivial-builders.references
currently evaluates to { }
on non-Linux to make OfBorg build always green. We don't have to wait for it.
BTW, #273183 provides non-Linux developers with utilities to run and inspect the tests, while keeping the CI green.
read nrRefs | ||
for ((i = 0; i < nrRefs; i++)); do read ref; done | ||
done < graph | ||
jq -r ".graph | map(.path) | sort | .[]" "$NIX_ATTRS_JSON_FILE" > "$out" |
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.
Reminder: you can now open a PR with the lib.sort
feature you proposed earlier. I still don't understand the implications this would have
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.
#300722 it is! Please take a look.
@SomeoneSerge, sorry that I made it wrong. I didn't realize that the whole closure of |
I thought we concluded someplace else that |
They have different signatures. I said they are "not even close" (#178717 (comment)) based on the content of the file
I thought the closure of |
Description of changes
The new builder takes a list
paths
instead of a single path, and print their closure to a file. It would be helpful when building a container image from a list ofpackages. See #177908 (comment) .
I have prepared two versions of implementation, both of which tries to merge the result of
writeReferencesToFile
on each derivation:sort
command. Time complexity:writeReferencesToFile
are sorted. Time complexity:paths
andThis PR adopts the first implementation, since the code is shorter and more understandable.
Update:
@SomeoneSerge proposed the third approach: Write the path list with
writeText
, get its list of dependencies withwriteReferencesToFile
and then remove the line containing the store path of the path list derivation. Just re-implement this PR following this approach.Update:
Use the new
exportReferencesGraph
interface with__structuredAttrs = true;
and parse.attrs.json
withjq
.The test cases ofwriteReference*
builders doesn't run (#204456), blocking the test case adding for this new builder.Update:
The test that makes sure the equivalence between the
writeMultipleReferencesToFile [ path1 path2 ... ]
andnix-store --query --references outPath1 outPath2 ...
is added to the NixOS testtests.trivial-builders.references
.Add two package tests:
tests.trivial-builders.writeMultipleReferencesToFile-single
ensure the equivalence betweenwriteMultipleReferencesToFile [ path ]
andwriteReferencesToFile path
.tests.trivial-builders.writeMultipleReferencesToFile-mixed
ensures that the content of the result derivation ofwriteMultipleReferencesToFile [ path1 path2 ... ]
is the unique collection of that of (writeReferencesToFile path1
,writeReferencesToFile path2
, ...).Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)pkgs.writeMultipleReferencesToFile [ pkgs.jupyter ]
andpkgs.writeReferencesToFile pkgs.jupyter
is the same.pkgs.writeMultipleReferencesToFile [ pkgs.gcc pkgs.jupyter ]
andpkgs.writeReferencesToFile [ pkgs.jupyter pkgs.gcc ]
is the same.nixos/doc/manual/md-to-db.sh
to update generated release notes