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

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

100 lines
3.5 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchFromGitHub, glfw, freetype, openssl, makeWrapper, upx, pkgsStatic, xorg, binaryen }:
2019-07-29 18:36:27 +00:00
let
version = "weekly.2023.19";
# Required for bootstrap.
2019-07-29 18:36:27 +00:00
vc = fetchFromGitHub {
owner = "vlang";
repo = "vc";
rev = "f7c2b5f2a0738d0d236161c9de9f31dd0280ac86";
sha256 = "sha256-xU3TvyNgc0o4RCsHtoC6cZTNaue2yuAiolEOvP37TKA=";
2019-07-29 18:36:27 +00:00
};
# Required for vdoc.
markdown = fetchFromGitHub {
owner = "vlang";
repo = "markdown";
rev = "6e970bd0a7459ad7798588f1ace4aa46c5e789a2";
hash = "sha256-hFf7c8ZNMU1j7fgmDakuO7tBVr12Wq0dgQddJnkMajE=";
};
in
stdenv.mkDerivation {
pname = "vlang";
inherit version;
src = fetchFromGitHub {
owner = "vlang";
repo = "v";
rev = version;
sha256 = "sha256-fHn1z2q3LmSycCOa1ii4DoHvbEW4uJt3Psq3/VuZNVQ=";
};
propagatedBuildInputs = [ glfw freetype openssl ]
++ lib.optional stdenv.hostPlatform.isUnix upx;
2019-07-29 18:36:27 +00:00
nativeBuildInputs = [ makeWrapper ];
makeFlags = [
"local=1"
];
2019-07-29 18:36:27 +00:00
env.VC = vc;
# libX11.dev and xorg.xorgproto are needed because of
# builder error: Header file <X11/Xlib.h>, needed for module `clipboard.x11` was not found. Please install a package with the X11 development headers, for example: `apt-get install libx11-dev`.
# libXau, libxcb, libXdmcp need to be static if you use static gcc otherwise
# /nix/store/xnk2z26fqy86xahiz3q797dzqx96sidk-glibc-2.37-8/lib/libc.so.6: undefined reference to `_rtld_glob al_ro@GLIBC_PRIVATE'
env.VFLAGS = "-cc ${pkgsStatic.gcc}/bin/gcc -no-retry-compilation -cflags -I${xorg.libX11.dev}/include -cflags -I${xorg.xorgproto}/include -ldflags -L${binaryen}/lib -ldflags -L${pkgsStatic.xorg.libX11}/lib -ldflags -L${pkgsStatic.xorg.libxcb}/lib -ldflags -lxcb -ldflags -L${pkgsStatic.xorg.libXau}/lib -ldflags -lXau -ldflags -L${pkgsStatic.xorg.libXdmcp}/lib -ldflags -lXdmcp";
2022-05-17 11:23:29 +00:00
preBuild = ''
export HOME=$(mktemp -d)
mkdir -p ./thirdparty/tcc/lib
# this step is not needed it's just to silence a warning
# we don't use tcc at all since it fails on a missing libatomic
ln -s ${pkgsStatic.tinycc}/bin/tcc ./thirdparty/tcc/tcc.exe
cp -r ${pkgsStatic.boehmgc}/lib/* ./thirdparty/tcc/lib
2022-05-17 11:23:29 +00: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/vcreate_test.v $HOME/vcreate_test.v
2022-05-17 11:23:29 +00:00
'' + lib.optionalString stdenv.isDarwin ''
mv cmd/tools/vtest.v $HOME/vtest.v
'';
2019-07-29 18:36:27 +00:00
installPhase = ''
runHook preInstall
2019-10-03 20:47:40 +00:00
mkdir -p $out/{bin,lib,share}
cp -r examples $out/share
2021-06-26 13:02:25 +00:00
cp -r {cmd,vlib,thirdparty} $out/lib
cp v $out/lib
2019-10-03 20:47:40 +00: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 18:36:27 +00:00
runHook postInstall
'';
2022-05-17 11:23:29 +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
'';
meta = with lib; {
2019-07-29 18:36:27 +00: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 18:36:27 +00:00
platforms = platforms.all;
};
}