Idris2/nix/buildIdris.nix

42 lines
1.1 KiB
Nix
Raw Normal View History

{ stdenv, lib, idris2-version, idris2 }:
{ src, projectName, idrisLibraries, ... }@attrs:
2021-03-15 17:21:50 +03:00
let
ipkgName = projectName + ".ipkg";
idrName = "idris2-${idris2-version}";
libSuffix = "lib/${idrName}";
lib-dirs =
lib.strings.concatMapStringsSep ":" (p: "${p}/${libSuffix}") idrisLibraries;
drvAttrs = builtins.removeAttrs attrs [ "idrisLibraries" ];
in rec {
build = stdenv.mkDerivation (drvAttrs // {
2021-03-15 17:21:50 +03:00
name = projectName;
src = src;
nativeBuildInputs = [ idris2 ];
2021-03-15 17:21:50 +03:00
configurePhase = ''
runHook preConfigure
2021-03-15 17:21:50 +03:00
export IDRIS2_PACKAGE_PATH=${lib-dirs}
runHook postConfigure
2021-03-15 17:21:50 +03:00
'';
buildPhase = ''
runHook preBuild
2021-03-15 17:21:50 +03:00
idris2 --build ${ipkgName}
runHook postBuild
2021-03-15 17:21:50 +03:00
'';
installPhase = ''
runHook preInstall
2021-03-15 17:21:50 +03:00
mkdir -p $out/bin
mv build/exec/* $out/bin
runHook postInstall
2021-03-15 17:21:50 +03:00
'';
});
installLibrary = build.overrideAttrs (_: {
2021-03-15 17:21:50 +03:00
buildPhase = "";
installPhase = ''
2021-03-15 17:21:50 +03:00
mkdir -p $out/${libSuffix}
export IDRIS2_PREFIX=$out/lib
idris2 --install ${ipkgName}
'';
});
}