about summary refs log tree commit diff
path: root/pkgs/development/tools/rund/default.nix
blob: e02e58fb893c13a8613aef6530cbf542c4c10d5c (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
47
48
49
50
{stdenv, lib, fetchFromGitHub, ldc ? null, dcompiler ? ldc }:

assert dcompiler != null;

stdenv.mkDerivation rec {
  pname = "rund";
  version = "1.0.0";

  src = fetchFromGitHub {
    owner = "dragon-lang";
    repo = pname;
    rev = "v${version}";
    sha256 = "10x6f1nn294r5qnpacrpcbp348dndz5fv4nz6ih55c61ckpkvgcf";
  };

  buildInputs = [ dcompiler ];
  buildPhase = ''
    for candidate in dmd ldmd2 gdmd; do
      echo Checking for DCompiler $candidate ...
      dc=$(type -P $candidate || echo "")
      if [ ! "$dc" == "" ]; then
        break
      fi
    done
    if [ "$dc" == "" ]; then
      exit "Error: could not find a D compiler"
    fi
    echo Using DCompiler $candidate
    $dc -I=$src/src -i -run $src/make.d build --out $NIX_BUILD_TOP
  '';

  doCheck = true;
  checkPhase = ''
    $NIX_BUILD_TOP/rund make.d test
  '';

  installPhase = ''
    mkdir -p $out/bin
    mv $NIX_BUILD_TOP/rund $out/bin
  '';

  meta = with lib; {
    description = "A compiler-wrapper that runs and caches D programs";
    mainProgram = "rund";
    homepage = "https://github.com/dragon-lang/rund";
    license = lib.licenses.boost;
    maintainers = with maintainers; [ jonathanmarler ];
    platforms = lib.platforms.unix;
  };
}