nixpkgs/pkgs/development/compilers/vlang/default.nix

56 lines
1.6 KiB
Nix
Raw Normal View History

2019-10-03 22:47:40 +02:00
{ stdenv, fetchFromGitHub, glfw, freetype, openssl, upx ? null }:
assert stdenv.hostPlatform.isUnix -> upx != null;
2019-07-29 20:36:27 +02:00
stdenv.mkDerivation rec {
pname = "vlang";
2019-10-03 22:47:40 +02:00
version = "0.1.21";
2019-07-29 20:36:27 +02:00
src = fetchFromGitHub {
owner = "vlang";
repo = "v";
2019-09-09 01:38:31 +02:00
rev = version;
2019-10-03 22:47:40 +02:00
sha256 = "0npd7a7nhd6r9mr99naib9scqk30209hz18nxif27284ckjbl4fk";
2019-07-29 20:36:27 +02:00
};
# V compiler source translated to C for bootstrap.
2019-10-03 22:47:40 +02:00
# Use matching v.c release commit for now, 0.1.21 release is not available.
2019-07-29 20:36:27 +02:00
vc = fetchFromGitHub {
owner = "vlang";
repo = "vc";
2019-10-03 22:47:40 +02:00
rev = "950a90b6acaebad1c6ddec5486fc54307e38a9cd";
sha256 = "1dh5l2m207rip1xj677hvbp067inw28n70ddz5wxzfpmaim63c0l";
2019-07-29 20:36:27 +02:00
};
enableParallelBuilding = true;
propagatedBuildInputs = [ glfw freetype openssl ]
2019-10-03 22:47:40 +02:00
++ stdenv.lib.optional stdenv.hostPlatform.isUnix upx;
2019-07-29 20:36:27 +02:00
buildPhase = ''
runHook preBuild
2019-08-23 08:56:42 +02:00
cc -std=gnu11 $CFLAGS -w -o v $vc/v.c -lm $LDFLAGS
2019-10-03 22:47:40 +02:00
./v -prod -cflags `$CFLAGS` -o v compiler
# Exclude thirdparty/vschannel as it is windows-specific.
find thirdparty -path thirdparty/vschannel -prune -o -type f -name "*.c" -execdir cc -std=gnu11 $CFLAGS -w -c {} $LDFLAGS ';'
2019-07-29 20:36:27 +02:00
runHook postBuild
'';
installPhase = ''
runHook preInstall
2019-10-03 22:47:40 +02:00
mkdir -p $out/{bin,lib,share}
cp -r examples $out/share
cp -r {vlib,thirdparty} $out/lib
cp v $out/lib
ln -s $out/lib/v $out/bin/v
2019-07-29 20:36:27 +02:00
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;
};
}