dwarf-fortress-packages.soundSense: fix initialization and drop JDK 8

We don't need the JDK 8 override anymore; soundsense works fine without
it if we use an --add-opens.
This commit is contained in:
Morgan Jones 2025-04-20 01:40:52 -07:00
parent 9d7246e046
commit ab31da0235
No known key found for this signature in database
GPG key ID: 5C3EB94D198F1491
6 changed files with 67 additions and 55 deletions

View file

@ -7,8 +7,6 @@
libsForQt5,
newScope,
perlPackages,
jdk8,
jre8,
}:
# To whomever it may concern:
@ -114,8 +112,6 @@ let
dfhack
dwarf-therapist
;
jdk = jdk8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
}
// args
);

View file

@ -1,12 +1,13 @@
{
lib,
stdenv,
fetchzip,
dos2unix,
soundPack ? stdenv.mkDerivation {
name = "soundsense-soundpack";
src = fetchzip {
url = "http://df.zweistein.cz/soundsense/soundpack.zip";
sha256 = "0qz0mjkp7wp0gxk3ws2x760awv8c9lkacj2fn9bz3gqqnq262ffa";
url = "https://df.zweistein.cz/soundsense/soundpack.zip";
hash = "sha256-yjlhBLYYv/FXsk5IpiZNDG2ugDldaD5mf+Dyc6es4GM=";
};
installPhase = ''
cp -r . $out
@ -20,8 +21,8 @@ stdenv.mkDerivation rec {
inherit soundPack;
pname = "soundsense";
src = fetchzip {
url = "http://df.zweistein.cz/soundsense/soundSense_${version}.zip";
sha256 = "1gkrs69l3xsh858yjp204ddp29m668j630akm7arssc9359wxqkk";
url = "https://df.zweistein.cz/soundsense/soundSense_${version}.zip";
hash = "sha256-c+LOUxmJaZ3VqVOBYSQypiZxWyNAXOlRQVD3QZPReb4=";
};
nativeBuildInputs = [ dos2unix ];
buildPhase = ''
@ -35,4 +36,14 @@ stdenv.mkDerivation rec {
ln -s $soundPack $out/soundsense/packs
'';
passthru = { inherit version dfVersion; };
meta = {
description = "Plays sound based on Dwarf Fortress game logs";
maintainers = with lib.maintainers; [
numinit
];
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
license = lib.licenses.gpl3Only;
platforms = lib.platforms.all;
homepage = "https://df.zweistein.cz/soundsense";
};
}

View file

@ -14,7 +14,7 @@
dfhack,
enableSoundSense ? false,
soundSense,
jdk,
jre,
expect,
xvfb-run,
writeText,
@ -235,7 +235,7 @@ lib.throwIf (enableTWBT' && !enableDFHack) "dwarf-fortress: TWBT requires DFHack
+ lib.optionalString enableSoundSense ''
substitute $runSoundSense $out/bin/soundsense \
--subst-var-by stdenv_shell ${stdenv.shell} \
--subst-var-by jre ${jdk.jre} \
--subst-var-by jre ${jre} \
--subst-var dfInit
chmod 755 $out/bin/soundsense
'';

View file

@ -112,24 +112,27 @@ go() {
cd "$NIXPKGS_DF_HOME"
debug "Executing: $NIXPKGS_DF_HOME/$NIXPKGS_DF_EXE"
# Handle library paths on Darwin.
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"
# Only mess with the library paths if we're starting Dwarf Fortress (not Soundsense).
if [ "$NIXPKGS_DF_GAME" -eq 1 ]; then
# Handle library paths on Darwin.
if [ "$NIXPKGS_DF_PLATFORM" == df_osx ]; then
if [ "${NIXPKGS_DF_PLATFORM_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
fi
if [ "$os_name" == Linux ]; then
# We have to preload the audio plugin for audio to work. See Nix Pill #12 for this pattern:
# https://nixos.org/guides/nix-pills/12-inputs-design-pattern.html
if [ "${_NIXPKGS_DF_OPTS[fmod]}" -eq 0 ] && [ -f "$NIXPKGS_DF_HOME/libfmod.so.13" ]; then
export LD_PRELOAD="$NIXPKGS_DF_HOME/libfmod.so.13${LD_PRELOAD:+:}${LD_PRELOAD:-}"
else
export LD_PRELOAD="@SDL2_mixer@${LD_PRELOAD:+:}${LD_PRELOAD:-}"
if [ "$NIXPKGS_DF_PLATFORM" == df_linux ]; then
# We have to preload the audio plugin for audio to work. See Nix Pill #12 for this pattern:
# https://nixos.org/guides/nix-pills/12-inputs-design-pattern.html
if [ "${_NIXPKGS_DF_OPTS[fmod]}" -eq 0 ] && [ -f "$NIXPKGS_DF_HOME/libfmod.so.13" ]; then
export LD_PRELOAD="$NIXPKGS_DF_HOME/libfmod.so.13${LD_PRELOAD:+:}${LD_PRELOAD:-}"
else
export LD_PRELOAD="@SDL2_mixer@${LD_PRELOAD:+:}${LD_PRELOAD:-}"
fi
fi
fi
@ -140,17 +143,17 @@ go() {
exit 1
}
# Figure out the Dwarf Fortress directory (df_linux or df_osx).
os_name="$(@uname@)"
os_rev="$(@uname@ -r)"
if [ "$os_name" == Linux ]; then
df_dir="df_linux"
export NIXPKGS_DF_PLATFORM="df_linux"
elif [ "$os_name" == Darwin ]; then
df_dir="df_osx"
export NIXPKGS_DF_PLATFORM="df_osx"
else
log "Unknown platform: $os_name"
exit 1
fi
export NIXPKGS_DF_PLATFORM_REV="$(@uname@ -r)"
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.
@ -158,7 +161,7 @@ if [[ -v DF_DIR ]] && [ -n "$DF_DIR" ] && { [[ ! -v NIXPKGS_DF_HOME ]] || [ -z "
fi
if [[ ! -v NIXPKGS_DF_HOME ]] || [ -z "$NIXPKGS_DF_HOME" ]; then
export NIXPKGS_DF_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/$df_dir"
export NIXPKGS_DF_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/$NIXPKGS_DF_PLATFORM"
fi
# Compatibility.
@ -187,26 +190,3 @@ export DF_DIR="$NIXPKGS_DF_HOME"
EOF
cd "$NIXPKGS_DF_ENV"
# All potential important files in DF 50 and below.
for path in dwarfort dwarfort.exe df *.so* libs raw data/init/* data/!(init|index|announcement); do
force_delete=0
if [[ "$path" == *fmod*.so* ]] && [ "${_NIXPKGS_DF_OPTS[fmod]}" -eq 0 ]; then
# Delete fmod plugins if we're using SDL_mixer.
force_delete=1
elif [[ "$path" == *mixer*.so* ]] && [ "${_NIXPKGS_DF_OPTS[fmod]}" -ne 0 ]; then
# Delete SDL_mixer plugins if we're using fmod.
force_delete=1
fi
if [ -e "$path" ] && [ "$force_delete" -eq 0 ]; then
update_path "$path"
else
cleanup_path "$path"
fi
done
# These need to be copied due to read only flags on older versions of DF.
for path in index announcement help dipscript; do
forcecopy_path "data/$path"
done

View file

@ -1,8 +1,32 @@
#!@stdenv_shell@ -e
export NIXPKGS_DF_EXE="@dfExe@"
export NIXPKGS_DF_GAME=1
source @dfInit@
# All potential important files in DF 50 and below.
for path in dwarfort dwarfort.exe df *.so* libs raw data/init/* data/!(init|index|announcement); do
force_delete=0
if [[ "$path" == *fmod*.so* ]] && [ "${_NIXPKGS_DF_OPTS[fmod]}" -eq 0 ]; then
# Delete fmod plugins if we're using SDL_mixer.
force_delete=1
elif [[ "$path" == *mixer*.so* ]] && [ "${_NIXPKGS_DF_OPTS[fmod]}" -ne 0 ]; then
# Delete SDL_mixer plugins if we're using fmod.
force_delete=1
fi
if [ -e "$path" ] && [ "$force_delete" -eq 0 ]; then
update_path "$path"
else
cleanup_path "$path"
fi
done
# These need to be copied due to read only flags on older versions of DF.
for path in index announcement help dipscript; do
forcecopy_path "data/$path"
done
# If we're switching back from dfhack to vanilla, cleanup all dfhack
# links so Dwarf Fortress doesn't autoload its leftover libdfhooks.so.
# Otherwise, populate them.

View file

@ -1,10 +1,11 @@
#!@stdenv_shell@ -e
export NIXPKGS_DF_EXE="soundsense/soundSense.sh"
export NIXPKGS_DF_GAME=0
source @dfInit@
for path in soundsense/*; do
update_path "$path"
done
PATH="@jre@/bin:$PATH" go
JDK_JAVA_OPTIONS='--add-opens=java.xml/com.sun.org.apache.xerces.internal.parsers=ALL-UNNAMED' PATH="@jre@/bin:$PATH" go "$@"