nixpkgs/pkgs/by-name/vl/vlang/package.nix

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

134 lines
2.9 KiB
Nix
Raw Normal View History

2023-05-16 16:53:18 +00:00
{
lib,
stdenv,
fetchFromGitHub,
glfw,
freetype,
openssl,
makeWrapper,
upx,
boehmgc,
xorg,
binaryen,
darwin,
}:
2019-07-29 18:36:27 +00:00
let
2024-10-11 09:59:13 +00:00
version = "0.4.8";
2023-05-16 11:34:12 +00:00
ptraceSubstitution = ''
#include <sys/types.h>
#include <sys/ptrace.h>
'';
2023-12-05 08:34:06 +00:00
# vc is the V compiler's source translated to C (needed for boostrap).
# So we fix its rev to correspond to the V version.
2023-05-16 11:34:12 +00:00
vc = stdenv.mkDerivation {
pname = "v.c";
2024-10-11 09:59:13 +00:00
version = "0.4.8";
2023-05-16 11:34:12 +00:00
src = fetchFromGitHub {
owner = "vlang";
repo = "vc";
2024-10-11 09:59:13 +00:00
rev = "54beb1f416b404a06b894e6883a0e2368d80bc3e";
hash = "sha256-hofganRnWPRCjjsItwF2BKam4dCqzMCrjgWSjZLSrlo=";
2023-05-16 11:34:12 +00:00
};
# patch the ptrace reference for darwin
installPhase =
lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace v.c \
--replace "#include <sys/ptrace.h>" "${ptraceSubstitution}"
''
+ ''
mkdir -p $out
cp v.c $out/
'';
2019-07-29 18:36:27 +00:00
};
# Required for vdoc.
markdown = fetchFromGitHub {
owner = "vlang";
repo = "markdown";
2023-12-05 08:34:06 +00:00
rev = "0c280130cb7ec410b7d21810d1247956c15b72fc";
hash = "sha256-Fmhkrg9DBiWxInostNp+WfA3V5GgEIs5+KIYrqZosqY=";
};
2023-05-16 16:53:18 +00:00
boehmgcStatic = boehmgc.override {
enableStatic = true;
2023-05-16 16:44:49 +00:00
};
in
stdenv.mkDerivation {
pname = "vlang";
inherit version;
src = fetchFromGitHub {
owner = "vlang";
repo = "v";
rev = version;
2024-10-11 09:59:13 +00:00
hash = "sha256-V4f14TcuKW8unzlo6i/tE6MzSb3HAll478OU2LxiTPQ=";
};
propagatedBuildInputs = [
glfw
freetype
openssl
] ++ lib.optional stdenv.hostPlatform.isUnix upx;
2019-07-29 18:36:27 +00:00
nativeBuildInputs = [ makeWrapper ];
2023-05-16 20:20:58 +00:00
buildInputs =
[
binaryen
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk.frameworks.Cocoa
]
++ lib.optionals stdenv.hostPlatform.isLinux [
xorg.libX11
xorg.libXau
xorg.libXdmcp
xorg.xorgproto
];
2023-05-16 16:44:49 +00:00
makeFlags = [
"local=1"
];
2019-07-29 18:36:27 +00:00
env.VC = vc;
2022-05-17 11:23:29 +00:00
preBuild = ''
export HOME=$(mktemp -d)
mkdir -p ./thirdparty/tcc/lib
2023-05-16 16:44:49 +00:00
cp -r ${boehmgcStatic}/lib/* ./thirdparty/tcc/lib
2022-05-17 11:23:29 +00:00
'';
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
2023-10-24 21:26:51 +00:00
$out/lib/v -v $out/lib/cmd/tools/vcreate
2019-07-29 18:36:27 +00:00
runHook postInstall
'';
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;
2023-11-06 16:18:28 +00:00
maintainers = with maintainers; [
Madouura
delta231
];
mainProgram = "v";
2019-07-29 18:36:27 +00:00
platforms = platforms.all;
};
}