dwarf-fortress: refactor
This commit is contained in:
parent
4e75706a46
commit
cd3ed54f6e
@ -1,4 +1,4 @@
|
||||
{ pkgs, stdenv, stdenvNoCC, gccStdenv, lib, recurseIntoAttrs }:
|
||||
{ stdenv, stdenvNoCC, gccStdenv, lib, recurseIntoAttrs, libsForQt5, newScope, texlive, perlPackages, jdk8, jre8 }:
|
||||
|
||||
# To whomever it may concern:
|
||||
#
|
||||
@ -35,7 +35,7 @@
|
||||
with lib;
|
||||
|
||||
let
|
||||
callPackage = pkgs.newScope self;
|
||||
callPackage = newScope self;
|
||||
|
||||
# The latest Dwarf Fortress version. Maintainers: when a new version comes
|
||||
# out, ensure that (unfuck|dfhack|twbt) are all up to date before changing
|
||||
@ -45,14 +45,15 @@ let
|
||||
# Converts a version to a package name.
|
||||
versionToName = version: "dwarf-fortress_${lib.replaceStrings ["."] ["_"] version}";
|
||||
|
||||
dwarf-therapist-original = pkgs.qt5.callPackage ./dwarf-therapist {
|
||||
texlive = pkgs.texlive.combine {
|
||||
inherit (pkgs.texlive) scheme-basic float caption wrapfig adjmulticol sidecap preprint enumitem;
|
||||
dwarf-therapist-original = libsForQt5.callPackage ./dwarf-therapist {
|
||||
texlive = texlive.combine {
|
||||
inherit (texlive) scheme-basic float caption wrapfig adjmulticol sidecap preprint enumitem;
|
||||
};
|
||||
};
|
||||
|
||||
# A map of names to each Dwarf Fortress package we know about.
|
||||
df-games = lib.listToAttrs (map (dfVersion: {
|
||||
df-games = lib.listToAttrs (map
|
||||
(dfVersion: {
|
||||
name = versionToName dfVersion;
|
||||
value =
|
||||
let
|
||||
@ -63,18 +64,19 @@ let
|
||||
};
|
||||
|
||||
# unfuck is linux-only right now, we will only use it there.
|
||||
dwarf-fortress-unfuck = if stdenv.isLinux then callPackage ./unfuck.nix { inherit dfVersion; }
|
||||
dwarf-fortress-unfuck =
|
||||
if stdenv.isLinux then callPackage ./unfuck.nix { inherit dfVersion; }
|
||||
else null;
|
||||
|
||||
twbt = callPackage ./twbt { inherit dfVersion; };
|
||||
|
||||
dfhack = callPackage ./dfhack {
|
||||
inherit (pkgs.perlPackages) XMLLibXML XMLLibXSLT;
|
||||
inherit (perlPackages) XMLLibXML XMLLibXSLT;
|
||||
inherit dfVersion twbt;
|
||||
stdenv = gccStdenv;
|
||||
};
|
||||
|
||||
dwarf-therapist = callPackage ./dwarf-therapist/wrapper.nix {
|
||||
dwarf-therapist = libsForQt5.callPackage ./dwarf-therapist/wrapper.nix {
|
||||
inherit dwarf-fortress;
|
||||
dwarf-therapist = dwarf-therapist-original;
|
||||
};
|
||||
@ -87,9 +89,10 @@ let
|
||||
dfhack = dfhack;
|
||||
dwarf-therapist = dwarf-therapist;
|
||||
|
||||
jdk = pkgs.jdk8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
|
||||
jdk = jdk8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
|
||||
};
|
||||
}) (lib.attrNames self.df-hashes));
|
||||
})
|
||||
(lib.attrNames self.df-hashes));
|
||||
|
||||
self = rec {
|
||||
df-hashes = builtins.fromJSON (builtins.readFile ./game.json);
|
||||
@ -107,7 +110,7 @@ let
|
||||
soundSense = callPackage ./soundsense.nix { };
|
||||
|
||||
legends-browser = callPackage ./legends-browser {
|
||||
jre = pkgs.jre8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
|
||||
jre = jre8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
|
||||
};
|
||||
|
||||
themes = recurseIntoAttrs (callPackage ./themes {
|
||||
@ -119,4 +122,5 @@ let
|
||||
cla-theme = themes.cla;
|
||||
};
|
||||
|
||||
in self // df-games
|
||||
in
|
||||
self // df-games
|
||||
|
@ -1,7 +1,20 @@
|
||||
{ stdenv, buildEnv, lib, fetchFromGitHub, cmake, writeScriptBin
|
||||
, perl, XMLLibXML, XMLLibXSLT, zlib, ruby
|
||||
, enableStoneSense ? false, allegro5, libGLU, libGL
|
||||
, enableTWBT ? true, twbt
|
||||
{ stdenv
|
||||
, buildEnv
|
||||
, lib
|
||||
, fetchFromGitHub
|
||||
, cmake
|
||||
, writeScriptBin
|
||||
, perl
|
||||
, XMLLibXML
|
||||
, XMLLibXSLT
|
||||
, zlib
|
||||
, ruby
|
||||
, enableStoneSense ? false
|
||||
, allegro5
|
||||
, libGLU
|
||||
, libGL
|
||||
, enableTWBT ? true
|
||||
, twbt
|
||||
, SDL
|
||||
, dfVersion
|
||||
}:
|
||||
@ -60,7 +73,8 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
release = if hasAttr dfVersion dfhack-releases
|
||||
release =
|
||||
if hasAttr dfVersion dfhack-releases
|
||||
then getAttr dfVersion dfhack-releases
|
||||
else throw "[DFHack] Unsupported Dwarf Fortress version: ${dfVersion}";
|
||||
|
||||
|
@ -1,5 +1,12 @@
|
||||
{ lib, stdenv, fetchFromGitHub, qtbase
|
||||
, qtdeclarative, cmake, texlive, ninja }:
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, qtbase
|
||||
, qtdeclarative
|
||||
, cmake
|
||||
, texlive
|
||||
, ninja
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "dwarf-therapist";
|
||||
@ -15,7 +22,8 @@ stdenv.mkDerivation rec {
|
||||
nativeBuildInputs = [ texlive cmake ninja ];
|
||||
buildInputs = [ qtbase qtdeclarative ];
|
||||
|
||||
installPhase = if stdenv.isDarwin then ''
|
||||
installPhase =
|
||||
if stdenv.isDarwin then ''
|
||||
mkdir -p $out/Applications
|
||||
cp -r DwarfTherapist.app $out/Applications
|
||||
'' else null;
|
||||
|
@ -5,22 +5,21 @@
|
||||
install_dir="@install@"
|
||||
therapist_dir="@therapist@"
|
||||
|
||||
cat <<EOF >&2
|
||||
@cat@ <<EOF >&2
|
||||
Using $DT_DIR as Dwarf Therapist overlay directory.
|
||||
EOF
|
||||
|
||||
update_path() {
|
||||
local path="$1"
|
||||
|
||||
mkdir -p "$DT_DIR/$(dirname "$path")"
|
||||
@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"
|
||||
@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" "$@"
|
||||
|
@ -1,7 +1,8 @@
|
||||
{ pkgs, stdenv, dwarf-therapist, dwarf-fortress, makeWrapper }:
|
||||
{ stdenv, dwarf-therapist, dwarf-fortress, substituteAll, coreutils, wrapQtAppsHook }:
|
||||
|
||||
let
|
||||
platformSlug = if stdenv.targetPlatform.is32bit then
|
||||
platformSlug =
|
||||
if stdenv.targetPlatform.is32bit then
|
||||
"linux32" else "linux64";
|
||||
inifile = "linux/v0.${dwarf-fortress.baseVersion}.${dwarf-fortress.patchVersion}_${platformSlug}.ini";
|
||||
|
||||
@ -10,24 +11,32 @@ in
|
||||
stdenv.mkDerivation {
|
||||
name = "dwarf-therapist-${dwarf-therapist.version}";
|
||||
|
||||
wrapper = ./dwarf-therapist.in;
|
||||
wrapper = substituteAll {
|
||||
src = ./dwarf-therapist.in;
|
||||
stdenv_shell = "${stdenv.shell}";
|
||||
rm = "${coreutils}/bin/rm";
|
||||
ln = "${coreutils}/bin/ln";
|
||||
cat = "${coreutils}/bin/cat";
|
||||
mkdir = "${coreutils}/bin/mkdir";
|
||||
dirname = "${coreutils}/bin/dirname";
|
||||
therapist = "${dwarf-therapist}";
|
||||
};
|
||||
|
||||
paths = [ dwarf-therapist ];
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
nativeBuildInputs = [ wrapQtAppsHook ];
|
||||
|
||||
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
|
||||
install -Dm755 $wrapper $out/bin/dwarftherapist
|
||||
ln -s $out/bin/dwarftherapist $out/bin/DwarfTherapist
|
||||
|
||||
substituteInPlace $out/bin/dwarftherapist \
|
||||
--subst-var-by install $out
|
||||
wrapQtApp $out/bin/dwarftherapist
|
||||
|
||||
# Fix up memory layouts
|
||||
rm -rf $out/share/dwarftherapist/memory_layouts/linux
|
||||
|
@ -1,10 +1,16 @@
|
||||
{ stdenv, lib, fetchurl
|
||||
, SDL, dwarf-fortress-unfuck
|
||||
{ stdenv
|
||||
, lib
|
||||
, fetchurl
|
||||
, SDL
|
||||
, dwarf-fortress-unfuck
|
||||
|
||||
# Our own "unfuck" libs for macOS
|
||||
, ncurses, fmodex, gcc
|
||||
, ncurses
|
||||
, fmodex
|
||||
, gcc
|
||||
|
||||
, dfVersion, df-hashes
|
||||
, dfVersion
|
||||
, df-hashes
|
||||
}:
|
||||
|
||||
with lib;
|
||||
@ -30,13 +36,16 @@ let
|
||||
baseVersion = elemAt dfVersionTriple 1;
|
||||
patchVersion = elemAt dfVersionTriple 2;
|
||||
|
||||
game = if hasAttr dfVersion df-hashes
|
||||
game =
|
||||
if hasAttr dfVersion df-hashes
|
||||
then getAttr dfVersion df-hashes
|
||||
else throw "Unknown Dwarf Fortress version: ${dfVersion}";
|
||||
dfPlatform = if hasAttr stdenv.hostPlatform.system platforms
|
||||
dfPlatform =
|
||||
if hasAttr stdenv.hostPlatform.system platforms
|
||||
then getAttr stdenv.hostPlatform.system platforms
|
||||
else throw "Unsupported system: ${stdenv.hostPlatform.system}";
|
||||
sha256 = if hasAttr dfPlatform game
|
||||
sha256 =
|
||||
if hasAttr dfPlatform game
|
||||
then getAttr dfPlatform game
|
||||
else throw "Unsupported dfPlatform: ${dfPlatform}";
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
{ stdenvNoCC, lib, buildEnv
|
||||
, df-games, themes, latestVersion, versionToName
|
||||
{ stdenvNoCC
|
||||
, lib
|
||||
, buildEnv
|
||||
, df-games
|
||||
, themes
|
||||
, latestVersion
|
||||
, versionToName
|
||||
, dfVersion ? latestVersion
|
||||
# This package should, at any given time, provide an opinionated "optimal"
|
||||
# DF experience. It's the equivalent of the Lazy Newbie Pack, that is, and
|
||||
@ -9,7 +14,8 @@
|
||||
, enableSoundSense ? true
|
||||
, enableStoneSense ? true
|
||||
, enableDwarfTherapist ? true
|
||||
, enableLegendsBrowser ? true, legends-browser
|
||||
, enableLegendsBrowser ? true
|
||||
, legends-browser
|
||||
, theme ? themes.phoebus
|
||||
# General config options:
|
||||
, enableIntro ? true
|
||||
@ -23,7 +29,8 @@ with lib;
|
||||
|
||||
let
|
||||
dfGame = versionToName dfVersion;
|
||||
dwarf-fortress = if hasAttr dfGame df-games
|
||||
dwarf-fortress =
|
||||
if hasAttr dfGame df-games
|
||||
then getAttr dfGame df-games
|
||||
else throw "Unknown Dwarf Fortress version: ${dfVersion}";
|
||||
dwarf-therapist = dwarf-fortress.dwarf-therapist;
|
||||
@ -34,7 +41,8 @@ buildEnv {
|
||||
(dwarf-fortress.override {
|
||||
inherit enableDFHack enableTWBT enableSoundSense enableStoneSense theme
|
||||
enableIntro enableTruetype enableFPS enableTextMode enableSound;
|
||||
})]
|
||||
})
|
||||
]
|
||||
++ lib.optional enableDwarfTherapist dwarf-therapist
|
||||
++ lib.optional enableLegendsBrowser legends-browser;
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
{ stdenv, fetchzip, dos2unix
|
||||
{ stdenv
|
||||
, fetchzip
|
||||
, dos2unix
|
||||
, soundPack ? stdenv.mkDerivation {
|
||||
name = "soundsense-soundpack";
|
||||
src = fetchzip {
|
||||
@ -8,7 +10,8 @@
|
||||
installPhase = ''
|
||||
cp -r . $out
|
||||
'';
|
||||
}}:
|
||||
}
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "2016-1_196";
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
with builtins;
|
||||
|
||||
listToAttrs (map (v: {
|
||||
listToAttrs (map
|
||||
(v: {
|
||||
inherit (v) name;
|
||||
value = fetchFromGitHub {
|
||||
name = "${v.name}-${v.version}";
|
||||
@ -16,4 +17,5 @@ listToAttrs (map (v: {
|
||||
license = licenses.free;
|
||||
};
|
||||
};
|
||||
}) (fromJSON (readFile ./themes.json)))
|
||||
})
|
||||
(fromJSON (readFile ./themes.json)))
|
||||
|
@ -1,4 +1,7 @@
|
||||
{ stdenvNoCC, lib, fetchurl, unzip
|
||||
{ stdenvNoCC
|
||||
, lib
|
||||
, fetchurl
|
||||
, unzip
|
||||
, dfVersion
|
||||
}:
|
||||
|
||||
@ -49,7 +52,8 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
release = if hasAttr dfVersion twbt-releases
|
||||
release =
|
||||
if hasAttr dfVersion twbt-releases
|
||||
then getAttr dfVersion twbt-releases
|
||||
else throw "[TWBT] Unsupported Dwarf Fortress version: ${dfVersion}";
|
||||
in
|
||||
|
@ -1,7 +1,21 @@
|
||||
{ stdenv, lib, fetchFromGitHub, cmake
|
||||
, libGL, libSM, SDL, SDL_image, SDL_ttf, glew, openalSoft
|
||||
, ncurses, glib, gtk2, libsndfile, zlib
|
||||
, dfVersion, pkg-config
|
||||
{ stdenv
|
||||
, lib
|
||||
, fetchFromGitHub
|
||||
, cmake
|
||||
, libGL
|
||||
, libSM
|
||||
, SDL
|
||||
, SDL_image
|
||||
, SDL_ttf
|
||||
, glew
|
||||
, openalSoft
|
||||
, ncurses
|
||||
, glib
|
||||
, gtk2
|
||||
, libsndfile
|
||||
, zlib
|
||||
, dfVersion
|
||||
, pkg-config
|
||||
}:
|
||||
|
||||
with lib;
|
||||
@ -46,7 +60,8 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
release = if hasAttr dfVersion unfuck-releases
|
||||
release =
|
||||
if hasAttr dfVersion unfuck-releases
|
||||
then getAttr dfVersion unfuck-releases
|
||||
else throw "[unfuck] Unknown Dwarf Fortress version: ${dfVersion}";
|
||||
in
|
||||
@ -68,8 +83,17 @@ stdenv.mkDerivation {
|
||||
|
||||
nativeBuildInputs = [ cmake pkg-config ];
|
||||
buildInputs = [
|
||||
libSM SDL SDL_image SDL_ttf glew openalSoft
|
||||
ncurses gtk2 libsndfile zlib libGL
|
||||
libSM
|
||||
SDL
|
||||
SDL_image
|
||||
SDL_ttf
|
||||
glew
|
||||
openalSoft
|
||||
ncurses
|
||||
gtk2
|
||||
libsndfile
|
||||
zlib
|
||||
libGL
|
||||
];
|
||||
|
||||
# Don't strip unused symbols; dfhack hooks into some of them.
|
||||
|
@ -1,10 +1,19 @@
|
||||
{ stdenv, lib, buildEnv, substituteAll, runCommand
|
||||
{ stdenv
|
||||
, lib
|
||||
, buildEnv
|
||||
, substituteAll
|
||||
, runCommand
|
||||
, coreutils
|
||||
, dwarf-fortress
|
||||
, dwarf-therapist
|
||||
, enableDFHack ? false, dfhack
|
||||
, enableSoundSense ? false, soundSense, jdk
|
||||
, enableDFHack ? false
|
||||
, dfhack
|
||||
, enableSoundSense ? false
|
||||
, soundSense
|
||||
, jdk
|
||||
, enableStoneSense ? false
|
||||
, enableTWBT ? false, twbt
|
||||
, enableTWBT ? false
|
||||
, twbt
|
||||
, themes ? { }
|
||||
, theme ? null
|
||||
# General config options:
|
||||
@ -89,8 +98,15 @@ stdenv.mkDerivation {
|
||||
name = "dwarf-fortress-init";
|
||||
src = ./dwarf-fortress-init.in;
|
||||
inherit env;
|
||||
exe = if stdenv.isLinux then "libs/Dwarf_Fortress"
|
||||
exe =
|
||||
if stdenv.isLinux then "libs/Dwarf_Fortress"
|
||||
else "dwarfort.exe";
|
||||
stdenv_shell = "${stdenv.shell}";
|
||||
cp = "${coreutils}/bin/cp";
|
||||
rm = "${coreutils}/bin/rm";
|
||||
ln = "${coreutils}/bin/ln";
|
||||
cat = "${coreutils}/bin/cat";
|
||||
mkdir = "${coreutils}/bin/mkdir";
|
||||
};
|
||||
|
||||
runDF = ./dwarf-fortress.in;
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!@stdenv_shell@ -e
|
||||
shopt -s extglob
|
||||
|
||||
[ -z "$DF_DIR" ] && export DF_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/df_linux"
|
||||
@ -7,25 +8,25 @@ exe="$env_dir/@exe@"
|
||||
update_path() {
|
||||
local path="$1"
|
||||
|
||||
mkdir -p "$DF_DIR/$(dirname "$path")"
|
||||
@mkdir@ -p "$DF_DIR/$(dirname "$path")"
|
||||
# If user has replaced these data directories, let them stay.
|
||||
if [ ! -e "$DF_DIR/$path" ] || [ -L "$DF_DIR/$path" ]; then
|
||||
rm -f "$DF_DIR/$path"
|
||||
ln -s "$env_dir/$path" "$DF_DIR/$path"
|
||||
@rm@ -f "$DF_DIR/$path"
|
||||
@ln@ -s "$env_dir/$path" "$DF_DIR/$path"
|
||||
fi
|
||||
}
|
||||
|
||||
forcecopy_path() {
|
||||
local path="$1"
|
||||
|
||||
mkdir -p "$DF_DIR/$(dirname "$path")"
|
||||
rm -rf "$DF_DIR/$path"
|
||||
cp -rL --no-preserve=all "$env_dir/$path" "$DF_DIR/$path"
|
||||
@mkdir@ -p "$DF_DIR/$(dirname "$path")"
|
||||
@rm@ -rf "$DF_DIR/$path"
|
||||
@cp@ -rL --no-preserve=all "$env_dir/$path" "$DF_DIR/$path"
|
||||
}
|
||||
|
||||
mkdir -p "$DF_DIR"
|
||||
@mkdir@ -p "$DF_DIR"
|
||||
|
||||
cat <<EOF >&2
|
||||
@cat@ <<EOF >&2
|
||||
Using $DF_DIR as Dwarf Fortress overlay directory.
|
||||
If you do any changes in it, don't forget to clean it when updating the game version!
|
||||
We try to detect changes based on data directories being symbolic links -- keep this in mind.
|
||||
|
Loading…
Reference in New Issue
Block a user