Idris2/nix/buildIdris.nix
Matthieu Coudron 6780874d2e nix flake: make it more idiomatic
so that one can pass attributes directly to buildIdris instead of the
convoluted.
buildIdris (...).build.overrideAttrs(oldAttrs: {})
2021-09-07 16:34:45 +01:00

51 lines
1.1 KiB
Nix

{ stdenv
, lib
, idris2-version
, idris2
}:
{
src
, projectName
, idrisLibraries
, ...
}@attrs:
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 // {
name = projectName;
src = src;
nativeBuildInputs = [ idris2 ];
configurePhase = ''
runHook preConfigure
export IDRIS2_PACKAGE_PATH=${lib-dirs}
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
idris2 --build ${ipkgName}
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mv build/exec/* $out/bin
runHook postInstall
'';
});
installLibrary = build.overrideAttrs (_: {
buildPhase = "";
installPhase = ''
mkdir -p $out/${libSuffix}
export IDRIS2_PREFIX=$out/lib
idris2 --install ${ipkgName}
'';
});
}