Idris2/nix/package.nix
Las Safin ca95781a74 flake.nix: Use Racket's Chez for non-x86_64-linux platforms
It supports many more platforms, excerpt from the README:
> Supported platforms:
>
>     Windows: x86, x86_64
>     Mac OS: x86, x86_64, AArch64, PowerPC32
>     Linux: x86, x86_64, ARMv6, AArch64, PowerPC32
>     FreeBSD: x86, x86_64, ARMv6, AArch64, PowerPC32
>     OpenBSD: x86, x86_64, ARMv6, AArch64, PowerPC32
>     NetBSD: x86, x86_64, ARMv6, AArch64, PowerPC32
>     Solaris: x86, x86_64
>     Android: ARMv7, AArch64
>     iOS: AArch64

Link to the fork: https://github.com/racket/ChezScheme
2021-08-06 08:54:14 +02:00

76 lines
2.2 KiB
Nix

{ stdenv
, lib
, chez
, clang
, gmp
, fetchFromGitHub
, makeWrapper
, idris2-version
, srcRev
, gambit
, nodejs
, zsh
}:
# Uses scheme to bootstrap the build of idris2
stdenv.mkDerivation rec {
pname = "idris2";
version = idris2-version;
src = ../.;
strictDeps = true;
nativeBuildInputs = [ makeWrapper clang chez ]
++ lib.optional stdenv.isDarwin [ zsh ];
buildInputs = [ chez gmp ];
prePatch = let match = "$\{GIT_SHA1}"; in
''
patchShebangs --build tests
sed 's/${match}/${srcRev}/' -i Makefile
'';
makeFlags = [ "PREFIX=$(out)" ]
++ lib.optional stdenv.isDarwin "OS=";
# The name of the main executable of pkgs.chez is `scheme`
buildFlags = [ "bootstrap" "SCHEME=scheme" ];
checkInputs = [ gambit nodejs ]; # racket ];
checkFlags = [ "INTERACTIVE=" ];
# 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}";
globalLibraries = [
"\\$HOME/.nix-profile/lib/${name}"
"/run/current-system/sw/lib/${name}"
"$out/${name}"
];
globalLibrariesPath = builtins.concatStringsSep ":" globalLibraries;
in ''
# Remove existing idris2 wrapper that sets incorrect LD_LIBRARY_PATH
rm $out/bin/idris2
# The only thing we need from idris2_app is the actual binary
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
# 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.
# 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" \
--set-default IDRIS2_PREFIX "~/.idris2" \
--suffix IDRIS2_LIBS ':' "$out/${name}/lib" \
--suffix IDRIS2_DATA ':' "$out/${name}/support" \
--suffix IDRIS2_PACKAGE_PATH ':' "${globalLibrariesPath}" \
--suffix LD_LIBRARY_PATH ':' "$out/${name}/lib"
'';
}