Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 148 lines 3.1 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fontconfig, 6 freetype, 7 libX11, 8 libXext, 9 libXt, 10 xorgproto, 11 perl, # For building web manuals 12 which, 13 ed, 14 DarwinTools, # For building on Darwin 15}: 16 17stdenv.mkDerivation rec { 18 pname = "plan9port"; 19 version = "2025-01-29"; 20 21 src = fetchFromGitHub { 22 owner = "9fans"; 23 repo = pname; 24 rev = "a5d6857a3b912b43c88ef298c28d13d4623f9ef0"; 25 sha256 = "0c23z56zygrsyr96ml7907mpfgx80vnsy99nqr3nmfw1a045mjgv"; 26 }; 27 28 postPatch = '' 29 substituteInPlace bin/9c \ 30 --replace 'which uniq' '${which}/bin/which uniq' 31 32 ed -sE INSTALL <<EOF 33 # get /bin:/usr/bin out of PATH 34 /^PATH=[^ ]*/s,,PATH=\$PATH:\$PLAN9/bin, 35 # no xcbuild nonsense 36 /^if.* = Darwin/+;/^fi/-c 37 ${"\t"}export NPROC=$NIX_BUILD_CORES 38 . 39 # remove absolute include paths from fontsrv test 40 /cc -o a.out -c -I.*freetype2/;/x11.c/j 41 s/(-Iinclude).*-I[^ ]*/\1/ 42 wq 43 EOF 44 ''; 45 46 nativeBuildInputs = [ ed ]; 47 buildInputs = [ 48 perl 49 which 50 ] 51 ++ ( 52 if !stdenv.hostPlatform.isDarwin then 53 [ 54 fontconfig 55 freetype # fontsrv uses these 56 libX11 57 libXext 58 libXt 59 xorgproto 60 ] 61 else 62 [ 63 DarwinTools 64 ] 65 ); 66 67 configurePhase = '' 68 runHook preConfigure 69 cat >LOCAL.config <<EOF 70 CC9='$(command -v $CC)' 71 CFLAGS='$NIX_CFLAGS_COMPILE' 72 LDFLAGS='$(for f in $NIX_LDFLAGS; do echo "-Wl,$f"; done | xargs echo)' 73 ${lib.optionalString (!stdenv.hostPlatform.isDarwin) "X11='${libXt.dev}/include'"} 74 EOF 75 76 # make '9' available in the path so there's some way to find out $PLAN9 77 cat >LOCAL.INSTALL <<EOF 78 #!$out/plan9/bin/rc 79 mkdir $out/bin 80 ln -s $out/plan9/bin/9 $out/bin/ 81 EOF 82 chmod +x LOCAL.INSTALL 83 84 # now, not in fixupPhase, so ./INSTALL works 85 patchShebangs . 86 runHook postConfigure 87 ''; 88 89 buildPhase = '' 90 runHook preBuild 91 PLAN9_TARGET=$out/plan9 ./INSTALL -b 92 runHook postBuild 93 ''; 94 95 installPhase = '' 96 runHook preInstall 97 mkdir $out 98 cp -r . $out/plan9 99 cd $out/plan9 100 101 ./INSTALL -c 102 runHook postInstall 103 ''; 104 105 dontPatchShebangs = true; 106 107 doInstallCheck = true; 108 installCheckPhase = '' 109 $out/bin/9 rc -c 'echo rc is working.' 110 111 # 9l can find and use its libs 112 cd $TMP 113 cat >test.c <<EOF 114 #include <u.h> 115 #include <libc.h> 116 #include <thread.h> 117 void 118 threadmain(int argc, char **argv) 119 { 120 threadexitsall(nil); 121 } 122 EOF 123 $out/bin/9 9c -o test.o test.c 124 $out/bin/9 9l -o test test.o 125 ./test 126 ''; 127 128 meta = with lib; { 129 homepage = "https://9fans.github.io/plan9port/"; 130 description = "Plan 9 from User Space"; 131 longDescription = '' 132 Plan 9 from User Space (aka plan9port) is a port of many Plan 9 programs 133 from their native Plan 9 environment to Unix-like operating systems. 134 ''; 135 license = licenses.mit; 136 maintainers = with maintainers; [ 137 bbarker 138 ehmry 139 ftrvxmtrx 140 kovirobi 141 matthewdargan 142 ylh 143 ]; 144 mainProgram = "9"; 145 platforms = platforms.unix; 146 }; 147} 148# TODO: investigate the mouse chording support patch