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