2021-01-20 23:15:24 +03:00
|
|
|
{ stdenv
|
2021-03-15 17:21:50 +03:00
|
|
|
, lib
|
2021-01-20 23:15:24 +03:00
|
|
|
, chez
|
|
|
|
, clang
|
2021-06-03 12:44:42 +03:00
|
|
|
, gmp
|
2021-01-20 23:15:24 +03:00
|
|
|
, fetchFromGitHub
|
|
|
|
, makeWrapper
|
2021-03-15 17:21:50 +03:00
|
|
|
, idris2-version
|
2021-06-29 02:35:54 +03:00
|
|
|
, srcRev
|
2021-04-14 18:39:32 +03:00
|
|
|
, gambit
|
|
|
|
, nodejs
|
2021-06-28 13:47:47 +03:00
|
|
|
, zsh
|
2021-01-15 20:20:52 +03:00
|
|
|
}:
|
|
|
|
|
|
|
|
# Uses scheme to bootstrap the build of idris2
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "idris2";
|
2021-03-15 17:21:50 +03:00
|
|
|
version = idris2-version;
|
2021-01-15 20:20:52 +03:00
|
|
|
|
2021-03-15 17:21:50 +03:00
|
|
|
src = ../.;
|
2021-01-15 20:20:52 +03:00
|
|
|
|
|
|
|
strictDeps = true;
|
2021-06-28 13:47:47 +03:00
|
|
|
nativeBuildInputs = [ makeWrapper clang chez ]
|
|
|
|
++ lib.optional stdenv.isDarwin [ zsh ];
|
2021-06-03 12:44:42 +03:00
|
|
|
buildInputs = [ chez gmp ];
|
2021-01-15 20:20:52 +03:00
|
|
|
|
2021-12-30 05:08:25 +03:00
|
|
|
prePatch = ''
|
2021-01-15 20:20:52 +03:00
|
|
|
patchShebangs --build tests
|
2021-12-30 05:08:25 +03:00
|
|
|
sed 's/''$(GIT_SHA1)/${srcRev}/' -i Makefile
|
2021-01-15 20:20:52 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
makeFlags = [ "PREFIX=$(out)" ]
|
2021-03-15 17:21:50 +03:00
|
|
|
++ lib.optional stdenv.isDarwin "OS=";
|
2021-01-15 20:20:52 +03:00
|
|
|
|
|
|
|
# The name of the main executable of pkgs.chez is `scheme`
|
2021-01-20 23:15:24 +03:00
|
|
|
buildFlags = [ "bootstrap" "SCHEME=scheme" ];
|
2021-01-15 20:20:52 +03:00
|
|
|
|
2021-04-14 18:39:32 +03:00
|
|
|
checkInputs = [ gambit nodejs ]; # racket ];
|
|
|
|
checkFlags = [ "INTERACTIVE=" ];
|
2021-01-15 20:20:52 +03:00
|
|
|
|
|
|
|
# TODO: Move this into its own derivation, such that this can be changed
|
|
|
|
# without having to recompile idris2 every time.
|
|
|
|
postInstall = let
|
|
|
|
name = "${pname}-${version}";
|
2021-06-28 13:47:47 +03:00
|
|
|
globalLibraries = [
|
|
|
|
"\\$HOME/.nix-profile/lib/${name}"
|
|
|
|
"/run/current-system/sw/lib/${name}"
|
|
|
|
"$out/${name}"
|
|
|
|
];
|
2021-03-15 17:21:50 +03:00
|
|
|
globalLibrariesPath = builtins.concatStringsSep ":" globalLibraries;
|
2021-01-15 20:20:52 +03:00
|
|
|
in ''
|
|
|
|
# Remove existing idris2 wrapper that sets incorrect LD_LIBRARY_PATH
|
|
|
|
rm $out/bin/idris2
|
2021-06-28 13:47:47 +03:00
|
|
|
|
|
|
|
# The only thing we need from idris2_app is the actual binary
|
2021-01-15 20:20:52 +03:00
|
|
|
mv $out/bin/idris2_app/idris2.so $out/bin/idris2
|
|
|
|
rm $out/bin/idris2_app/*
|
|
|
|
rmdir $out/bin/idris2_app
|
2021-06-28 13:47:47 +03:00
|
|
|
|
2021-01-15 20:20:52 +03:00
|
|
|
# idris2 needs to find scheme at runtime to compile
|
2021-06-28 13:47:47 +03:00
|
|
|
# idris2 installs packages with --install into the path given by
|
|
|
|
# IDRIS2_PREFIX. We set that to a default of ~/.idris2, to mirror the
|
|
|
|
# behaviour of the standard Makefile install.
|
2021-01-15 20:20:52 +03:00
|
|
|
# TODO: Make support libraries their own derivation such that
|
|
|
|
# overriding LD_LIBRARY_PATH is unnecessary
|
|
|
|
wrapProgram "$out/bin/idris2" \
|
|
|
|
--set-default CHEZ "${chez}/bin/scheme" \
|
2021-12-30 05:08:25 +03:00
|
|
|
--run 'export IDRIS2_PREFIX=''${IDRIS2_PREFIX-"$HOME/.idris2"}' \
|
2021-01-15 20:20:52 +03:00
|
|
|
--suffix IDRIS2_LIBS ':' "$out/${name}/lib" \
|
|
|
|
--suffix IDRIS2_DATA ':' "$out/${name}/support" \
|
2021-06-28 13:47:47 +03:00
|
|
|
--suffix IDRIS2_PACKAGE_PATH ':' "${globalLibrariesPath}" \
|
2021-12-30 05:08:25 +03:00
|
|
|
--suffix DYLD_LIBRARY_PATH ':' "$out/${name}/lib" \
|
2021-01-15 20:20:52 +03:00
|
|
|
--suffix LD_LIBRARY_PATH ':' "$out/${name}/lib"
|
|
|
|
'';
|
|
|
|
}
|