2022-01-13 20:06:32 +00:00
|
|
|
# Almost 1:1 copy of idris2's nix/platform.nix. Some work done in their flake.nix
|
|
|
|
# we do here instead.
|
|
|
|
{ stdenv
|
|
|
|
, lib
|
2021-06-28 23:13:55 +00:00
|
|
|
, chez
|
2022-01-13 20:06:32 +00:00
|
|
|
, chez-racket
|
|
|
|
, clang
|
2021-06-28 23:13:55 +00:00
|
|
|
, gmp
|
2022-01-13 20:06:32 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, makeWrapper
|
|
|
|
, gambit
|
|
|
|
, nodejs
|
2021-06-28 23:13:55 +00:00
|
|
|
, zsh
|
2021-12-24 04:21:11 +00:00
|
|
|
, callPackage
|
2020-05-29 06:06:01 +00:00
|
|
|
}:
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
# NOTICE: An `idris2WithPackages` is available at: https://github.com/claymager/idris2-pkgs
|
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
let
|
|
|
|
# Taken from Idris2/idris2/flake.nix. Check if the idris2 project does it this
|
|
|
|
# way, still, every now and then.
|
|
|
|
platformChez = if stdenv.system == "x86_64-linux" then chez else chez-racket;
|
2020-05-29 06:06:01 +00:00
|
|
|
# Uses scheme to bootstrap the build of idris2
|
2022-01-13 20:06:32 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
2020-09-25 04:45:31 +00:00
|
|
|
pname = "idris2";
|
2022-10-30 15:09:59 +00:00
|
|
|
version = "0.6.0";
|
2020-05-29 06:06:01 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "idris-lang";
|
|
|
|
repo = "Idris2";
|
2020-06-18 07:06:33 +00:00
|
|
|
rev = "v${version}";
|
2022-10-30 15:09:59 +00:00
|
|
|
sha256 = "sha256-80MAGM1IEtI09h5aCYfDL4PRrjGq2gT8OUEibOVk8H4=";
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
strictDeps = true;
|
2022-01-13 20:06:32 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper clang platformChez ]
|
2022-10-30 15:09:59 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ zsh ];
|
2022-01-13 20:06:32 +00:00
|
|
|
buildInputs = [ platformChez gmp ];
|
2020-05-29 06:06:01 +00:00
|
|
|
|
|
|
|
prePatch = ''
|
|
|
|
patchShebangs --build tests
|
|
|
|
'';
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
makeFlags = [ "PREFIX=$(out)" ]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optional stdenv.isDarwin "OS=";
|
2020-05-29 06:06:01 +00:00
|
|
|
|
|
|
|
# The name of the main executable of pkgs.chez is `scheme`
|
2021-06-28 23:13:55 +00:00
|
|
|
buildFlags = [ "bootstrap" "SCHEME=scheme" ];
|
2020-06-18 07:06:33 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
checkTarget = "test";
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ gambit nodejs ]; # racket ];
|
2022-01-13 20:06:32 +00:00
|
|
|
checkFlags = [ "INTERACTIVE=" ];
|
2020-05-29 06:06:01 +00:00
|
|
|
|
2020-09-25 04:45:31 +00: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}";
|
2022-01-13 20:06:32 +00:00
|
|
|
globalLibraries = [
|
|
|
|
"\\$HOME/.nix-profile/lib/${name}"
|
|
|
|
"/run/current-system/sw/lib/${name}"
|
|
|
|
"$out/${name}"
|
|
|
|
];
|
|
|
|
globalLibrariesPath = builtins.concatStringsSep ":" globalLibraries;
|
2020-09-25 04:45:31 +00:00
|
|
|
in ''
|
|
|
|
# Remove existing idris2 wrapper that sets incorrect LD_LIBRARY_PATH
|
|
|
|
rm $out/bin/idris2
|
2022-01-13 20:06:32 +00:00
|
|
|
# The only thing we need from idris2_app is the actual binary
|
2020-09-25 04:45:31 +00:00
|
|
|
mv $out/bin/idris2_app/idris2.so $out/bin/idris2
|
|
|
|
rm $out/bin/idris2_app/*
|
|
|
|
rmdir $out/bin/idris2_app
|
|
|
|
# idris2 needs to find scheme at runtime to compile
|
2022-01-13 20:06:32 +00: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.
|
2020-09-25 04:45:31 +00:00
|
|
|
# TODO: Make support libraries their own derivation such that
|
|
|
|
# overriding LD_LIBRARY_PATH is unnecessary
|
|
|
|
wrapProgram "$out/bin/idris2" \
|
2022-01-13 20:06:32 +00:00
|
|
|
--set-default CHEZ "${platformChez}/bin/scheme" \
|
|
|
|
--run 'export IDRIS2_PREFIX=''${IDRIS2_PREFIX-"$HOME/.idris2"}' \
|
2020-09-25 04:45:31 +00:00
|
|
|
--suffix IDRIS2_LIBS ':' "$out/${name}/lib" \
|
|
|
|
--suffix IDRIS2_DATA ':' "$out/${name}/support" \
|
2022-01-13 20:06:32 +00:00
|
|
|
--suffix IDRIS2_PACKAGE_PATH ':' "${globalLibrariesPath}" \
|
|
|
|
--suffix DYLD_LIBRARY_PATH ':' "$out/${name}/lib" \
|
|
|
|
--suffix LD_LIBRARY_PATH ':' "$out/${name}/lib"
|
2020-05-29 06:06:01 +00:00
|
|
|
'';
|
|
|
|
|
2021-12-24 04:21:11 +00:00
|
|
|
# Run package tests
|
|
|
|
passthru.tests = callPackage ./tests.nix { inherit pname; };
|
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
meta = {
|
|
|
|
description = "A purely functional programming language with first class types";
|
2020-06-18 07:06:33 +00:00
|
|
|
homepage = "https://github.com/idris-lang/Idris2";
|
2021-02-05 17:12:51 +00:00
|
|
|
license = lib.licenses.bsd3;
|
2021-06-28 23:13:55 +00:00
|
|
|
maintainers = with lib.maintainers; [ fabianhjr wchresta ];
|
2020-06-18 07:06:33 +00:00
|
|
|
inherit (chez.meta) platforms;
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
}
|