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

Allow filtering string with contexts (e.g. flake inputs) if contexts are in state.allowedPaths #5344

Closed
ilkecan opened this issue Oct 6, 2021 · 0 comments · Fixed by #5347

Comments

@ilkecan
Copy link
Member

ilkecan commented Oct 6, 2021

Is your feature request related to a problem? Please describe.
Currently filtering a string with context is not possible as both builtins.filterSource1 and builtins.path2 throws an error in the form of string '<string>' cannot refer to other paths unless the context is empty.

This is a problem in general; filtering a path that is already filtered is not possible, as described in here. But it has a bigger implication with flakes and that is flake inputs cannot be filtered. This is important because flakes are not always inside the source repository they belong3, and source filtering has to be omitted in that case.

Describe the solution you'd like
I think this

... check if the context's paths are in state.allowedPaths rather than just checking if it is empty ...

as proposed by @tomberek in here would solve the problem. But I don't have enough knowledge with the codebase to say this wouldn't break anything.

Describe alternatives you've considered
While not a solution, one could use builtins.unsafeDiscardStringContext avoid the problem. But obviously, such things shouldn't be necessary.

Additional context
I wasn't sure whether to open this as a bug or as a feature request. Even if this isn't a bug, I think this deserves a high priority. Only other discussion I could find about this is this issue, which is unfortunate because it got sidetracked by another avoidable problem. @maisiliym was the main person that was talking about this problem456.

Footnotes

  1. https://github.com/NixOS/nix/blob/53e479428958b39a126ce15de85d7397fdcfe2e1/src/libexpr/primops.cc#L1904-L1908

  2. https://github.com/NixOS/nix/blob/53e479428958b39a126ce15de85d7397fdcfe2e1/src/libexpr/primops.cc#L1991-L1995

  3. See this as an example of a flake residing outside the source repository because the PR to add it to the upstream is not accepted.

  4. https://github.com/NixOS/nix/issues/3732#issuecomment-721478348

  5. https://github.com/NixOS/nix/issues/3732#issuecomment-728683410

  6. https://github.com/NixOS/nix/issues/3732#issuecomment-732028019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant