title: Failed when `nix-build hello.nix`
body: <p>I followed the steps on <a href="http://lethalman.blogspot.com/2014/08/nix-pill-8-generic-builders.html" rel="nofollow noreferrer">http://lethalman.blogspot.com/2014/08/nix-pill-8-generic-builders.html</a> to build GNU Hello, and here is the files I used to build GNU hello 2.9:</p>
  
  <pre><code>$ wget -c http://ftp.gnu.org/gnu/hello/hello-2.9.tar.gz
  </code></pre>
  
  <p>hello.nix:</p>
  
  <pre><code>$ cat hello.nix
  let
    pkgs = import &lt;nixpkgs&gt; {};
    mkDerivation = import ./autotools.nix pkgs;
  in mkDerivation {
    name = "hello";
    src = ./hello-2.9.tar.gz;
  }
  </code></pre>
  
  <p>autotools.nix:</p>
  
  <pre><code>$ cat autotools.nix
  pkgs: attrs:
    with pkgs;
    let defaultAttrs = {
      builder = "${bash}/bin/bash";
      args = [ ./builder.sh ];
      baseInputs = [ gnutar gzip gnumake gcc binutils coreutils gawk gnused gnugrep ];
      buildInputs = [];
      system = builtins.currentSystem;
    };
    in
    derivation (defaultAttrs // attrs)
  </code></pre>
  
  <p>builder.sh:</p>
  
  <pre><code>$ cat builder.sh
  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
  </code></pre>
  
  <p>Error messages: </p>
  
  <pre><code>$ nix-build hello.nix
  these derivations will be built:
    /nix/store/d84l57agx3rmw00lxs8gjlw8srmx1bh9-hello.drv
  building '/nix/store/d84l57agx3rmw00lxs8gjlw8srmx1bh9-hello.drv'...
  /nix/store/vv3xqdggviqqbvym25jf2pwv575y9j1r-builder.sh: line 7: tar: No such file or directory
  builder for '/nix/store/d84l57agx3rmw00lxs8gjlw8srmx1bh9-hello.drv' failed with exit code 127
  error: build of '/nix/store/d84l57agx3rmw00lxs8gjlw8srmx1bh9-hello.drv' failed
  </code></pre>
  
  <p>It seems there is <code>gnutar</code> in the <code>autotools.nix</code> but builder still complains <code>tar: No such file or directory</code>, why is this?</p>