Is it possible to include relative paths in build process without having to include entire root directory?
Given build config
with (import <nixpkgs> {});
pkgs.stdenv.mkDerivation {
pname = "mypackage";
version = "2.0.0";
srcs = [../hardcoded ./.];
setSourceRoot = ./.;
buildInputs = [tree];
buildPhase = ''
tree .
make
'';
}
I get
$ nix-build example.nix
this derivation will be built:
/nix/store/2j1vspqvy2r5i8kbdpp12ak7vl9rrc49-mypackage-2.0.0.drv
building '/nix/store/2j1vspqvy2r5i8kbdpp12ak7vl9rrc49-mypackage-2.0.0.drv'...
unpacking sources
unpacking source archive /nix/store/csh3kng8wrpa1lkqffkxni7wmcnq3iks-hardcoded
unpacking source archive /nix/store/ygx43wbhcy30mbv7b94sjr9knsvl3dyf-src
/nix/store/bj5n3k01mq8bysw0rcdm7jxvhc620pd3-stdenv-linux/setup: line 86: /nix/store/ygx43wbhcy30mbv7b94sjr9knsvl3dyf-src: Is a directory
error: builder for '/nix/store/2j1vspqvy2r5i8kbdpp12ak7vl9rrc49-mypackage-2.0.0.drv' failed with exit code 1;
last 4 log lines:
> unpacking sources
> unpacking source archive /nix/store/csh3kng8wrpa1lkqffkxni7wmcnq3iks-hardcoded
> unpacking source archive /nix/store/ygx43wbhcy30mbv7b94sjr9knsvl3dyf-src
> /nix/store/bj5n3k01mq8bysw0rcdm7jxvhc620pd3-stdenv-linux/setup: line 86: /nix/store/ygx43wbhcy30mbv7b94sjr9knsvl3dyf-src: Is a directory
For full logs, run 'nix log /nix/store/2j1vspqvy2r5i8kbdpp12ak7vl9rrc49-mypackage-2.0.0.drv'.
Let me guess, if you run ldd on it it tells you the interpreter is some variant of /lib/ld-linux.so? That file doesn’t exist on NixOS, the error is super unreadable, but that’s basically a Linux kernel problem.
NixOS cannot use precompiled, dynamically linked libraries without some additional work.
You’ll either need to patchelf the binary before you use it, or just package it. See this wiki entry for more details: Packaging/Binaries - NixOS Wiki