summaryrefslogtreecommitdiff
path: root/pkgs/fetch-ant-deps.nix
blob: 69e29b4140e11bc9d260336be73eb8860e00a444 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
  lib,
  stdenv,
  ant,
  buildPackages,
}:

lib.makeOverridable (
  lib.fetchers.withNormalizedHash { } (
    {
      pname,
      nativeBuildInputs ? [ ],
      antJdk ? buildPackages.jdk,
      outputHash,
      outputHashAlgo,
      ...
    }@args:

    let
      args' = lib.removeAttrs args [
        "pname"
        "nativeBuildInputs"
        "antJdk"
      ];
    in

    stdenv.mkDerivation (
      lib.recursiveUpdate {
        pname = pname + "-ant-deps";

        nativeBuildInputs = [ ant ] ++ nativeBuildInputs;

        buildPhase = ''
          runHook preBuild
          ant init
          runHook postBuild
        '';

        installPhase = ''
          runHook preInstall
          mv bin/libs $out
          runHook postInstall
        '';

        fixupPhase = ''
          runHook preFixup

          find $out -type f \( \
            -name \*.lastUpdated \
            -o -name resolver-status.properties \
            -o -name _remote.repositories \) \
            -delete

          runHook postFixup
        '';

        dontConfigure = true;

        env = {
          JAVA_HOME = toString (antJdk.passthru.home or antJdk);
        };

        inherit outputHash outputHashAlgo;
        outputHashMode = "recursive";
      } args'
    )
  )
)