Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A derivation to merge multiple outputs #36883

Closed
veprbl opened this issue Mar 12, 2018 · 3 comments · Fixed by #36886
Closed

A derivation to merge multiple outputs #36883

veprbl opened this issue Mar 12, 2018 · 3 comments · Fixed by #36886

Comments

@veprbl
Copy link
Member

veprbl commented Mar 12, 2018

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
@matthewbauer
Copy link
Member

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

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

@markuskowa
Copy link
Member

Another alternative is symlinkJoin. For example:

fftwAll = symlinkJoin {
  name ="fftw-all";
  paths = [ fftw.dev fftw.out ];
};

@veprbl
Copy link
Member Author

veprbl commented Mar 12, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants