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

Add types.strMatching #32256

Closed
wants to merge 2 commits into from
Closed

Conversation

ryantrinkle
Copy link
Contributor

Motivation for this change

This gives a way for nixos modules to easily check and document requirements for string parameters, when they can be validated by a regular expression.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
    • N/A
  • Built on platform(s)
    • NixOS
    • macOS
      • N/A
    • other Linux distributions
      • N/A
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
    • N/A
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
    • N/A
  • Tested execution of all binary files (usually in ./result/bin/)
    • N/A
  • Fits CONTRIBUTING.md.

@ryantrinkle
Copy link
Contributor Author

@ryantrinkle ryantrinkle mentioned this pull request Dec 2, 2017
8 tasks
@@ -174,6 +174,13 @@ rec {
merge = mergeOneOption;
};

strMatching = pattern: mkOptionType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

matchRegex or just match ?

@ryantrinkle
Copy link
Contributor Author

This was merged as part of 3807408

@ryantrinkle ryantrinkle closed this Dec 5, 2017
escapeNixString "hello\${}\n"
=> "\"hello\\\${}\\n\""
*/
escapeNixString = s: escape ["$"] (builtins.toJSON s);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the use case for this function? It seems to me that if you need to escape a Nix string, you're doing it wrong. Also using a combination of toJSON and escape seems weird.

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

4 participants