makeBinaryWrapper: add --set-from-file option #478261
Open
+65
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been working on a collection of wrappers, and want each wrapper to support both:
pkgs.formatstransformation (think home-manager.settingsoptionsMost programs support taking a config path, but some can only read from the state of an env var, or the flags they've been passed directly. To allow these programs to be handled impurely, the wrapper itself needs to read from the file and pass the contents to the program.
This PR adds the ability to do the first part of that. Calling
wrapProgram $out/bin/foo --set-from-file FOO_ENV_VAR /home/user/example/filecreates the relevant C code to read from /home/user/example/file at runtime, and set FOO_ENV_VAR to the contents of this file. I'm using this locally with one of my wrappers, and can confirm it functions.Feel free to critique my C code. In a future PR, I'd like to add the equivalent feature for --add-flags, and see if I can bring this API to the normal makeWrapper as well.
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.