There are some builds (mostly cmake-based) that accept a prefix path to static and shared libraries $prefix/lib and $prefix/include. This becomes a problem when the derivation puts includes and static libraries into separate outputs, so that there is no such common prefix. To work around this, we end up needing to patch the build scripts, which is a burden. I was wondering if there can be a general solution to this. I propose creating a wrapper derivation that would instantiate into a path with symlinks to all outputs:
For example if foo instantiates to:
/nix/store/abcd...-foo/lib/libfoo.so
and foo.dev instantiates to:
/nix/store/qwer...-foo/lib/libfoo.a
/nix/store/qwer...-foo/include/foo.h
Then proposed symlink_combine [foo foo.dev] would instantiate to something like:
/nix/store/zxcv...-foo/lib/libfoo.so -> /nix/store/abcd...-foo/lib/libfoo.so
/nix/store/zxcv...-foo/lib/libfoo.a -> /nix/store/qwer...-foo/lib/libfoo.a
/nix/store/zxcv...-foo/include/foo.h -> /nix/store/qwer...-foo/include/foo.h
I think buildEnv can do this now. Just something like:
buildEnv {
name = "test";
paths = [foo];
extraOutputsToInstall = [ "dev" "out" ];
}
Another alternative is symlinkJoin. For example:
fftwAll = symlinkJoin {
name ="fftw-all";
paths = [ fftw.dev fftw.out ];
};
Great! Thank you. I like symlinkJoin more since its shorter and it is clearly used in nixpkgs for the same purpose as what I had in mind.
I've opened #36886 to document this.
Most helpful comment
I think buildEnv can do this now. Just something like: