Created
June 6, 2018 23:48
-
-
Save coreyoconnor/198e331bd585606ff5d35de17872eddf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self: super: | |
let | |
lib = self.lib; | |
in with lib; | |
let | |
inherit (self) boehmgc libunwind re2 llvmPackages zlib makeWrapper; | |
c-pkgs = [ re2 zlib boehmgc libunwind llvmPackages.libraries.libcxxabi ]; | |
cplus-pkgs = [ llvmPackages.libraries.libcxx ]; | |
CPATH = makeSearchPathOutput "dev" "include" c-pkgs; | |
CPLUS_INCLUDE_PATH = makeSearchPathOutput "dev" "include/c++/v1" cplus-pkgs; | |
lib-pkgs = c-pkgs ++ cplus-pkgs; | |
libdir-out = replaceStrings [":"] ["\n"] (makeLibraryPath lib-pkgs); | |
# llvm-config proxy that emits the additional include and library directories. | |
# scala-native assumes llvm+config + /usr/local/lib is sufficient. | |
# until scala-native is patched this is cheap and easy. | |
llvm-config-proxy = self.writeShellScriptBin "llvm-config" '' | |
case "$1" in | |
--libdir) | |
${llvmPackages.llvm}/bin/llvm-config --libdir | |
echo "${libdir-out}" | |
exit | |
;; | |
*) | |
exec ${llvmPackages.llvm}/bin/llvm-config "$@" | |
;; | |
esac | |
''; | |
# the compile server seems to not inherit the env vars? | |
clang-proxy = self.writeShellScriptBin "clang" '' | |
exec ${llvmPackages.libcxxClang}/bin/clang "$@" | |
''; | |
clangxx-proxy = self.writeShellScriptBin "clang++" '' | |
exec ${llvmPackages.libcxxClang}/bin/clang++ -Wl,-lc++abi -stdlib=libc++ "$@" | |
''; | |
in { | |
sbt-with-scala-native = self.sbt.overrideDerivation (old: { | |
nativeBuildInputs = [ makeWrapper ]; | |
postFixup = '' | |
wrapProgram $out/bin/sbt \ | |
--prefix PATH : "${makeBinPath [llvm-config-proxy]}" \ | |
--prefix CPATH : "${CPATH}:${CPLUS_INCLUDE_PATH}" \ | |
--set CLANG_PATH "${clang-proxy}/bin/clang" \ | |
--set CLANGPP_PATH "${clangxx-proxy}/bin/clang++" | |
''; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment