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 = [
poetry-core
pkgs.dos2unix # Add dos2unix to convert line endings
];
propagatedBuildInputs = [
pep517
pip
requests
aiohttp
rich
importlib-metadata
filelock
pathspec
docker
pyyaml
python-jose
];
# 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; [
jina-hubble-sdk
]);
in {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
curl
ollama
(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
The important line in the error message:
/nix/store/v099hqvw5z87423p4hz1vfhzaqa07dii-stdenv-linux/setup: line 114: $'\r': command not found >
I supposed that the problem is linked to the different way linux and window( see this website) have to break a line. I wanted to adapt the file that caused a problem with:
preConfigure = ''
# dos2unix -f /nix/store/v099hqvw5z87423p4hz1vfhzaqa07dii-stdenv-linux/setup
# '';
but it change nothing. Therefore I comment it but you can uncomment it to test it yourself.
Although the error message said that the problem comes from a file that is not the flake.nix that I developed, the problems comes from the flake.nix that I developed. I write the code using code opened from windows. Hence it use the dos encoding.
run nix develop in another directory containing this flake
{
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};
in {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
pkgs.dos2unix
];
};
});
}
You can now run
dos2unix flake.nix
in the directory with the flake returning an error. it changed the encoding. And you can now run
nix develop
with this flake and it will work fine
The answer comes from VTimofeenko who wrote it there : https://discourse.nixos.org/t/what-could-cause-this-flake-to-fail-on-my-computer-and-succeed-on-another/41868/2