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

nix flakes: git CRLF line endings are not handled #10640

Open
tmplt opened this issue May 3, 2024 · 2 comments
Open

nix flakes: git CRLF line endings are not handled #10640

tmplt opened this issue May 3, 2024 · 2 comments
Labels

Comments

@tmplt
Copy link
Member

tmplt commented May 3, 2024

Describe the bug

On WSL2, CRLF line endings break flake build unless git attributes are overridden, usually resulting in a confusing $'\r': command not found error.

Steps To Reproduce

In a NixOS-WSL instance, run

$ git clone https://github.com/cachix/devenv.git && cd devenv
$ nix build .#devenv
error: builder for '/nix/store/hnjx2v3nw9al8pjcp4g22b2s9xhyq9r7-devenv-1.0.5.drv' failed with exit code 127;                                                                                       
last 10 log lines:                                                                                                                                                                         
>                                                                                                                                                                                           
> running 0 tests                                                                                                                                                                           
>                                                                                                                                                                                           
> test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s                                                                                             
>                                                                                                                                                                                           
> Finished cargoCheckHook                                                                                                                                                                   
> Running phase: installPhase                                                                                                                                                               
> Executing cargoInstallHook                                                                                                                                                                
> /nix/store/v5lsd029lz5lfhamivbgqyp3zdv94ah2-stdenv-linux/setup: line 114: $'\r': command not found                                                                                        
> /nix/store/v5lsd029lz5lfhamivbgqyp3zdv94ah2-stdenv-linux/setup: line 131: pop_var_context: head of shell_variables not a function context                                                 
For full logs, run 'nix log /nix/store/hnjx2v3nw9al8pjcp4g22b2s9xhyq9r7-devenv-1.0.5.drv'. 
$ echo "*.nix text eol=lf" > .gitattributes && git add .gitattributes
$ nix build .#devenv && echo $?
0

Expected behavior

devenv should be built without having to override git EOL attributes.

nix-env --version output

nix-env (Nix) 2.18.1

Additional context

Previously reported at https://discourse.nixos.org/t/nix-flakes-and-line-endings/22065, but not strictly WSL2-related.

Priorities

Add 👍 to issues you find important.

@tmplt tmplt added the bug label May 3, 2024
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-flakes-and-line-endings/22065/10

@tmplt
Copy link
Member Author

tmplt commented May 3, 2024

MWE can very likely be reduced: git init; trivially build a file containing CRLF; observe different hash depending on git attributes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants