-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Function for transforming store path contents #264541
Comments
It seems enough to document that one can arbitrarily transform store paths at build time. We already have plenty of shell scripting helpers, no need to add another interface for general computation. |
@fricklerhandwerk It doesn't have to be this exact interface, and maybe if we have the right use cases, there's a case to be made for a composable API to transform store paths too. However I think even this very simple command-based API would be worth having, because it's currently not easily doable with other functions:
In comparison, having a new well-scoped function for just transforming a store path might be a really nice primitive to have. Of course, if we have any use cases that even need this, so far I don't know of any. |
For inspiration/discussion maybe: I have a usecase and a specialized implementation in my dotfiles of a content transformation like this, to replace the binaries in a pkg by my own: Another usecase I had was to patch incoming sources (didn't find a better way than a manual drv):
Could the (many) wrapper packages we have be a usecase for this? Where the 'unwrapped' pkg is transformed to have some kind of new behavior |
Ideally we'd be able to produce the same store path through this. This would then allow cache sharing when NixOS/nix#9259 is implemented. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-11-28-nixpkgs-architecture-team-meeting-46/36171/1 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/easy-source-filtering-with-file-sets/29117/15 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
Proposal: The crucial limitation of derivations is that we can't serialize Nix functions into it,¹ so I think it makes sense to name it after this property. This sublibrary would consist primarily of lazy, mostly dumb constructors, that construct a data structure without performing any computation. After constructing the serializable fileset, the only two operations to consume it are
Example output { "unions": [
{ "path": "./src/foo.cc" },
{ "byExt": {
"root": { "path": "./include" },
"ext": ".hh"
}}
]} Note that we can't have a In Nixpkgs we'll implement a program that can perform a filtering copy using the JSON as its input, and a simple runCommand-flavored derivation helper. Details
Resolving path values works well
¹ It's not fundamentally impossible, but very complex to implement, and very likely to make your drv hashes inadvertently depend on evaluator implementation details. |
Issue description
I've been working on the new file set library in recent months, which allows selecting local eval-time paths to add to the store. Notably this library does not support handling of store paths, see #264537 for why not.
However, it would be very doable to have a simple function for doing arbitrary transformations over store paths with a command. I can imagine an interface like this:
I can also imagine there being alternate more convenient approaches, suggestions welcome.
Ping @roberth @fricklerhandwerk
This issue is sponsored by Antithesis ✨
The text was updated successfully, but these errors were encountered: