about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/vlang/default.nix
blob: f72ec0890543b7e17e4d7ef6452c85f3114c98c5 (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, fetchFromGitHub, glfw, freetype, openssl }:

stdenv.mkDerivation rec {
  pname = "vlang";
  version = "0.1.18";

  src = fetchFromGitHub {
    owner = "vlang";
    repo = "v";
    rev = version;
    sha256 = "0js92v2r1h4vaaha3z1spgi7qynlmr9vls41gxp284w4yhnjzv15";
  };

  # V compiler source translated to C for bootstrap.
  vc = fetchFromGitHub {
    owner = "vlang";
    repo = "vc";
    rev = version;
    sha256 = "0qx1drs1hr94w7vaaq5w8mkq7j1d3biffnmxkyz63yv8573k03bj";
  };

  enableParallelBuilding = true;
  buildInputs = [ glfw freetype openssl ];

  buildPhase = ''
    runHook preBuild
    cc -std=gnu11 $CFLAGS -w -o v $vc/v.c -lm $LDFLAGS
    ./v -prod -o v compiler
    make thirdparty
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall
    mkdir -p $out/{bin,lib/vlang,share/vlang}
    cp -r examples $out/share/vlang
    cp -r {vlib,thirdparty} $out/lib/vlang
    cp v $out/lib/vlang
    ln -s $out/lib/vlang/v $out/bin/v
    runHook postInstall
  '';

  meta = with stdenv.lib; {
    homepage = "https://vlang.io/";
    description = "Simple, fast, safe, compiled language for developing maintainable software";
    license = licenses.mit;
    maintainers = with maintainers; [ chiiruno ];
    platforms = platforms.all;
  };
}