nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 105 lines 2.8 kB view raw
1{ 2 cmake, 3 fetchFromGitHub, 4 fetchpatch2, 5 fpattern, 6 lib, 7 SDL2, 8 stdenv, 9 writeShellScript, 10 zlib, 11 nix-update-script, 12}: 13 14let 15 launcher = writeShellScript "fallout2-ce" '' 16 set -eu 17 assetDir="''${XDG_DATA_HOME:-$HOME/.local/share}/fallout2-ce" 18 [ -d "$assetDir" ] || mkdir -p "$assetDir" 19 cd "$assetDir" 20 21 notice=0 fault=0 22 requiredFiles=(master.dat critter.dat) 23 for f in "''${requiredFiles[@]}"; do 24 if [ ! -f "$f" ]; then 25 echo "Required file $f not found in $PWD, note the files are case-sensitive" 26 notice=1 fault=1 27 fi 28 done 29 30 if [ ! -d "data/sound/music" ] && [ ! -d "sound/music" ]; then 31 echo "data/sound/music directory not found in $PWD. This may prevent in-game music from functioning." 32 notice=1 33 fi 34 35 if [ $notice -ne 0 ]; then 36 echo "Please reference the installation instructions at https://github.com/alexbatalov/fallout2-ce" 37 fi 38 39 if [ $fault -ne 0 ]; then 40 exit $fault; 41 fi 42 43 exec @out@/libexec/fallout2-ce "$@" 44 ''; 45in 46 47stdenv.mkDerivation (finalAttrs: { 48 pname = "fallout2-ce"; 49 version = "1.3.0"; 50 51 src = fetchFromGitHub { 52 owner = "alexbatalov"; 53 repo = "fallout2-ce"; 54 tag = "v${finalAttrs.version}"; 55 hash = "sha256-r1pnmyuo3uw2R0x9vGScSHIVNA6t+txxABzgHkUEY5U="; 56 }; 57 58 patches = [ 59 # Fix case-sensitive filesystems issue when save/load games 60 (fetchpatch2 { 61 url = "https://github.com/alexbatalov/fallout2-ce/commit/e770e64a48cd4d0a58a07f8db72839e4747e4c1e.patch?full_index=1"; 62 sha256 = "sha256-49N6uXwOBL/sE+f+W4nX6Gpwwpmbgvy38B1NjECiia0="; 63 }) 64 ]; 65 66 nativeBuildInputs = [ cmake ]; 67 68 buildInputs = [ 69 SDL2 70 zlib 71 ]; 72 73 hardeningDisable = [ "format" ]; 74 75 postPatch = '' 76 substituteInPlace third_party/fpattern/CMakeLists.txt \ 77 --replace-fail "FetchContent_Populate" "#FetchContent_Populate" \ 78 --replace-fail "\''${fpattern_SOURCE_DIR}" "${fpattern}/include" 79 ''; 80 81 installPhase = '' 82 runHook preInstall 83 84 install -D fallout2-ce $out/libexec/fallout2-ce 85 install -D ${launcher} $out/bin/fallout2-ce 86 substituteInPlace $out/bin/fallout2-ce --subst-var out 87 88 runHook postInstall 89 ''; 90 91 passthru.updateScript = nix-update-script { }; 92 93 meta = { 94 description = "Fallout 2 for modern operating systems"; 95 longDescription = '' 96 Fully working re-implementation of Fallout 2, with the same original gameplay, engine bugfixes, and some quality of life improvements. 97 You must own the game and copy the files to the specified folder to play. 98 ''; 99 homepage = "https://github.com/alexbatalov/fallout2-ce"; 100 license = lib.licenses.sustainableUse; 101 maintainers = with lib.maintainers; [ hughobrien ]; 102 platforms = lib.platforms.linux; 103 mainProgram = "fallout2-ce"; 104 }; 105})