Nixpkgs: A derivation to merge multiple outputs

Created on 12 Mar 2018  路  3Comments  路  Source: NixOS/nixpkgs

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

Most helpful comment

I think buildEnv can do this now. Just something like:

buildEnv {
  name = "test";
  paths = [foo];
  extraOutputsToInstall = [ "dev" "out" ];
}

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grahamc picture grahamc  路  88Comments

nico202 picture nico202  路  70Comments

joepie91 picture joepie91  路  102Comments

worldofpeace picture worldofpeace  路  103Comments

fdietze picture fdietze  路  144Comments