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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

88 lines
2.3 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchFromGitHub, glfw, freetype, openssl, makeWrapper, upx }:
2019-07-29 20:36:27 +02:00
stdenv.mkDerivation rec {
pname = "vlang";
2022-05-17 13:23:29 +02:00
version = "weekly.2022.20";
2019-07-29 20:36:27 +02:00
src = fetchFromGitHub {
owner = "vlang";
repo = "v";
2019-09-09 01:38:31 +02:00
rev = version;
2022-05-17 13:23:29 +02:00
sha256 = "1isbyfs98bdbm2qjf7q4bqbpsmdiqlavn3gznwr12bkvhnsf4j3x";
2019-07-29 20:36:27 +02:00
};
# Required for bootstrap.
2019-07-29 20:36:27 +02:00
vc = fetchFromGitHub {
owner = "vlang";
repo = "vc";
2022-05-17 13:23:29 +02:00
rev = "167f262866090493650f58832d62d910999dd5a4";
sha256 = "1xax8355qkrccjcmx24gcab88xnrqj15mhqy0bgp3v2rb1hw1n3a";
2019-07-29 20:36:27 +02:00
};
# Required for vdoc.
markdown = fetchFromGitHub {
owner = "vlang";
repo = "markdown";
rev = "bbbd324a361e404ce0682fc00666df3a7877b398";
sha256 = "0cawzizr3rjz81blpvxvxrcvcdai1adj66885ss390444qq1fnv7";
};
propagatedBuildInputs = [ glfw freetype openssl ]
++ lib.optional stdenv.hostPlatform.isUnix upx;
2019-07-29 20:36:27 +02:00
nativeBuildInputs = [ makeWrapper ];
makeFlags = [
"local=1"
"VC=${vc}"
];
2019-07-29 20:36:27 +02:00
2022-05-17 13:23:29 +02:00
preBuild = ''
export HOME=$(mktemp -d)
2022-05-17 13:23:29 +02:00
'';
# 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
'';
2019-07-29 20:36:27 +02:00
installPhase = ''
runHook preInstall
2019-10-03 22:47:40 +02:00
mkdir -p $out/{bin,lib,share}
cp -r examples $out/share
2021-06-26 15:02:25 +02:00
cp -r {cmd,vlib,thirdparty} $out/lib
cp v $out/lib
2019-10-03 22:47:40 +02:00
ln -s $out/lib/v $out/bin/v
wrapProgram $out/bin/v --prefix PATH : ${lib.makeBinPath [ stdenv.cc ]}
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
2019-07-29 20:36:27 +02:00
runHook postInstall
'';
2022-05-17 13:23:29 +02: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
'';
meta = with lib; {
2019-07-29 20:36:27 +02:00
homepage = "https://vlang.io/";
description = "Simple, fast, safe, compiled language for developing maintainable software";
license = licenses.mit;
maintainers = with maintainers; [ Madouura ];
mainProgram = "v";
2019-07-29 20:36:27 +02:00
platforms = platforms.all;
};
}