Getting full build dir path at buildPhase

I wrote the following derivative:

with import <nixpkgs> {};

stdenv.mkDerivation rec {
  pname = "rosie";
  version = "1.2.1";

  src = fetchgit {
    url = "https://gitlab.com/rosie-pattern-language/rosie.git";
    rev = "v${version}";
    sha256 = "1fgp48q9xn8fc4zbpyc2issmmc6lrdsxpa93nk3xaj0qcj6kgz78";
  };

  buildInputs = [ libbsd readline ];

  buildPhase = ''
    build_path=$(pwd)

    substituteInPlace src/build_info.sh \
      --replace '#!/bin/bash' '#!/usr/bin/env bash'
    substituteInPlace Makefile \
      --replace 'git submodule init' 'true' \
      --replace 'git submodule update --checkout' 'true'

    make DESTDIR=$out BUILD_ROOT=$PWD
  '';

  installPhase = ''
    make install DESTDIR=$out
  '';

  meta = with stdenv.lib; {
    homepage = "https://rosie-lang.org/";
    description = "A supercharged alternative to regular expressions (regex), matching patterns against any input text";
    license = licenses.mit;
    maintainers = [ maintainers.suhr ];
    platforms = platforms.linux;
  };
}

When I try to build it, I get the following error:

cd /build/rosie/submodules/lua && rm -f include && ln -sf src include
cp -p /build/rosie/submodules/lua/README submodules/~~present~~
/bin/sh: /build/rosie/src/build_info.sh: not found
make: *** [Makefile:181: submodules/~~present~~] Error 127

It looks like $PWD returns only a part of the path to the build dir. But how do I obtain the full path?

1 Like