summary refs log tree commit diff
path: root/pkgs/games/dwarf-fortress/wrapper
diff options
context:
space:
mode:
authorMorgan Jones <me@numin.it>2018-07-15 03:58:37 +0000
committerMorgan Jones <me@numin.it>2018-09-09 06:59:41 +0000
commitf14d3b4795c173f5ff353031b8d32afab7090ab9 (patch)
tree0f10c1a662c9e738b0b3e540d48402224b03e5be /pkgs/games/dwarf-fortress/wrapper
parent4ada74e293212434114ac87a679c1432650f4b40 (diff)
downloadnixlib-f14d3b4795c173f5ff353031b8d32afab7090ab9.tar
nixlib-f14d3b4795c173f5ff353031b8d32afab7090ab9.tar.gz
nixlib-f14d3b4795c173f5ff353031b8d32afab7090ab9.tar.bz2
nixlib-f14d3b4795c173f5ff353031b8d32afab7090ab9.tar.lz
nixlib-f14d3b4795c173f5ff353031b8d32afab7090ab9.tar.xz
nixlib-f14d3b4795c173f5ff353031b8d32afab7090ab9.tar.zst
nixlib-f14d3b4795c173f5ff353031b8d32afab7090ab9.zip
Fix dfhack's Dwarf Fortress MD5 in the correct environment
Diffstat (limited to 'pkgs/games/dwarf-fortress/wrapper')
-rw-r--r--pkgs/games/dwarf-fortress/wrapper/default.nix54
1 files changed, 33 insertions, 21 deletions
diff --git a/pkgs/games/dwarf-fortress/wrapper/default.nix b/pkgs/games/dwarf-fortress/wrapper/default.nix
index 105143916d10..33523270b19d 100644
--- a/pkgs/games/dwarf-fortress/wrapper/default.nix
+++ b/pkgs/games/dwarf-fortress/wrapper/default.nix
@@ -37,6 +37,39 @@ let
 
     paths = themePkg ++ pkgs;
     pathsToLink = [ "/" "/hack" "/hack/scripts" ];
+
+    postBuild = ''
+      # De-symlink init.txt
+      cp $out/data/init/init.txt init.txt
+      rm -f $out/data/init/init.txt
+      mv init.txt $out/data/init/init.txt
+    '' + lib.optionalString enableDFHack ''
+      # De-symlink symbols.xml
+      rm $out/hack/symbols.xml
+
+      # Patch the MD5
+      orig_md5=$(cat "${dwarf-fortress}/hash.md5.orig")
+      patched_md5=$(cat "${dwarf-fortress}/hash.md5")
+      input_file="${dfhack_}/hack/symbols.xml"
+      output_file="$out/hack/symbols.xml"
+
+      echo "[DFHack Wrapper] Fixing Dwarf Fortress MD5:"
+      echo "  Input:   $input_file"
+      echo "  Search:  $orig_md5"
+      echo "  Output:  $output_file"
+      echo "  Replace: $patched_md5"
+
+      substitute "$input_file" "$output_file" --replace "$orig_md5" "$patched_md5"
+    '' + lib.optionalString enableTWBT ''
+      substituteInPlace $out/data/init/init.txt \
+        --replace '[PRINT_MODE:2D]' '[PRINT_MODE:TWBT]'
+    '' + ''
+      substituteInPlace $out/data/init/init.txt \
+        --replace '[INTRO:YES]' '[INTRO:${unBool enableIntro}]' \
+        --replace '[TRUETYPE:YES]' '[TRUETYPE:${unBool enableTruetype}]' \
+        --replace '[FPS:NO]' '[FPS:${unBool enableFPS}]'
+    '';
+
     ignoreCollisions = true;
   };
 in
@@ -78,26 +111,5 @@ stdenv.mkDerivation rec {
     chmod 755 $out/bin/soundsense
   '';
 
-  postBuild = ''
-    # De-symlink init.txt
-    cp $out/data/init/init.txt init.txt
-    rm $out/data/init/init.txt
-    mv init.txt $out/data/init/init.txt
-  '' + lib.optionalString enableDFHack ''
-    rm $out/hack/symbols.xml
-    echo "[$out/hack/symbols.xml] $(cat ${dwarf-fortress}/hash.md5.orig) => $(cat ${dwarf-fortress}/hash.md5)"
-    substitute ${dfhack_}/hack/symbols.xml $out/hack/symbols.xml \
-      --replace $(cat ${dwarf-fortress}/hash.md5.orig) \
-                $(cat ${dwarf-fortress}/hash.md5)
-  '' + lib.optionalString enableTWBT ''
-    substituteInPlace $out/data/init/init.txt \
-      --replace '[PRINT_MODE:2D]' '[PRINT_MODE:TWBT]'
-  '' + ''
-    substituteInPlace $out/data/init/init.txt \
-      --replace '[INTRO:YES]' '[INTRO:${unBool enableIntro}]' \
-      --replace '[TRUETYPE:YES]' '[TRUETYPE:${unBool enableTruetype}]' \
-      --replace '[FPS:NO]' '[FPS:${unBool enableFPS}]'
-  '';
-
   preferLocalBuild = true;
 }