nixpkgs/pkgs/development/idris-modules/build-idris-package.nix

62 lines
1.6 KiB
Nix
Raw Normal View History

2015-11-27 19:17:17 +01:00
# Build an idris package
2018-07-02 05:18:08 +02:00
{ stdenv, lib, idrisPackages, gmp }:
{ idrisDeps ? []
, noPrelude ? false
, noBase ? false
, name
, version
2018-09-18 10:38:59 +02:00
, ipkgName ? name
, extraBuildInputs ? []
2018-07-02 05:18:08 +02:00
, ...
}@attrs:
let
allIdrisDeps = idrisDeps
++ lib.optional (!noPrelude) idrisPackages.prelude
++ lib.optional (!noBase) idrisPackages.base;
idris-with-packages = idrisPackages.with-packages allIdrisDeps;
2018-09-18 10:38:59 +02:00
newAttrs = builtins.removeAttrs attrs [
"idrisDeps" "noPrelude" "noBase"
"name" "version" "ipkgName" "extraBuildInputs"
] // {
2018-07-02 05:18:08 +02:00
meta = attrs.meta // {
platforms = attrs.meta.platforms or idrisPackages.idris.meta.platforms;
};
};
in
stdenv.mkDerivation ({
name = "idris-${name}-${version}";
2018-07-02 05:18:08 +02:00
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 = ''
2018-09-18 10:38:59 +02:00
runHook prePatch
sed -i ${ipkgName}.ipkg -e "/^opts/ s|-i \\.\\./|-i ${idris-with-packages}/libs/|g"
'';
buildPhase = ''
2018-09-18 10:38:59 +02:00
runHook preBuild
idris --build ${ipkgName}.ipkg
runHook postBuild
'';
checkPhase = ''
2018-09-18 10:38:59 +02:00
runHook preCheck
if grep -q tests ${ipkgName}.ipkg; then
idris --testpkg ${ipkgName}.ipkg
fi
2018-09-18 10:38:59 +02:00
runHook postCheck
'';
installPhase = ''
2018-09-18 10:38:59 +02:00
runHook preInstall
idris --install ${ipkgName}.ipkg --ibcsubdir $out/libs
IDRIS_DOC_PATH=$out/doc idris --installdoc ${ipkgName}.ipkg || true
runHook postInstall
'';
2015-11-27 17:03:04 +01:00
2018-07-02 05:18:08 +02:00
} // newAttrs)