Skip to content
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

lib.fileset: Lazier path existence check #267091

Closed
wants to merge 2 commits into from

Conversation

infinisil
Copy link
Member

@infinisil infinisil commented Nov 12, 2023

Description of changes

Allows things like difference ./. ./a even if ./a doesn't exist.
Another case that's now doable is intersection ./a (union ./a ./b) even if ./b doesn't exist.

This is an alternative to #265964 that doesn't require a new function and is more transparent to the user.

It's not perfect however, because difference ./. (difference ./a ./a/b)
doesn't give an error anymore if ./a/b doesn't exist. We can maybe consider this an edge case. This could be fixed in the future, but would need a non-trivial change to the internal representation.

More problematic however is that you aren't protected against typos in the negative argument anymore: If you want to remove ./secret, but you write difference ./. ./sercet instead, it would just fail silently and import the path into the store! This is making me think that we maybe shouldn't do this.

This work is sponsored by Antithesis

Things done

  • Extended tests
  • Updated documentation
  • Clean and commented code

@github-actions github-actions bot added 8.has: documentation This PR adds or changes documentation 6.topic: lib The Nixpkgs function library labels Nov 12, 2023
@infinisil infinisil mentioned this pull request Nov 12, 2023
3 tasks
@infinisil infinisil changed the title Lib.fileset lazier lib.fileset: Lazier path existence check Nov 12, 2023
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Nov 12, 2023
- Make fromSource's missing file error message more consistent with others,
  and add a test for it
- Indent some function arguments
- Make the contextual error test not rely on nested paths
  Makes the next commit smaller
- Add single-file tests for trace and fileFilter
Allows things like `difference ./. ./a` even if `./a` doesn't exist.

Not perfect however, because `difference ./. (difference ./a ./a/b)`
doesn't give an error if `./a/b` doesn't exist. This is considered an
edge case, but it could be fixed in the future.
@infinisil infinisil marked this pull request as draft November 14, 2023 07:51
@fricklerhandwerk
Copy link
Contributor

it would just fail silently and import the path into the store! This is making me think that we maybe shouldn't do this.

Yes, this in particular.

@roberth
Copy link
Member

roberth commented Nov 15, 2023

Looks like we need a sercet breaker.

@roberth roberth closed this Nov 15, 2023
@infinisil infinisil deleted the lib.fileset-lazier branch November 15, 2023 23:53
@infinisil infinisil mentioned this pull request Nov 19, 2023
1 task
@infinisil
Copy link
Member Author

There were some minor changes here useful on their own, created a separate PR for those: #268520

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: lib The Nixpkgs function library 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants