Idris2/nix/buildIdris.nix

41 lines
836 B
Nix
Raw Normal View History

2021-03-15 17:21:50 +03:00
{ stdenv
, lib
, projectName
, src
, idris2
, idris2-version
, idrisLibraries
}:
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;
2021-03-15 17:21:50 +03:00
in
rec {
build = stdenv.mkDerivation {
name = projectName;
src = src;
nativeBuildInputs = [ idris2 ];
2021-03-15 17:21:50 +03:00
configurePhase = ''
export IDRIS2_PACKAGE_PATH=${lib-dirs}
'';
buildPhase = ''
idris2 --build ${ipkgName}
'';
installPhase = ''
mkdir -p $out/bin
mv build/exec/* $out/bin
'';
};
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}
'';
});
}