Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 23.05 117 lines 3.0 kB view raw
1{ lib, stdenv, fetchFromGitHub, glfw, freetype, openssl, makeWrapper, upx, boehmgc, xorg, binaryen, darwin }: 2 3let 4 version = "weekly.2023.19"; 5 ptraceSubstitution = '' 6 #include <sys/types.h> 7 #include <sys/ptrace.h> 8 ''; 9 # Required for bootstrap. 10 vc = stdenv.mkDerivation { 11 pname = "v.c"; 12 version = "unstable-2023-05-14"; 13 src = fetchFromGitHub { 14 owner = "vlang"; 15 repo = "vc"; 16 rev = "f7c2b5f2a0738d0d236161c9de9f31dd0280ac86"; 17 sha256 = "sha256-xU3TvyNgc0o4RCsHtoC6cZTNaue2yuAiolEOvP37TKA="; 18 }; 19 20 # patch the ptrace reference for darwin 21 installPhase = lib.optionalString stdenv.isDarwin '' 22 substituteInPlace v.c \ 23 --replace "#include <sys/ptrace.h>" "${ptraceSubstitution}" 24 '' + '' 25 mkdir -p $out 26 cp v.c $out/ 27 ''; 28 }; 29 # Required for vdoc. 30 markdown = fetchFromGitHub { 31 owner = "vlang"; 32 repo = "markdown"; 33 rev = "6e970bd0a7459ad7798588f1ace4aa46c5e789a2"; 34 hash = "sha256-hFf7c8ZNMU1j7fgmDakuO7tBVr12Wq0dgQddJnkMajE="; 35 }; 36 boehmgcStatic = boehmgc.override { 37 enableStatic = true; 38 }; 39in 40stdenv.mkDerivation { 41 pname = "vlang"; 42 inherit version; 43 44 src = fetchFromGitHub { 45 owner = "vlang"; 46 repo = "v"; 47 rev = version; 48 sha256 = "sha256-fHn1z2q3LmSycCOa1ii4DoHvbEW4uJt3Psq3/VuZNVQ="; 49 }; 50 51 propagatedBuildInputs = [ glfw freetype openssl ] 52 ++ lib.optional stdenv.hostPlatform.isUnix upx; 53 54 nativeBuildInputs = [ makeWrapper ]; 55 56 buildInputs = [ 57 binaryen 58 ] ++ lib.optionals stdenv.isDarwin [ 59 darwin.apple_sdk.frameworks.Cocoa 60 ] ++ lib.optionals stdenv.isLinux [ 61 xorg.libX11 62 xorg.libXau 63 xorg.libXdmcp 64 xorg.xorgproto 65 ]; 66 67 makeFlags = [ 68 "local=1" 69 ]; 70 71 env.VC = vc; 72 73 preBuild = '' 74 export HOME=$(mktemp -d) 75 mkdir -p ./thirdparty/tcc/lib 76 cp -r ${boehmgcStatic}/lib/* ./thirdparty/tcc/lib 77 ''; 78 79 # vcreate_test.v requires git, so we must remove it when building the tools. 80 preInstall = '' 81 mv cmd/tools/vcreate/vcreate_test.v $HOME/vcreate_test.v 82 ''; 83 84 installPhase = '' 85 runHook preInstall 86 87 mkdir -p $out/{bin,lib,share} 88 cp -r examples $out/share 89 cp -r {cmd,vlib,thirdparty} $out/lib 90 cp v $out/lib 91 ln -s $out/lib/v $out/bin/v 92 wrapProgram $out/bin/v --prefix PATH : ${lib.makeBinPath [ stdenv.cc ]} 93 94 mkdir -p $HOME/.vmodules; 95 ln -sf ${markdown} $HOME/.vmodules/markdown 96 $out/lib/v -v build-tools 97 $out/lib/v -v $out/lib/cmd/tools/vdoc 98 $out/lib/v -v $out/lib/cmd/tools/vast 99 $out/lib/v -v $out/lib/cmd/tools/vvet 100 101 runHook postInstall 102 ''; 103 104 # Return vcreate_test.v and vtest.v, so the user can use it. 105 postInstall = '' 106 cp $HOME/vcreate_test.v $out/lib/cmd/tools/vcreate_test.v 107 ''; 108 109 meta = with lib; { 110 homepage = "https://vlang.io/"; 111 description = "Simple, fast, safe, compiled language for developing maintainable software"; 112 license = licenses.mit; 113 maintainers = with maintainers; [ Madouura ]; 114 mainProgram = "v"; 115 platforms = platforms.all; 116 }; 117}