What could cause this flake to fail on my computer and succeed on another?

I am running NixOS on WSL

I use nix version nix 2.18.1 I run

 nix develop

in the directory containing flake.nix that looks like that:

 description = "Python environment with ollama";

 inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
 inputs.flake-utils.url = "github:numtide/flake-utils";

 outputs = { self, nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (system: let
      pkgs = nixpkgs.legacyPackages.${system};
      jina-hubble-sdk = with pkgs.python3Packages;
        buildPythonPackage rec {
          pname = "jina-hubble-sdk";
          version = "0.39.0";

          src = pkgs.fetchPypi {
            inherit pname version;
            sha256 = "9021417794a6d3cf3fad8a880cf668a3a986b9d53d5be5fa391aae1767a5b9b0";

          nativeBuildInputs = [
            pkgs.dos2unix # Add dos2unix to convert line endings

          propagatedBuildInputs = [

          # Convert line endings to Unix-style
          preConfigure = ''
            export HOME=$(mktemp -d)
             # put this code inside preConfigure if you want to run it dos2unix -f /nix/store/v099hqvw5z87423p4hz1vfhzaqa07dii-stdenv-linux/setup
      pythonEnv = pkgs:
        pkgs.python3.withPackages (ps:
          with ps; [
    in {
      devShells.default = pkgs.mkShell {
        buildInputs = with pkgs; [
          (pythonEnv pkgs)

and I get the following error

error: builder for ‘/nix/store/dm6cxw020s7whbfgqj8jivd3dv1pby0i-python3.11-jina-hubble-sdk-0.39.0.drv’ failed with exit code 127; last 10 log lines: > Using setuptoolsCheckPhase > Running phase: unpackPhase > unpacking source archive /nix/store/9q6b5l6955sabgvk8ah5xx0sfji25zmn-jina-hubble-sdk-0.39.0.tar.gz > source root is jina-hubble-sdk-0.39.0 > setting SOURCE_DATE_EPOCH to timestamp 1688549032 of file jina-hubble-sdk-0.39.0/setup.cfg > Running phase: patchPhase > Running phase: updateAutotoolsGnuConfigScriptsPhase > Running phase: configurePhase > /nix/store/v099hqvw5z87423p4hz1vfhzaqa07dii-stdenv-linux/setup: line 114: $‘\r’: command not found > /nix/store/v099hqvw5z87423p4hz1vfhzaqa07dii-stdenv-linux/setup: line 131: pop_var_context: head of shell_variables not a function context For full logs, run ‘nix-store -l /nix/store/dm6cxw020s7whbfgqj8jivd3dv1pby0i-python3.11-jina-hubble-sdk-0.39.0.drv’. error: 1 dependencies of derivation ‘/nix/store/25gl4f29rr56ci1h5k53wmm7wgfmk2p2-python3-3.11.8-env.drv’ failed to build error: 1 dependencies of derivation ‘/nix/store/pxkgnl5nx66fcdi1rkvz86kbfrvlmhn2-nix-shell-env.drv’ failed to build

But when I asked for help on stackoverflow, somebody say that this problem don’t occur on his computer and he is using nixos with WSL too.

nix flake - How to fix Nix build failure due to a file using the windows way to break line - Stack Overflow

Hence my question, why is causing this flake not to run correctly on my computer when it works for others ?

Looks like your copy of flake.nix (the file, not the code) is using DOS line endings:

❯ nix shell nixpkgs#toybox
❯ unix2dos ./flake.nix 
❯ nix develop        
error: builder for '/nix/store/bn0gx56rasjhx41kgm5921nk784k8496-python3.11-jina-hubble-sdk-0.39.0.drv' failed with exit code 127;
       > /nix/store/v099hqvw5z87423p4hz1vfhzaqa07dii-stdenv-linux/setup: line 114: $'\r': command not found
       > /nix/store/v099hqvw5z87423p4hz1vfhzaqa07dii-stdenv-linux/setup: line 131: pop_var_context: head of shell_variabl

❯ dos2unix ./flake.nix  
❯ nix develop

/tmp/tmp.JzhsSBmlx8 via ❄️  impure (nix-shell-env) 

I wrote the flake using visual studio code, open from windows. That meant that my flake was coded with dos encoding. I convert my flake with dos2nix and I can run it without problem.
I should have tested earlier but the error message didn’t say that error was coming from my flake and until now I wrote all my falke with dos encoding and it worked.

@ VTimofeenko Thank you for your help

My guess is that the it’s preConfigure script that was causing the builder to crash. Maybe previous flakes did not have embedded scripts.

In any case – quick search for dos line endings shows some weird bugs so it’s best to avoid it.