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

nixos/utils: use removePrefix in escapeSystemdPath #66761

Merged
merged 1 commit into from Mar 14, 2020

Conversation

florianjacob
Copy link
Contributor

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

isValidUnitName = name: (builtins.match "[a-zA-Z0-9:_.\\-]+" name) == [];

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.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

Could not find a maintainer, so
cc @wkennington as the last one who touched that part.

@alyssais alyssais merged commit 8b07500 into NixOS:master Mar 14, 2020
@florianjacob florianjacob deleted the systemdEscapeRemovePrefix branch March 14, 2020 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants