2021-01-22 11:25:31 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, glfw, freetype, openssl, upx ? null }:
|
2019-10-03 21:47:40 +01:00
|
|
|
|
|
|
|
assert stdenv.hostPlatform.isUnix -> upx != null;
|
2019-07-29 19:36:27 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "vlang";
|
2021-06-26 14:02:25 +01:00
|
|
|
version = "weekly.2021.25";
|
2019-07-29 19:36:27 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "vlang";
|
|
|
|
repo = "v";
|
2019-09-09 00:38:31 +01:00
|
|
|
rev = version;
|
2021-06-26 14:02:25 +01:00
|
|
|
sha256 = "0y4a5rmpcdqina32d6azbmsbi3zqqfl413sicg72x6a1pm2vg33j";
|
2019-07-29 19:36:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# V compiler source translated to C for bootstrap.
|
2019-10-03 21:47:40 +01:00
|
|
|
# Use matching v.c release commit for now, 0.1.21 release is not available.
|
2019-07-29 19:36:27 +01:00
|
|
|
vc = fetchFromGitHub {
|
|
|
|
owner = "vlang";
|
|
|
|
repo = "vc";
|
2021-06-26 14:02:25 +01:00
|
|
|
rev = "3201d2dd2faadfa370da0bad2a749a664ad5ade3";
|
|
|
|
sha256 = "0xzkjdph5wfjr3qfkihgc27vsbbjh2l31rp8z2avq9hc531hwvrz";
|
2019-07-29 19:36:27 +01:00
|
|
|
};
|
|
|
|
|
2019-10-07 05:02:34 +01:00
|
|
|
propagatedBuildInputs = [ glfw freetype openssl ]
|
2021-01-22 11:25:31 +00:00
|
|
|
++ lib.optional stdenv.hostPlatform.isUnix upx;
|
2019-07-29 19:36:27 +01:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2019-08-23 07:56:42 +01:00
|
|
|
cc -std=gnu11 $CFLAGS -w -o v $vc/v.c -lm $LDFLAGS
|
2021-06-26 14:02:25 +01:00
|
|
|
# vlang seems to want to write to $HOME/.vmodules,
|
|
|
|
# so lets give it a writable HOME
|
|
|
|
HOME=$PWD ./v -prod self
|
2019-10-03 21:47:40 +01:00
|
|
|
# Exclude thirdparty/vschannel as it is windows-specific.
|
2019-10-07 05:02:34 +01:00
|
|
|
find thirdparty -path thirdparty/vschannel -prune -o -type f -name "*.c" -execdir cc -std=gnu11 $CFLAGS -w -c {} $LDFLAGS ';'
|
2019-07-29 19:36:27 +01:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2019-10-03 21:47:40 +01:00
|
|
|
mkdir -p $out/{bin,lib,share}
|
|
|
|
cp -r examples $out/share
|
2021-06-26 14:02:25 +01:00
|
|
|
cp -r {cmd,vlib,thirdparty} $out/lib
|
|
|
|
mv v $out/lib
|
2019-10-03 21:47:40 +01:00
|
|
|
ln -s $out/lib/v $out/bin/v
|
2019-07-29 19:36:27 +01:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2021-01-22 11:25:31 +00:00
|
|
|
meta = with lib; {
|
2019-07-29 19:36:27 +01:00
|
|
|
homepage = "https://vlang.io/";
|
|
|
|
description = "Simple, fast, safe, compiled language for developing maintainable software";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ chiiruno ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|