Skip to content

symlinkJoin: ability to strip prefix from tree#345127

Merged
philiptaron merged 2 commits intoNixOS:masterfrom
CertainLach:feat/symlinkJoin-stripPrefix
Feb 26, 2025
Merged

symlinkJoin: ability to strip prefix from tree#345127
philiptaron merged 2 commits intoNixOS:masterfrom
CertainLach:feat/symlinkJoin-stripPrefix

Conversation

@CertainLach
Copy link
Member

Currently, symlinkJoin always joins packages at its roots. It is possible to just suffix every package with wanted path to avoid that, but this causes an error due to missing path (If there is one packages option, but multiple things that you want to extract from those packages)

We already have uses for similar functionality in tree, but it it always duplicated, e.g

The patch is a little bit ugly to avoid causing mass-rebuilds, it would be nice to make it prettier during one.

Required for Qubes: #341215

Description of changes

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@CertainLach CertainLach force-pushed the feat/symlinkJoin-stripPrefix branch from 90deff2 to ae2d4d1 Compare September 28, 2024 15:58
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Sep 28, 2024
Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, Yaroslav (@CertainLach).

I'm requesting changes for three things.

  1. Documentation of the new behavior.
  2. Tests of the facility.
  3. Good errors from the new assert.

Of these, I care the most about the tests. 🙂

I appreciate the research you did to motivate adding this new functionality to symlinkJoin.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we're adding in something more than just a simple for loop, I think this needs a test.

See the file pkgs/build-support/trivial-builders/test/default.nix for the set of tests.

Run the tests using nix-build -A tests.trivial-builders.symlinkJoin.

Take a look at pkgs/test/replace-vars/default.nix for an example of how to write those tests. testers.testEqualContents in particular will be useful, and testBuildFailure for demonstrating what happens when the derivation ought to error.

That'll give you the ability to do demonstrate the following cases:

  1. Direct, normal use sans any path stripping (maybe with a nested list, per the recursive call).
  2. Build failure due to a missing path.
  3. Path stripping with missing paths
  4. Path stripping with failures due to other reasons that are skipped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path stripping with failures due to other reasons that are skipped.

Error skipping behavior was unintentional, it was added to make command not error, i.e test -d nonexisting && lndir ... would fail because of test -d exit code, and test -d ... && lndir ... || true would fix that error code.
Changed to if test -d ...; then instead. This way the code is even more ugly, but more correct.

It will skip those paths, whose prefix references some file (This test was added too), but should not ignore other I/O errors.

@CertainLach CertainLach force-pushed the feat/symlinkJoin-stripPrefix branch from 28239f2 to c213c2f Compare February 13, 2025 20:23
@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Feb 13, 2025
@CertainLach CertainLach mentioned this pull request Feb 15, 2025
13 tasks
@philiptaron philiptaron merged commit 68fdbf5 into NixOS:master Feb 26, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants