Conversation
roberth
left a comment
There was a problem hiding this comment.
Thank you for picking this up!
substitute
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
7709c01 to
7b1b805
Compare
substitute7b1b805 to
a50b505
Compare
a50b505 to
5b30b6e
Compare
5b30b6e to
8a13130
Compare
roberth
left a comment
There was a problem hiding this comment.
Still not a big fan of the automatic @s, also noting that the name is very generic, admittedly due to my own suggestion.
Should it be like this?
replaceInPath { variables = { inherit bash; }; } ./foo.shThat way it can be extended with arguments like
replaceInPath { replacements = { "/store/dir" = builtins.storeDir; }; } bar|
Robert, I'm pretty set on the argument order (attrset last) and the semantics ( On the other hand, I'm very open to other names than What about |
dea68a5 to
95d42c9
Compare
|
I don’t know if I like the name |
Whoops, didn't mean to relitigate this. I just find it natural to order positional arguments from least dynamic to most dynamic, and I consider the substitutions to be the more dynamic value. EDIT: uhh wait, so actually I agree then.
We know we need all the functionality, because otherwise it wouldn't already exist in the bash functions. I completely understand the need to scope things down, but by saying we won't need it, you're denying a clear need. Or maybe I missed something; is this part of a larger plan you have in mind? Please take my comments with a grain of salt - I think you're more aware of the big picture here than I am. |
|
FWIW I think having to write (Also the Bash functions are more often used to deal with random third‐party files that we don’t control, which I suspect is not so much the main use case of this function.) |
|
Fair enough then. Sorry for my detour, but I think we're getting to a good place. |
I love |
95d42c9 to
5472140
Compare
5472140 to
0c529fc
Compare
infinisil
left a comment
There was a problem hiding this comment.
I like it! I found some things to address, but otherwise I think we should merge this :)
I'm deeply interested and want the system to ping me.
0c529fc to
3f43af5
Compare
|
Without user facing docs (#301350 (comment)) this may as well not exist 😢 |
It needs some real life transformation experience. When I get back from camping I'm planning on doing a pass through nixpkgs on current substituteAll calls to see if it works or needs tweaks. Then the marketing can ensue. |
|
Awesome. Enjoy camping! |
|
Docs are live on noogle at least: https://noogle.dev/f/pkgs/replaceVars |
|
I've run into two things so far that might motivate a
I'm just skipping derivations that have these properties. |
What if we made the output have the same executable bit as the input? |
Here's an attempt at making an easy-to-use variant of
pkgs.substitutethat suffers from none of the pitfalls ofsubstituteAll. It's namedreplaceVarssince this isn't the unrelated concept of Nix substitution.Motivating transformation
From
pkgs/applications/audio/curseradio/default.nix:Into something like this, after
nixfmthas its way:According to a quick grep, there's around 340 of these throughout the codebase, making up the majority of the roughly 430 uses of
substituteAll.Simple cases:
rg -A1 --no-heading --no-filename --no-line-number -tnix -F '(substituteAll {' | rg -F 'src = ./' | wc -lAll cases:
rg --no-heading --no-filename --no-line-number -tnix -F 'substituteAll {' | wc -lGoals
substituteAllfor the majority case, where the thing being replaced lives in the repository rather that acquired through a fetcher or part of a more complicated substitution pipeline.--replace-failexclusively. I think the ergonomics of normal-looking names in the.nixfiles makes me want to continue thenameto@name@substitution throughout the codebase.checkPhase: when there are remaining@...@tokens in the output, will fail. This would be wrong for the general-purposesubstitutefunction but net positive for the patch substitution use case. This is the main reason for wanting--replace-failexclusively.substituteAttrs, didn't hit this mark. PerhapsreplaceVarsmight.substituteAllcommits.Description of changes
replaceVarsfunction.Things done
pkgs/test/replace-vars/default.nix(run withnix-build -A test.replaceVars)