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

Can't evaluate .#generate-k8s: invalid regular expression #15

Closed
felixscheinost opened this issue Feb 15, 2023 · 3 comments
Closed

Can't evaluate .#generate-k8s: invalid regular expression #15

felixscheinost opened this issue Feb 15, 2023 · 3 comments

Comments

@felixscheinost
Copy link
Contributor

felixscheinost commented Feb 15, 2023

Hi,

I just tried a nix build .#generate-k8s which fails with a Nix evaluation error:

error: invalid regular expression '(  |)+'

       at /nix/store/255f8yvapjp479bi5h3ngyqsrc25qh94-source/jobs/generators/k8s/default.nix:24:64:

           23|
           24|     removeEmptyLines = str: concatStringsSep "\n" (filter (l: (builtins.match "(  |)+" l) == null) (splitString "\n" str));

I am using Nix 2.11.1.

The regex ( |)+ in principle seems correct to me but shouldn't builtins.match "\s*" l !+ null be a simpler way to test whether a line is "empty" (which I assume means blank, zero characters or only space characters). Or is there some edge case I am missing?

@hall
Copy link
Owner

hall commented Feb 15, 2023

Thanks for opening this issue. I probably should have done so when it was first mentioned in #12 (comment).

I'm guessing you're also on darwin. Your proposed changed looks similar to mine a few comments down. Though I don't really have a way to test on darwin to ensure it actually works (if it results in no diff for the generated modules, it's likely a suitable fix).

However, I just did a quick test on my end (x86_64-linux) and \s* appears to delete several non-empty lines.

@felixscheinost
Copy link
Contributor Author

Yeah, didn't test when opening the issue.

I tested with the fix you proposed ((l: builtins.match "[[:space:]]*" l != [])) by doing rm modules/generated/* && nix run .#generate and it seems like all files are generated exactly the same as before!

felixscheinost added a commit to felixscheinost/kubenix that referenced this issue Feb 15, 2023
hall pushed a commit that referenced this issue Feb 15, 2023
@hall
Copy link
Owner

hall commented Feb 15, 2023

Great! Merged the fix you submitted.

fwiw, nix run '.#generate' will do the rm automatically

@hall hall closed this as completed Feb 15, 2023
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

No branches or pull requests

2 participants