Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 87 lines 1.9 kB view raw
1{ 2 cmake, 3 fpattern, 4 lib, 5 SDL2, 6 stdenv, 7 writeShellScript, 8 9 extraBuildInputs ? [ ], 10 extraMeta, 11 patches, 12 pname, 13 version, 14 src, 15}: 16 17let 18 launcher = writeShellScript "${pname}" '' 19 set -eu 20 assetDir="''${XDG_DATA_HOME:-$HOME/.local/share}/${pname}" 21 [ -d "$assetDir" ] || mkdir -p "$assetDir" 22 cd "$assetDir" 23 24 notice=0 fault=0 25 requiredFiles=(master.dat critter.dat) 26 for f in "''${requiredFiles[@]}"; do 27 if [ ! -f "$f" ]; then 28 echo "Required file $f not found in $PWD, note the files are case-sensitive" 29 notice=1 fault=1 30 fi 31 done 32 33 if [ ! -d "data/sound/music" ]; then 34 echo "data/sound/music directory not found in $PWD. This may prevent in-game music from functioning." 35 notice=1 36 fi 37 38 if [ $notice -ne 0 ]; then 39 echo "Please reference the installation instructions at https://github.com/alexbatalov/fallout2-ce" 40 fi 41 42 if [ $fault -ne 0 ]; then 43 exit $fault; 44 fi 45 46 exec @out@/libexec/${pname} "$@" 47 ''; 48in 49stdenv.mkDerivation { 50 inherit 51 pname 52 version 53 src 54 patches 55 ; 56 57 nativeBuildInputs = [ cmake ]; 58 buildInputs = [ SDL2 ] ++ extraBuildInputs; 59 hardeningDisable = [ "format" ]; 60 cmakeBuildType = "RelWithDebInfo"; 61 62 postPatch = '' 63 substituteInPlace third_party/fpattern/CMakeLists.txt \ 64 --replace "FetchContent_Populate" "#FetchContent_Populate" \ 65 --replace "{fpattern_SOURCE_DIR}" "${fpattern}/include" \ 66 --replace "$/nix/" "/nix/" 67 ''; 68 69 installPhase = '' 70 runHook preInstall 71 72 install -D ${pname} $out/libexec/${pname} 73 install -D ${launcher} $out/bin/${pname} 74 substituteInPlace $out/bin/${pname} --subst-var out 75 76 runHook postInstall 77 ''; 78 79 meta = 80 with lib; 81 { 82 license = licenses.sustainableUse; 83 maintainers = with maintainers; [ hughobrien ]; 84 platforms = platforms.linux; 85 } 86 // extraMeta; 87}