2021-08-12 14:41:47 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, glfw, freetype, openssl, makeWrapper, upx }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "vlang";
|
2022-05-18 14:49:53 +00:00
|
|
|
version = "weekly.2022.20";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "vlang";
|
|
|
|
repo = "v";
|
|
|
|
rev = version;
|
2022-05-18 14:49:53 +00:00
|
|
|
sha256 = "1isbyfs98bdbm2qjf7q4bqbpsmdiqlavn3gznwr12bkvhnsf4j3x";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
# Required for bootstrap.
|
2020-04-24 23:36:52 +00:00
|
|
|
vc = fetchFromGitHub {
|
|
|
|
owner = "vlang";
|
|
|
|
repo = "vc";
|
2022-05-18 14:49:53 +00:00
|
|
|
rev = "167f262866090493650f58832d62d910999dd5a4";
|
|
|
|
sha256 = "1xax8355qkrccjcmx24gcab88xnrqj15mhqy0bgp3v2rb1hw1n3a";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Required for vdoc.
|
|
|
|
markdown = fetchFromGitHub {
|
|
|
|
owner = "vlang";
|
|
|
|
repo = "markdown";
|
|
|
|
rev = "bbbd324a361e404ce0682fc00666df3a7877b398";
|
|
|
|
sha256 = "0cawzizr3rjz81blpvxvxrcvcdai1adj66885ss390444qq1fnv7";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ glfw freetype openssl ]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optional stdenv.hostPlatform.isUnix upx;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-12 14:41:47 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"local=1"
|
|
|
|
"VC=${vc}"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
preBuild = ''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
'';
|
|
|
|
|
|
|
|
# vcreate_test.v requires git, so we must remove it when building the tools.
|
|
|
|
# vtest.v fails on Darwin, so let's just disable it for now.
|
|
|
|
preInstall = ''
|
|
|
|
mv cmd/tools/vcreate_test.v $HOME/vcreate_test.v
|
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
mv cmd/tools/vtest.v $HOME/vtest.v
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2022-05-18 14:49:53 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir -p $out/{bin,lib,share}
|
|
|
|
cp -r examples $out/share
|
2021-06-28 23:13:55 +00:00
|
|
|
cp -r {cmd,vlib,thirdparty} $out/lib
|
2022-05-18 14:49:53 +00:00
|
|
|
cp v $out/lib
|
2020-04-24 23:36:52 +00:00
|
|
|
ln -s $out/lib/v $out/bin/v
|
2021-08-12 14:41:47 +00:00
|
|
|
wrapProgram $out/bin/v --prefix PATH : ${lib.makeBinPath [ stdenv.cc ]}
|
2022-05-18 14:49:53 +00:00
|
|
|
|
|
|
|
mkdir -p $HOME/.vmodules;
|
|
|
|
ln -sf ${markdown} $HOME/.vmodules/markdown
|
|
|
|
$out/lib/v -v build-tools
|
|
|
|
$out/lib/v -v $out/lib/cmd/tools/vdoc
|
|
|
|
$out/lib/v -v $out/lib/cmd/tools/vast
|
|
|
|
$out/lib/v -v $out/lib/cmd/tools/vvet
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
# Return vcreate_test.v and vtest.v, so the user can use it.
|
|
|
|
postInstall = ''
|
|
|
|
cp $HOME/vcreate_test.v $out/lib/cmd/tools/vcreate_test.v
|
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
cp $HOME/vtest.v $out/lib/cmd/tools/vtest.v
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://vlang.io/";
|
|
|
|
description = "Simple, fast, safe, compiled language for developing maintainable software";
|
|
|
|
license = licenses.mit;
|
2022-04-27 09:35:20 +00:00
|
|
|
maintainers = with maintainers; [ Madouura ];
|
2022-05-18 14:49:53 +00:00
|
|
|
mainProgram = "v";
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|