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