nixos/utils: use removePrefix in escapeSystemdPath #66761
Merged
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.
Motivation for this change
I was in the process of creating my own escaping function, when I discovered that something like this was already in master. While I'm not sure whether half-handingly reimplement removePrefix has any performance benefits that were forgotten to document, it seems to make more sense to implement it that way.
Things done
Only tested using nix-repl. Are there tests for this hidden somewhere?
For my own function, knowing about the incompleteness of the replacement table, I used the following assertion function taken from here
Something like this would allow to check if a user gives input that is incorrectly escaped and return with a proper error message saying that the escaping function has to be improved, but I have no idea how to validate that globally and with an acceptable performance.
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
Could not find a maintainer, so
cc @wkennington as the last one who touched that part.