aboutsummaryrefslogtreecommitdiffhomepage
path: root/nix-overlays/dub/package.nix
blob: f13adecf81c3e6a81eacad18309db0a0b85feb52 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{ lib
, stdenv
, fetchFromGitHub
, curl
, ldc
, dcompiler ? ldc
, libevent
, rsync
}:

assert dcompiler != null;

stdenv.mkDerivation (finalAttrs: {
  pname = "dub";
  version = "1.38.1";

  enableParallelBuilding = true;

  src = fetchFromGitHub {
    owner = "dlang";
    repo = "dub";
    rev = "v${finalAttrs.version}";
    hash = "sha256-8Lr/0sx4SKwU1aNOxZArta0RXpDM+EWl29ZsPDdPWFo=";
  };

  postPatch = ''
    patchShebangs test
  '';

  nativeBuildInputs = [ dcompiler libevent rsync ];
  buildInputs = [ curl ];

  preBuild = ''
    for DCn in dmd ldmd2 gdmd; do
      echo "... check for D compiler $DCn ..."
      export DC=$(type -P $DCn || echo "")
      if [ ! "$DC" == "" ]; then
        break
      fi
    done
    if [ "$DC" == "" ]; then
      exit "Error: could not find D compiler"
    fi
    echo "$DCn found and used as D compiler in buildPhase for $pname"
  '';

  buildPhase = ''
    runHook preBuild
    $DC -run ./build.d
    runHook postBuild
  '';

  doCheck = !stdenv.hostPlatform.isDarwin;

  checkPhase = ''
    runHook preCheck
    export DUB=$NIX_BUILD_TOP/source/bin/dub
    export PATH=$PATH:$NIX_BUILD_TOP/source/bin/
    if [ "$DC" == "" ]; then
      exit "Error: could not find D compiler"
    fi
    echo "DC out --> $DC"
    export HOME=$TMP

    rm -rf test/issue502-root-import
    rm -r test/dpath-variable # requires execution of dpath-variable.sh
    rm -rf test/git-dependency
    rm -rf test/use-c-sources # added to build v1.33.0
    rm -rf test/pr2642-cache-db # added to build v1.34.0
    rm -rf test/pr2644-describe-artifact-path # added to build v1.36.0
    rm -rf test/pr2647-build-deep # added to build v1.36.0

    ./test/run-unittest.sh
    runHook postCheck
  '';

  installPhase = ''
    runHook preInstall
    install -Dm755 bin/dub $out/bin/dub
    runHook postInstall
  '';

  meta = with lib; {
    description = "Package and build manager for D programs and libraries";
    homepage = "https://code.dlang.org/";
    license = licenses.mit;
    mainProgram = "dub";
    maintainers = with maintainers; [ jtbx ];
    platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
  };
})