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

48 lines
1.2 KiB
Nix
Raw Normal View History

2015-11-27 18:17:17 +00:00
# Build an idris package
2018-07-02 03:18:08 +00:00
{ stdenv, lib, idrisPackages, gmp }:
{ idrisDeps ? []
2018-07-02 03:18:08 +00:00
, includePreludeBase ? true
, name
, version
, extraBuildInputs ? []
2018-07-02 03:18:08 +00:00
, ...
}@attrs:
let
2018-07-02 03:18:08 +00:00
idrisDeps' = idrisDeps ++ lib.optionals includePreludeBase (with idrisPackages; [ prelude base ]);
idris-with-packages = idrisPackages.with-packages idrisDeps';
newAttrs = builtins.removeAttrs attrs [ "idrisDeps" "extraBuildInputs" "name" "version" ] // {
meta = attrs.meta // {
platforms = attrs.meta.platforms or idrisPackages.idris.meta.platforms;
};
};
in
stdenv.mkDerivation ({
name = "${name}-${version}";
2018-07-02 03:18:08 +00:00
buildInputs = [ idris-with-packages gmp ] ++ extraBuildInputs;
propagatedBuildInputs = idrisDeps';
# 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"
'';
buildPhase = ''
2018-07-02 03:18:08 +00:00
idris --build *.ipkg
'';
checkPhase = ''
if grep -q test *.ipkg; then
2018-07-02 03:18:08 +00:00
idris --testpkg *.ipkg
fi
'';
installPhase = ''
2018-07-02 03:18:08 +00:00
idris --install *.ipkg --ibcsubdir $out/libs
IDRIS_DOC_PATH=$out/doc idris --installdoc *.ipkg || true
'';
2015-11-27 16:03:04 +00:00
2018-07-02 03:18:08 +00:00
} // newAttrs)