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

loaders: add matching loader #10

Merged
merged 12 commits into from May 26, 2023
Merged

Conversation

blaggacao
Copy link
Contributor

No description provided.

docs/src/api/load.md Outdated Show resolved Hide resolved
src/load.nix Outdated Show resolved Hide resolved
tests/matchers/expr.nix Outdated Show resolved Hide resolved
@figsoda
Copy link
Member

figsoda commented May 20, 2023

pushed some changes to make this fit kind of what I'm envisioning (I haven't updated the docs), tell me what you think

  • renamed match -> matches: I feel like match might be confused with builtins.match. There are some remaining uses of matches in the code base that means something else, but for the public facing docs this should be pretty unambiguous
  • removed __functor, matchers are now called with matcher.loader instead: I feel like this would be easier to understand
  • reimplemented parsePath: the previous implementation uses builtins.match and fails on file names that don't have a ., I don't think this is possible with builtins.match since nix uses POSIX regex and there are is no laziness (.+?). Also moved it into its own file since it's getting long
  • renamed nixFiles -> nix: I like it shorter since we are probably adding stuff like matchers.json and matchers.toml in the future. If this is too ambiguous maybe we can rename regex to withRegex

I'm still a bit unsure about whether matches should take the file name or the file name without prefixing _s (called stripped in parsePath's implementation). I do like this more than taking the full path

@blaggacao
Copy link
Contributor Author

I'm still a bit unsure about whether matches should take the file name or the file name without prefixing _s (called stripped in parsePath's implementation). I do like this more than taking the full path.

Agreed, and so to the rest of the changes. I understood that the matching groups are only available to the regex interface and that's much better this way, going to update the docs, then and we should be ready to go.

@figsoda figsoda merged commit ffa1e68 into nix-community:main May 26, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants