diff options
Diffstat (limited to 'nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist')
3 files changed, 106 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/default.nix b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/default.nix new file mode 100644 index 000000000000..652e4c184753 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/default.nix @@ -0,0 +1,30 @@ +{ stdenv, fetchFromGitHub, qtbase +, qtdeclarative, cmake, texlive, ninja }: + +stdenv.mkDerivation rec { + name = "dwarf-therapist-${version}"; + version = "41.0.2"; + + src = fetchFromGitHub { + owner = "Dwarf-Therapist"; + repo = "Dwarf-Therapist"; + rev = "v${version}"; + sha256 = "0cvnk1dkszh7q7viv3i1v3ifzv1w0xyz69mifa1cbvbi47z2dh0d"; + }; + + buildInputs = [ qtbase qtdeclarative ]; + nativeBuildInputs = [ texlive cmake ninja ]; + + installPhase = if stdenv.isDarwin then '' + mkdir -p $out/Applications + cp -r DwarfTherapist.app $out/Applications + '' else null; + + meta = with stdenv.lib; { + description = "Tool to manage dwarves in a running game of Dwarf Fortress"; + maintainers = with maintainers; [ the-kenny abbradar bendlas numinit ]; + license = licenses.mit; + platforms = platforms.unix; + homepage = https://github.com/Dwarf-Therapist/Dwarf-Therapist; + }; +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/dwarf-therapist.in b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/dwarf-therapist.in new file mode 100644 index 000000000000..77936c430e2b --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/dwarf-therapist.in @@ -0,0 +1,26 @@ +#!@stdenv_shell@ -e + +[ -z "$DT_DIR" ] && DT_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/dwarftherapist" + +install_dir="@install@" +therapist_dir="@therapist@" + +cat <<EOF >&2 +Using $DT_DIR as Dwarf Therapist overlay directory. +EOF + +update_path() { + local path="$1" + + mkdir -p "$DT_DIR/$(dirname "$path")" + if [ ! -e "$DT_DIR/$path" ] || [ -L "$DT_DIR/$path" ]; then + rm -f "$DT_DIR/$path" + ln -s "$install_dir/share/dwarftherapist/$path" "$DT_DIR/$path" + fi +} + +cd "$install_dir/share/dwarftherapist" +update_path memory_layouts + +QT_QPA_PLATFORM_PLUGIN_PATH="@qt_plugin_path@" \ + exec "$therapist_dir/bin/dwarftherapist" "$@" diff --git a/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix new file mode 100644 index 000000000000..071ab2af0c5c --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix @@ -0,0 +1,50 @@ +{ pkgs, stdenv, symlinkJoin, lib, dwarf-therapist, dwarf-fortress, makeWrapper }: + +let + platformSlug = if stdenv.targetPlatform.is32bit then + "linux32" else "linux64"; + inifile = "linux/v0.${dwarf-fortress.baseVersion}.${dwarf-fortress.patchVersion}_${platformSlug}.ini"; + +in + +stdenv.mkDerivation rec { + name = "dwarf-therapist-${dwarf-therapist.version}"; + + wrapper = ./dwarf-therapist.in; + + paths = [ dwarf-therapist ]; + + buildInputs = [ makeWrapper ]; + + passthru = { inherit dwarf-fortress dwarf-therapist; }; + + buildCommand = '' + mkdir -p $out/bin + ln -s $out/bin/dwarftherapist $out/bin/DwarfTherapist + substitute $wrapper $out/bin/dwarftherapist \ + --subst-var-by stdenv_shell ${stdenv.shell} \ + --subst-var-by install $out \ + --subst-var-by therapist ${dwarf-therapist} \ + --subst-var-by qt_plugin_path "${pkgs.qt5.qtbase}/lib/qt-${pkgs.qt5.qtbase.qtCompatVersion}/plugins/platforms" + + chmod 755 $out/bin/dwarftherapist + + # Fix up memory layouts + rm -rf $out/share/dwarftherapist/memory_layouts/linux + mkdir -p $out/share/dwarftherapist/memory_layouts/linux + orig_md5=$(cat "${dwarf-fortress}/hash.md5.orig" | cut -c1-8) + patched_md5=$(cat "${dwarf-fortress}/hash.md5" | cut -c1-8) + input_file="${dwarf-therapist}/share/dwarftherapist/memory_layouts/${inifile}" + output_file="$out/share/dwarftherapist/memory_layouts/${inifile}" + + echo "[Dwarf Therapist Wrapper] Fixing Dwarf Fortress MD5 prefix:" + 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" + ''; + + preferLocalBuild = true; +} |