2024-03-03 06:05:39 +03:00
|
|
|
{ stdenv, lib, chez, clang, gmp, fetchFromGitHub, makeWrapper, installShellFiles, support, idris2Version
|
2022-10-28 21:29:30 +03:00
|
|
|
, srcRev, gambit, nodejs, zsh, idris2Bootstrap ? null }:
|
2021-01-15 20:20:52 +03:00
|
|
|
|
|
|
|
# Uses scheme to bootstrap the build of idris2
|
2023-12-27 17:14:03 +03:00
|
|
|
let
|
|
|
|
bootstrap = idris2Bootstrap == null;
|
|
|
|
supportLibrariesPath = lib.makeLibraryPath [ support ];
|
|
|
|
supportSharePath = lib.makeSearchPath "share" [ support ];
|
|
|
|
in
|
2021-01-15 20:20:52 +03:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "idris2";
|
2024-01-22 08:05:26 +03:00
|
|
|
version = idris2Version;
|
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;
|
2024-03-03 06:05:39 +03:00
|
|
|
nativeBuildInputs = [ makeWrapper installShellFiles clang chez ]
|
2022-10-28 21:29:30 +03:00
|
|
|
++ lib.optional stdenv.isDarwin [ zsh ]
|
2024-03-03 06:05:39 +03:00
|
|
|
++ lib.optional (!bootstrap) [ idris2Bootstrap ];
|
2023-12-27 17:14:03 +03:00
|
|
|
buildInputs = [ chez gmp support ];
|
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
|
2022-10-28 21:29:30 +03:00
|
|
|
sed 's/$(GIT_SHA1)/${srcRev}/' -i Makefile
|
2021-01-15 20:20:52 +03:00
|
|
|
'';
|
|
|
|
|
2023-12-27 17:14:03 +03:00
|
|
|
makeFlags = [ "IDRIS2_SUPPORT_DIR=${supportLibrariesPath}" ]
|
|
|
|
++ lib.optional stdenv.isDarwin "OS=";
|
2021-01-15 20:20:52 +03:00
|
|
|
|
|
|
|
# The name of the main executable of pkgs.chez is `scheme`
|
2023-12-27 17:14:03 +03:00
|
|
|
buildFlags = [ "PREFIX=$(out)" ] ++
|
|
|
|
lib.optional bootstrap [
|
|
|
|
"bootstrap" "SCHEME=scheme"
|
|
|
|
"IDRIS2_DATA=${supportSharePath}"
|
|
|
|
"IDRIS2_LIBS=${supportLibrariesPath}"
|
|
|
|
];
|
2021-01-15 20:20:52 +03:00
|
|
|
|
2023-12-27 17:14:03 +03:00
|
|
|
# checks happen against built compiler prior to the postInstall
|
|
|
|
# wrapper below so we must augment some paths to point at prebuilt
|
|
|
|
# support paths regardless of whether we are bootstrapping or not.
|
2021-04-14 18:39:32 +03:00
|
|
|
checkInputs = [ gambit nodejs ]; # racket ];
|
2023-12-27 17:14:03 +03:00
|
|
|
checkFlags = [
|
|
|
|
"INTERACTIVE="
|
|
|
|
"IDRIS2_DATA=${supportSharePath}"
|
|
|
|
"IDRIS2_LIBS=${supportLibrariesPath}"
|
|
|
|
"TEST_IDRIS2_DATA=${supportSharePath}"
|
|
|
|
"TEST_IDRIS2_LIBS=${supportLibrariesPath}"
|
|
|
|
"TEST_IDRIS2_SUPPORT_DIR=${supportLibrariesPath}"
|
|
|
|
];
|
|
|
|
|
2024-01-06 00:59:11 +03:00
|
|
|
installTargets = "install-idris2 install-with-src-libs";
|
2023-12-27 17:14:03 +03:00
|
|
|
installFlags = [ "PREFIX=$(out)" ];
|
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
|
|
|
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"}' \
|
2023-12-27 17:14:03 +03:00
|
|
|
--suffix IDRIS2_LIBS ':' "${supportLibrariesPath}" \
|
|
|
|
--suffix IDRIS2_DATA ':' "${supportSharePath}" \
|
2021-06-28 13:47:47 +03:00
|
|
|
--suffix IDRIS2_PACKAGE_PATH ':' "${globalLibrariesPath}" \
|
2023-12-27 17:14:03 +03:00
|
|
|
--suffix LD_LIBRARY_PATH ':' "${supportLibrariesPath}" \
|
|
|
|
--suffix DYLD_LIBRARY_PATH ':' "${supportLibrariesPath}" \
|
2024-03-03 06:05:39 +03:00
|
|
|
|
|
|
|
installShellCompletion --cmd idris2 \
|
|
|
|
--bash <($out/bin/idris2 --bash-completion-script idris2) \
|
|
|
|
--zsh <($out/bin/idris2 --zsh-completion-script idris2) \
|
2021-01-15 20:20:52 +03:00
|
|
|
'';
|
|
|
|
}
|