Out-of-tree build

From NixOS Wiki
Revision as of 15:29, 23 May 2022 by imported>Milahu (create page: Out-of-tree build)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

By default, stdenv.mkDerivation will run configure and make in the source root,
but some projects require an out-of-tree build

Example: the build script

./autogen.sh

# out-of-tree build
mkdir build
cd build

../configure --enable-feature-a

make

make install

can be translated to the Nix expression

stdenv.mkDerivation {

  preConfigure = ''
    patchShebangs .
    ./autogen.sh

    mkdir build
    cd build
  '';

  configureScript = "../configure";

  configureFlags = [
    "--enable-feature-a"
  ];
}