2023-05-24 13:37:59 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, glfw, freetype, openssl, makeWrapper, upx, boehmgc, xorg, binaryen, darwin }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
let
|
2023-11-16 04:20:00 +00:00
|
|
|
version = "weekly.2023.44";
|
2023-05-24 13:37:59 +00:00
|
|
|
ptraceSubstitution = ''
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ptrace.h>
|
|
|
|
'';
|
2022-05-18 14:49:53 +00:00
|
|
|
# Required for bootstrap.
|
2023-05-24 13:37:59 +00:00
|
|
|
vc = stdenv.mkDerivation {
|
|
|
|
pname = "v.c";
|
2023-11-16 04:20:00 +00:00
|
|
|
version = "unstable-2023-10-30";
|
2023-05-24 13:37:59 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "vlang";
|
|
|
|
repo = "vc";
|
2023-11-16 04:20:00 +00:00
|
|
|
rev = "66b89ab916c13c5781753797d1f4ff08e427bb6b";
|
|
|
|
hash = "sha256-5Y7/rlcoIHjbf79A1rqFysNFc5+p6CY09MRPQalo7Ak=";
|
2023-05-24 13:37:59 +00:00
|
|
|
};
|
2022-05-18 14:49:53 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
# patch the ptrace reference for darwin
|
|
|
|
installPhase = lib.optionalString stdenv.isDarwin ''
|
|
|
|
substituteInPlace v.c \
|
|
|
|
--replace "#include <sys/ptrace.h>" "${ptraceSubstitution}"
|
|
|
|
'' + ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp v.c $out/
|
|
|
|
'';
|
|
|
|
};
|
2022-05-18 14:49:53 +00:00
|
|
|
# Required for vdoc.
|
|
|
|
markdown = fetchFromGitHub {
|
|
|
|
owner = "vlang";
|
|
|
|
repo = "markdown";
|
2023-11-16 04:20:00 +00:00
|
|
|
rev = "61c47ea0a6c0c79e973a119dcbab3b8fdd0973ca";
|
|
|
|
hash = "sha256-XBD30Pc9CGXzU1Gy6U0pDpTozYVwfgAvZRjIsnXp8ZM=";
|
2023-05-24 13:37:59 +00:00
|
|
|
};
|
|
|
|
boehmgcStatic = boehmgc.override {
|
|
|
|
enableStatic = true;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "vlang";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "vlang";
|
|
|
|
repo = "v";
|
|
|
|
rev = version;
|
2023-11-16 04:20:00 +00:00
|
|
|
hash = "sha256-1yFuheSyKfvm4GqKIbXycdzKx3XcD9LSmmuKlcJmteg=";
|
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 ];
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
buildInputs = [
|
|
|
|
binaryen
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
darwin.apple_sdk.frameworks.Cocoa
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
|
|
|
xorg.libX11
|
|
|
|
xorg.libXau
|
|
|
|
xorg.libXdmcp
|
|
|
|
xorg.xorgproto
|
|
|
|
];
|
|
|
|
|
2021-08-12 14:41:47 +00:00
|
|
|
makeFlags = [
|
|
|
|
"local=1"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
env.VC = vc;
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
preBuild = ''
|
|
|
|
export HOME=$(mktemp -d)
|
2023-05-24 13:37:59 +00:00
|
|
|
mkdir -p ./thirdparty/tcc/lib
|
|
|
|
cp -r ${boehmgcStatic}/lib/* ./thirdparty/tcc/lib
|
2022-05-18 14:49:53 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# vcreate_test.v requires git, so we must remove it when building the tools.
|
|
|
|
preInstall = ''
|
2023-05-24 13:37:59 +00:00
|
|
|
mv cmd/tools/vcreate/vcreate_test.v $HOME/vcreate_test.v
|
2022-05-18 14:49:53 +00:00
|
|
|
'';
|
|
|
|
|
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
|
2023-11-16 04:20:00 +00:00
|
|
|
$out/lib/v -v $out/lib/cmd/tools/vcreate
|
2022-05-18 14:49:53 +00:00
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
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;
|
2023-11-16 04:20:00 +00:00
|
|
|
maintainers = with maintainers; [ Madouura delta231 ];
|
2022-05-18 14:49:53 +00:00
|
|
|
mainProgram = "v";
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|