diff --git a/pkgs/games/dwarf-fortress/default.nix b/pkgs/games/dwarf-fortress/default.nix index acf50d650c49..e5bbf60e1550 100644 --- a/pkgs/games/dwarf-fortress/default.nix +++ b/pkgs/games/dwarf-fortress/default.nix @@ -49,7 +49,9 @@ let # The latest Dwarf Fortress version. Maintainers: when a new version comes # out, ensure that (unfuck|dfhack|twbt) are all up to date before changing # this. Note that unfuck and twbt are not required for 50. - latestVersion = "50.13"; + latestVersion = if stdenv.isLinux then "50.13" + else if stdenv.isDarwin then "0.47.05" + else throw "Unsupported system"; # Converts a version to a package name. versionToName = version: "dwarf-fortress_${replaceStrings ["."] ["_"] version}"; @@ -62,7 +64,7 @@ let let isAtLeast50 = versionAtLeast dfVersion "50.0"; - dwarf-fortress-unfuck = optionalAttrs (!isAtLeast50) (callPackage ./unfuck.nix { inherit dfVersion; }); + dwarf-fortress-unfuck = optionalAttrs (!isAtLeast50 && stdenv.isLinux) (callPackage ./unfuck.nix { inherit dfVersion; }); dwarf-fortress = callPackage ./game.nix { inherit dfVersion; diff --git a/pkgs/games/dwarf-fortress/dfhack/default.nix b/pkgs/games/dwarf-fortress/dfhack/default.nix index 96a5dac52540..cb0e1e529637 100644 --- a/pkgs/games/dwarf-fortress/dfhack/default.nix +++ b/pkgs/games/dwarf-fortress/dfhack/default.nix @@ -90,9 +90,9 @@ let xmlRev = "980b1af13acc31660dce632f913c968f52e2b275"; }; "50.13" = { - dfHackRelease = "50.13-r1.1"; - hash = "sha256-FiXanXflszTr4ogz+EoDAUxzE2U9ODeZIJJ1u6Xm4Mo="; - xmlRev = "3507715fd07340de5a6c47064220f6e17343e5d5"; + dfHackRelease = "50.13-r3"; + hash = "sha256-WbkJ8HmLT5GdZgDmcuFh+1uzhloKM9um0b9YO//uR7Y="; + xmlRev = "f0530a22149606596e97e3e17d941df3aafe29b9"; }; }; diff --git a/pkgs/games/dwarf-fortress/game.nix b/pkgs/games/dwarf-fortress/game.nix index 6e8467e55df9..95a4ff06e570 100644 --- a/pkgs/games/dwarf-fortress/game.nix +++ b/pkgs/games/dwarf-fortress/game.nix @@ -53,7 +53,7 @@ let patchVersion = elemAt dfVersionTuple (dfVersionBaseIndex + 1); isAtLeast50 = baseVersion >= 50; - enableUnfuck = !isAtLeast50 && dwarf-fortress-unfuck != null; + enableUnfuck = !isAtLeast50 && dwarf-fortress-unfuck != null && (dwarf-fortress-unfuck.dfVersion or null) == dfVersion; game = if hasAttr dfVersion df-hashes @@ -84,7 +84,7 @@ stdenv.mkDerivation { sourceRoot = "."; - postUnpack = optionalString stdenv.isLinux '' + postUnpack = '' directory=${ if stdenv.isLinux then "df_linux" else if stdenv.isDarwin then "df_osx" @@ -95,7 +95,7 @@ stdenv.mkDerivation { fi ''; - nativeBuildInputs = [ autoPatchelfHook ]; + nativeBuildInputs = optional stdenv.isLinux autoPatchelfHook; buildInputs = optionals isAtLeast50 [ SDL2 SDL2_image SDL2_mixer ] ++ optional (!isAtLeast50) SDL ++ optional enableUnfuck dwarf-fortress-unfuck @@ -108,6 +108,9 @@ stdenv.mkDerivation { mkdir -p $out cp -r * $out + # Clean up OS X detritus in the tarball. + find $out -type f -name '._*' -exec rm -rf {} \; + # Lots of files are +x in the newer releases... find $out -type d -exec chmod 0755 {} \; find $out -type f -exec chmod 0644 {} \; @@ -116,7 +119,7 @@ stdenv.mkDerivation { [ -f $out/run_df ] && chmod +x $out/run_df # We don't need any of these since they will just break autoPatchelf on $out/hash.md5.orig @@ -129,6 +132,7 @@ stdenv.mkDerivation { ln -s ${getLib ncurses}/lib/libncurses.dylib $out/libs ln -s ${getLib gcc.cc}/lib/libstdc++.6.dylib $out/libs + ln -s ${getLib gcc.cc}/lib/libgcc_s.1.dylib $out/libs ln -s ${getLib fmodex}/lib/libfmodex.dylib $out/libs install_name_tool \ diff --git a/pkgs/games/dwarf-fortress/wrapper/default.nix b/pkgs/games/dwarf-fortress/wrapper/default.nix index 2dd771ee922d..daa27ce5dc00 100644 --- a/pkgs/games/dwarf-fortress/wrapper/default.nix +++ b/pkgs/games/dwarf-fortress/wrapper/default.nix @@ -197,8 +197,8 @@ stdenv.mkDerivation rec { chmod 755 $out/bin/soundsense ''; - doInstallCheck = true; - nativeInstallCheckInputs = [ expect xvfb-run ]; + doInstallCheck = stdenv.isLinux; + nativeInstallCheckInputs = lib.optionals stdenv.isLinux [ expect xvfb-run ]; installCheckPhase = let commonExpectStatements = fmod: lib.optionalString isAtLeast50 '' diff --git a/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in b/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in index 61b1b4da6168..1c739a1afbbf 100644 --- a/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in +++ b/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in @@ -4,18 +4,6 @@ shopt -s extglob export NIXPKGS_DF_ENV="@env@" -if [[ -v DF_DIR ]] && [ -n "$DF_DIR" ] && { [[ ! -v NIXPKGS_DF_HOME ]] || [ -z "$NIXPKGS_DF_HOME" ]; }; then - # Compatibility for users that were using DF_DIR, since the dfhack script clobbers this variable. - export NIXPKGS_DF_HOME="$DF_DIR" -fi - -if [[ ! -v NIXPKGS_DF_HOME ]] || [ -z "$NIXPKGS_DF_HOME" ]; then - export NIXPKGS_DF_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/df_linux" -fi - -# Compatibility. -export DF_DIR="$NIXPKGS_DF_HOME" - ### BEGIN: Default DF options declare -A _NIXPKGS_DF_OPTS _NIXPKGS_DF_OPTS[fmod]=0 # Don't use fmod by default. @@ -131,6 +119,30 @@ go() { exit 1 } +os_name="$(@uname@)" +os_rev="$(@uname@ -r)" + +if [ "$os_name" == Linux ]; then + df_dir="df_linux" +elif [ "$os_name" == Darwin ]; then + df_dir="df_osx" +else + log "Unknown platform: $os_name" + exit 1 +fi + +if [[ -v DF_DIR ]] && [ -n "$DF_DIR" ] && { [[ ! -v NIXPKGS_DF_HOME ]] || [ -z "$NIXPKGS_DF_HOME" ]; }; then + # Compatibility for users that were using DF_DIR, since the dfhack script clobbers this variable. + export NIXPKGS_DF_HOME="$DF_DIR" +fi + +if [[ ! -v NIXPKGS_DF_HOME ]] || [ -z "$NIXPKGS_DF_HOME" ]; then + export NIXPKGS_DF_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/$df_dir" +fi + +# Compatibility. +export DF_DIR="$NIXPKGS_DF_HOME" + @mkdir@ -p "$NIXPKGS_DF_HOME" @cat@ <&2 @@ -156,7 +168,7 @@ EOF cd "$NIXPKGS_DF_ENV" # All potential important files in DF 50 and below. -for path in dwarfort *.so libs raw data/init/* data/!(init|index|announcement); do +for path in dwarfort dwarfort.exe df *.so libs raw data/init/* data/!(init|index|announcement); do force_delete=0 if [[ "$path" == libfmod*.so* ]] && [ "${_NIXPKGS_DF_OPTS[fmod]}" -eq 0 ]; then force_delete=1 @@ -175,7 +187,12 @@ for path in index announcement help dipscript; do done # Handle library paths on Darwin. -if [ "$(@uname@)" == Darwin ]; then - export DYLD_LIBRARY_PATH="$NIXPKGS_DF_ENV/libs" - export DYLD_FRAMEWORK_PATH="$NIXPKGS_DF_ENV/libs" +if [ "$os_name" == Darwin ]; then + if [ "${os_rev%%.*}" -ge 11 ]; then + export DYLD_LIBRARY_PATH="$NIXPKGS_DF_ENV/libs" + export DYLD_FRAMEWORK_PATH="$NIXPKGS_DF_ENV/libs" + else + export DYLD_FALLBACK_LIBRARY_PATH="$NIXPKGS_DF_ENV/libs" + export DYLD_FALLBACK_FRAMEWORK_PATH="$NIXPKGS_DF_ENV/libs" + fi fi