summary refs log tree commit diff
path: root/pkgs/development/idris-modules/build-idris-package.nix
blob: 0416e76afa9e0a06e78fbe90742a77f94aaff086 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Build an idris package
{ stdenv, idrisPackages, gmp }:
  { idrisDeps ? []
  , name
  , version
  , src
  , meta
  , extraBuildInputs ? []
  , postUnpack ? ""
  , doCheck ? true
  }:
let
  idris-with-packages = idrisPackages.with-packages idrisDeps;
in
stdenv.mkDerivation ({

  name = "${name}-${version}";

  inherit postUnpack src doCheck meta;


  # 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 = ''
    ${idris-with-packages}/bin/idris --build *.ipkg
  '';

  checkPhase = ''
    if grep -q test *.ipkg; then
      ${idris-with-packages}/bin/idris --testpkg *.ipkg
    fi
  '';

  installPhase = ''
    ${idris-with-packages}/bin/idris --install *.ipkg --ibcsubdir $out/libs
  '';

  buildInputs = [ gmp ] ++ extraBuildInputs;

  propagatedBuildInputs = idrisDeps;
})