Last active
February 12, 2018 02:46
-
-
Save mnacamura/ce3b8e6640d54158df1863cb54e94ff8 to your computer and use it in GitHub Desktop.
Julia in nixpkgs: managed to handle external dependency on Darwin
This file contains 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
#!/usr/bin/env nix-shell --pure | |
with import <nixpkgs> {}; | |
let | |
d = version: "v${lib.concatStringsSep "." (lib.take 2 (lib.splitString "." version))}"; | |
extraLibs = [ mbedtls zlib zeromq3 ]; | |
in | |
stdenv.mkDerivation rec { | |
name = "julia-${version}-env"; | |
version = julia.version; | |
nativeBuildInputs = [ makeWrapper cacert git pkgconfig which ]; | |
buildInputs = [ | |
julia | |
jupyterEnv # my custom jupyter | |
] ++ extraLibs; | |
phases = [ "installPhase" ]; | |
installPhase = '' | |
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt | |
export JULIA_PKGDIR=/var/cache/julia | |
export LD_LIBRARY_PATH=${lib.makeLibraryPath extraLibs} | |
if [ ! -d $JULIA_PKGDIR/${d version}/METADATA ]; then | |
julia -e "Pkg.init()" | |
# else | |
# julia -e "Pkg.update()" | |
fi | |
pushd $JULIA_PKGDIR/${d version} | |
# Install ZMQ.jl manually to remove dependnecy to Hombrew.jl | |
[ -d ZMQ ] || git clone https://github.com/JuliaInterop/ZMQ.jl.git ZMQ | |
pushd ZMQ | |
sed -i 's#.*Homebrew.*##g' REQUIRE | |
sed -i 's#.*Homebrew.*##g' deps/build.jl | |
julia -e "Pkg.resolve(); Pkg.build(\"ZMQ\")" | |
popd | |
# Install MbedTLS.jl manually to remove dependnecy to Homebrew.jl | |
[ -d MbedTLS ] || git clone https://github.com/JuliaWeb/MbedTLS.jl.git MbedTLS | |
pushd MbedTLS | |
sed -i 's#.*Homebrew.*##g' REQUIRE | |
sed -i 's#.*Homebrew.*##g' deps/build.jl | |
julia -e "Pkg.resolve(); Pkg.build(\"MbedTLS\")" | |
popd | |
julia -e "Pkg.add(\"IJulia\")" | |
# export JUPYTER=${jupyterEnv}/bin/jupyter | |
# export HOME=... | |
# julia -e "Pkg.build(\"IJulia\")" # install the kernelspec | |
popd | |
makeWrapper ${julia}/bin/julia $out/bin/julia \ | |
--prefix LD_LIBRARY_PATH : "$LD_LIBRARY_PATH" \ | |
--set JULIA_PKGDIR $JULIA_PKGDIR | |
# --set JULIA_LOAD_PATH $JULIA_PKGDIR/${d version} | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment