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 Pill Nr. 10 builder.sh ./configure not found #124

Open
ThoenigAdrian opened this issue Jan 24, 2020 · 2 comments
Open

Nix Pill Nr. 10 builder.sh ./configure not found #124

ThoenigAdrian opened this issue Jan 24, 2020 · 2 comments

Comments

@ThoenigAdrian
Copy link

Trying out Nix Pill Nr. 10 Part 1:

It says:

source builder.sh

But this fails with :

bash: ./configure: No such file or directory

thus i added some debug code which print the directory name found by the builder.sh:

for d in *; do
  if [ "$src" == *"$d"* ] && [ -d "$d" ]; then
    cd "$d"
    echo "$d" # THIS IS THE DEBUG CODE I ADDED
    break
  fi
done

To my suprprise this prints "Desktop" instead of "hello-2.10" .
Which makes sense because this loop (iiuic) iterates over every file and if it's a directory it cd's into it.

jane@nixos:~]$ ls -l
total 6180
-rw-r--r-- 1 jane users 362 Jan 24 08:26 autotools.nix
-rw-r--r-- 1 jane users 371 Jan 24 09:47 builder.sh
drwxr-xr-x 2 jane users 4096 Dec 28 20:04 Desktop
drwxr-xr-x 2 jane users 4096 Dec 28 20:04 Documents
drwxr-xr-x 2 jane users 4096 Jan 21 10:44 Downloads
drwxr-xr-x 12 jane users 4096 Nov 16 2014 hello-2.10
-rw-r--r-- 1 jane users 725946 Jan 21 10:57 hello-2.10.tar.gz
-rw-r--r-- 1 jane users 140 Jan 24 09:31 hello.nix
[....]

and Desktop is the first directory therefore it will cd into "Desktop" instead of "hello-2.10" .

Imo this is a bug in builder.sh.

With the following workaround it will work:

mkdir empty
cp hello.nix ./empty/
cp autotools.nix ./empty/
cp hello-2.10-tar.gz ./empty/
cp builder.sh ./empty/

But I think the proper way would be to change the "cd"-logic in builder.sh

@jtojnar
Copy link
Member

jtojnar commented Jan 24, 2020

We could make the builder error out when there are multiple directories in $PWD like the real deal does

https://github.com/NixOS/nixpkgs/blob/40e51d2092f1011c110c895e2818636cc25d4f09/pkgs/stdenv/generic/setup.sh#L881-L904

but as you can see that would unnecessarily increase the builder complexity without adding didactic value.

It is common practice to run tutorials in their own directory, if just for the ease of clean up afterwards. It will probably be better to add such suggestion to https://nixos.org/nixos/nix-pills/working-derivation.html#idm140737316246784 instead.

@ThoenigAdrian
Copy link
Author

yes a note in the beginning would be fine as well :)

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