Hey!
I am running on NixOS 21.05.
I am stuck on completing the excercise in Nix Pills Chapter 8.3.
Exercise: Complete the new builder.sh
by adding $baseInputs
in the for
loop together with $buildInputs
. As you noticed, we passed that new variable in the derivation. Instead of merging buildInputs with the base ones, we prefer to preserve buildInputs as seen by the caller, so we keep them separated. Just a matter of choice.
I have limited bash experience, so I get stuck here. I suppose some bash knowledge is good to have, but I would rather get on with learning nix No idea how to do this, and the following Nix Pill seems to depend on it, where I get this message running the
nix-store -r
command:
❯ nix-store -r /nix/store/7rmv83d9lwhd4z37479irw54dlsg0qgg-hello.drv
this derivation will be built:
/nix/store/7rmv83d9lwhd4z37479irw54dlsg0qgg-hello.drv
building '/nix/store/7rmv83d9lwhd4z37479irw54dlsg0qgg-hello.drv'...
/nix/store/6k3q6g0w8pinmmmqy576xv434y3fsqjz-builder.sh: line 7: tar: No such file or director
Is it possible this could be related? Struggling to see if I have made any typos, but tried to just copy paste and I am getting the same results.
Here are the relevant files:
builder.sh (as mentioned, I didn’t know excactly what to do, so I left it as is):
set -e
unset PATH
for p in $buildInputs; do
export PATH=$p/bin${PATH:+:}$PATH
done
tar -xf $src
for d in *; do
if [ -d "$d" ]; then
cd "$d"
break
fi
done
./configure --prefix=$out
make
make install
autotools.nix:
pkgs: attrs:
with pkgs;
let defaultAttrs = {
builder = "${bash}/bin/bash";
args = [ ./builder.sh ];
baseInputs = [ gnutar gzip gnumake gcc binutils-unwrapped coreutils gawk gnused gnugrep ];
buildInputs = [ ];
system = builtins.currentSystem;
};
in
derivation (defaultAttrs // attrs)
hello.nix:
let
pkgs = import <nixpkgs> { };
mkDerivation = import ./autotools.nix pkgs;
in
mkDerivation {
name = "hello";
src = ./hello-2.10.tar.gz;
}
And as mentioned, I run this command per 9.3
nix-instantiate hello.nix
with the following output
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/7rmv83d9lwhd4z37479irw54dlsg0qgg-hello.drv
So far so good.
But when I run
nix-store -r /nix/store/7rmv83d9lwhd4z37479irw54dlsg0qgg-hello.drv
I get this:
this derivation will be built:
/nix/store/7rmv83d9lwhd4z37479irw54dlsg0qgg-hello.drv
building '/nix/store/7rmv83d9lwhd4z37479irw54dlsg0qgg-hello.drv'...
/nix/store/6k3q6g0w8pinmmmqy576xv434y3fsqjz-builder.sh: line 7: tar: No such file or directory
error: builder for '/nix/store/7rmv83d9lwhd4z37479irw54dlsg0qgg-hello.drv' failed with exit code 127;
last 1 log lines:
> /nix/store/6k3q6g0w8pinmmmqy576xv434y3fsqjz-builder.sh: line 7: tar: No such file or directory
For full logs, run 'nix log /nix/store/7rmv83d9lwhd4z37479irw54dlsg0qgg-hello.drv'.
I do have the hello-2.10.tar.gz
file in the same folder, downloaded from http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz. In earlier parts of the tutorial, I was successful in unpacking it.