Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 107 lines 3.2 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchzip, 5 installShellFiles, 6 libX11, 7 ncurses, 8 pkg-config, 9 enableXwinGraphics ? false, 10}: 11 12let 13 options = [ 14 "${if enableXwinGraphics then "XWIN" else "CURSES"}GRAPHX" 15 "EXT94" 16 "PERMUTATE" 17 "RWLIMIT" 18 ]; 19 pkgConfigLibs = 20 lib.optionals enableXwinGraphics [ "x11" ] ++ lib.optionals (!enableXwinGraphics) [ "ncurses" ]; 21in 22stdenv.mkDerivation (finalAttrs: { 23 pname = "pmars"; 24 version = "0.9.4"; 25 26 src = fetchzip { 27 url = "http://www.koth.org/pmars/pmars-${finalAttrs.version}.zip"; 28 hash = "sha256-68zsH9HWWp13pozjMajayS/VhY8iTosUp1CvcAmj/dE="; 29 }; 30 31 patches = [ 32 # Error under Clang due to global "round" variable: redefinition of 'round' as different kind of symbol 33 ./0001-fix-round-redefinition.patch 34 35 # call to undeclared function 'sighandler' & undefined sighandler on Darwin 36 ./0002-fix-sighandler.patch 37 38 # ncurses' WINDOW struct was turned opaque for outside code, use functions for accessing values instead 39 ./0003-fix-ncurses-opaque-WINDOW.patch 40 ]; 41 42 postPatch = '' 43 substituteInPlace src/Makefile \ 44 --replace-fail 'CC = gcc' "CC = $CC" \ 45 --replace-fail '@strip' "@$STRIP" \ 46 --replace-fail 'CFLAGS = -O -DEXT94 -DXWINGRAPHX -DPERMUTATE -DRWLIMIT' "CFLAGS = ${ 47 lib.concatMapStringsSep " " (opt: "-D${opt}") options 48 } ${ 49 lib.optionalString ( 50 pkgConfigLibs != [ ] 51 ) "$($PKG_CONFIG --cflags ${lib.strings.concatStringsSep " " pkgConfigLibs})" 52 }" \ 53 --replace-fail 'LIB = -L/usr/X11R6/lib -lX11' "LIB = ${ 54 lib.optionalString ( 55 pkgConfigLibs != [ ] 56 ) "$($PKG_CONFIG --libs ${lib.strings.concatStringsSep " " pkgConfigLibs})" 57 }" 58 ''; 59 60 nativeBuildInputs = [ installShellFiles ] ++ lib.optionals (pkgConfigLibs != [ ]) [ pkg-config ]; 61 62 buildInputs = 63 lib.optionals enableXwinGraphics [ libX11 ] ++ lib.optionals (!enableXwinGraphics) [ ncurses ]; 64 65 preConfigure = '' 66 cd src 67 ''; 68 69 hardeningDisable = [ "format" ]; 70 71 enableParallelBuilding = true; 72 73 installPhase = '' 74 runHook preInstall 75 76 install -Dm755 pmars $out/bin/pmars 77 78 mkdir -p $out/share/pmars 79 cp -R -t $out/share/pmars/ ../{AUTHORS,COPYING,README,config,warriors} 80 81 installManPage ../doc/pmars.6 82 83 mkdir -p $out/share/doc/pmars 84 cp -t $out/share/doc/pmars/ ../doc/{primer.*,redcode.ref} 85 86 runHook postInstall 87 ''; 88 89 passthru = { 90 inherit options; 91 }; 92 93 meta = { 94 description = "Official Core War simulator"; 95 longDescription = '' 96 Portable MARS is the official Core War simulator of the ICWS and the rec.games.corewar newsgroup. pMARS serves as 97 a test bed for new Redcode standards and tournament styles. It has also been used in genetic algorithm experiments 98 and as an assembly language teaching aid. pMARS is under active development by a group of Core War enthusiasts who 99 put a lot of time into this project. 100 ''; 101 homepage = "http://www.koth.org/pmars/"; 102 license = lib.licenses.gpl2Plus; 103 mainProgram = "pmars"; 104 maintainers = with lib.maintainers; [ OPNA2608 ]; 105 platforms = lib.platforms.unix; 106 }; 107})