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