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