2015-11-27 19:17:17 +01:00
|
|
|
# Build an idris package
|
2018-07-02 05:18:08 +02:00
|
|
|
{ stdenv, lib, idrisPackages, gmp }:
|
2017-11-06 19:18:59 +01:00
|
|
|
{ idrisDeps ? []
|
2018-07-03 21:19:28 +02:00
|
|
|
, noPrelude ? false
|
|
|
|
, noBase ? false
|
2017-11-06 19:18:59 +01:00
|
|
|
, name
|
|
|
|
, version
|
|
|
|
, extraBuildInputs ? []
|
2018-07-02 05:18:08 +02:00
|
|
|
, ...
|
|
|
|
}@attrs:
|
2017-11-06 19:18:59 +01:00
|
|
|
let
|
2018-07-03 21:19:28 +02:00
|
|
|
allIdrisDeps = idrisDeps
|
|
|
|
++ lib.optional (!noPrelude) idrisPackages.prelude
|
|
|
|
++ lib.optional (!noBase) idrisPackages.base;
|
|
|
|
idris-with-packages = idrisPackages.with-packages allIdrisDeps;
|
2018-07-02 05:18:08 +02:00
|
|
|
newAttrs = builtins.removeAttrs attrs [ "idrisDeps" "extraBuildInputs" "name" "version" ] // {
|
|
|
|
meta = attrs.meta // {
|
|
|
|
platforms = attrs.meta.platforms or idrisPackages.idris.meta.platforms;
|
|
|
|
};
|
|
|
|
};
|
2017-11-06 19:18:59 +01:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation ({
|
2018-07-13 22:43:33 +02:00
|
|
|
name = "idris-${name}-${version}";
|
2017-11-06 19:18:59 +01:00
|
|
|
|
2018-07-02 05:18:08 +02:00
|
|
|
buildInputs = [ idris-with-packages gmp ] ++ extraBuildInputs;
|
2018-07-03 21:19:28 +02:00
|
|
|
propagatedBuildInputs = allIdrisDeps;
|
2017-11-06 19:18:59 +01: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 = ''
|
|
|
|
sed -i *.ipkg -e "/^opts/ s|-i \\.\\./|-i ${idris-with-packages}/libs/|g"
|
2018-02-03 11:12:43 +01:00
|
|
|
'';
|
|
|
|
|
2015-11-27 15:35:59 +01:00
|
|
|
buildPhase = ''
|
2018-07-02 05:18:08 +02:00
|
|
|
idris --build *.ipkg
|
2015-11-27 15:35:59 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
if grep -q test *.ipkg; then
|
2018-07-02 05:18:08 +02:00
|
|
|
idris --testpkg *.ipkg
|
2015-11-27 15:35:59 +01:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2018-07-02 05:18:08 +02:00
|
|
|
idris --install *.ipkg --ibcsubdir $out/libs
|
|
|
|
IDRIS_DOC_PATH=$out/doc idris --installdoc *.ipkg || true
|
2015-11-27 15:35:59 +01:00
|
|
|
'';
|
2015-11-27 17:03:04 +01:00
|
|
|
|
2018-07-02 05:18:08 +02:00
|
|
|
} // newAttrs)
|