1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/pkgs/development/idris-modules/build-idris-package.nix
2018-09-18 10:38:59 +02:00

62 lines
1.6 KiB
Nix

# Build an idris package
{ stdenv, lib, idrisPackages, gmp }:
{ idrisDeps ? []
, noPrelude ? false
, noBase ? false
, name
, version
, ipkgName ? name
, extraBuildInputs ? []
, ...
}@attrs:
let
allIdrisDeps = idrisDeps
++ lib.optional (!noPrelude) idrisPackages.prelude
++ lib.optional (!noBase) idrisPackages.base;
idris-with-packages = idrisPackages.with-packages allIdrisDeps;
newAttrs = builtins.removeAttrs attrs [
"idrisDeps" "noPrelude" "noBase"
"name" "version" "ipkgName" "extraBuildInputs"
] // {
meta = attrs.meta // {
platforms = attrs.meta.platforms or idrisPackages.idris.meta.platforms;
};
};
in
stdenv.mkDerivation ({
name = "idris-${name}-${version}";
buildInputs = [ idris-with-packages gmp ] ++ extraBuildInputs;
propagatedBuildInputs = allIdrisDeps;
# Some packages use the style
# opts = -i ../../path/to/package
# rather than the declarative pkgs attribute so we have to rewrite the path.
postPatch = ''
runHook prePatch
sed -i ${ipkgName}.ipkg -e "/^opts/ s|-i \\.\\./|-i ${idris-with-packages}/libs/|g"
'';
buildPhase = ''
runHook preBuild
idris --build ${ipkgName}.ipkg
runHook postBuild
'';
checkPhase = ''
runHook preCheck
if grep -q tests ${ipkgName}.ipkg; then
idris --testpkg ${ipkgName}.ipkg
fi
runHook postCheck
'';
installPhase = ''
runHook preInstall
idris --install ${ipkgName}.ipkg --ibcsubdir $out/libs
IDRIS_DOC_PATH=$out/doc idris --installdoc ${ipkgName}.ipkg || true
runHook postInstall
'';
} // newAttrs)