dwarf-fortress: refactors

This will make it easier for people to access old versions.

You can now access attributes like:

- dwarf-fortress_0_44_11
- dwarf-fortress_0_43_05
- etc.
This commit is contained in:
Matthew Bauer 2018-07-08 15:44:29 -04:00
parent cdd0ac7e54
commit 530427c7ab
5 changed files with 47 additions and 41 deletions

View File

@ -1,12 +1,19 @@
{ pkgs, stdenv, stdenvNoCC, gccStdenv }: { pkgs, stdenv, stdenvNoCC, gccStdenv, lib }:
let let
callPackage = pkgs.newScope self; callPackage = pkgs.newScope self;
self = rec { df-games = lib.listToAttrs (map (dfVersion: {
dwarf-fortress-original = callPackage ./game.nix { name = "dwarf-fortress_${lib.replaceStrings ["."] ["_"] dfVersion}";
dfVersion = "0.44.11"; value = callPackage ./wrapper {
inherit (self) themes;
dwarf-fortress = callPackage ./game.nix { inherit dfVersion; };
}; };
}) (lib.attrNames self.df-hashes));
self = rec {
df-hashes = builtins.fromJSON (builtins.readFile ./game.json);
dwarf-fortress = df-games.dwarf-fortress_0_44_11;
dfhack = callPackage ./dfhack { dfhack = callPackage ./dfhack {
inherit (pkgs.perlPackages) XMLLibXML XMLLibXSLT; inherit (pkgs.perlPackages) XMLLibXML XMLLibXSLT;
@ -17,29 +24,27 @@ let
# unfuck is linux-only right now, we will just use it there # unfuck is linux-only right now, we will just use it there
dwarf-fortress-unfuck = if stdenv.isLinux then callPackage ./unfuck.nix { } dwarf-fortress-unfuck = if stdenv.isLinux then callPackage ./unfuck.nix { }
else null; else null;
dwarf-fortress = callPackage ./wrapper { dwarf-therapist = callPackage ./dwarf-therapist/wrapper.nix {
inherit themes; inherit (dwarf-fortress) dwarf-fortress;
}; dwarf-therapist = pkgs.qt5.callPackage ./dwarf-therapist {
texlive = pkgs.texlive.combine {
dwarf-therapist-original = pkgs.qt5.callPackage ./dwarf-therapist { inherit (pkgs.texlive) scheme-basic float caption wrapfig adjmulticol sidecap preprint enumitem;
texlive = pkgs.texlive.combine { };
inherit (pkgs.texlive) scheme-basic float caption wrapfig adjmulticol sidecap preprint enumitem;
}; };
}; };
dwarf-therapist = callPackage ./dwarf-therapist/wrapper.nix { };
legends-browser = callPackage ./legends-browser {}; legends-browser = callPackage ./legends-browser {};
themes = callPackage ./themes { themes = callPackage ./themes {
stdenv = stdenvNoCC; stdenv = stdenvNoCC;
}; };
# aliases
phoebus-theme = themes.phoebus; phoebus-theme = themes.phoebus;
cla-theme = themes.cla; cla-theme = themes.cla;
dwarf-fortress-original = dwarf-fortress.dwarf-fortress;
}; };
in self in self // df-games

View File

@ -1,7 +1,8 @@
{ stdenv, fetchFromGitHub, coreutils, qtbase, qtdeclarative, cmake, texlive, ninja }: { stdenv, fetchFromGitHub, coreutils, qtbase
, qtdeclarative, cmake, texlive, ninja }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "dwarf-therapist-original-${version}"; name = "dwarf-therapist-${version}";
version = "40.1.0"; version = "40.1.0";
src = fetchFromGitHub { src = fetchFromGitHub {

View File

@ -1,20 +1,19 @@
{ stdenv, symlinkJoin, lib, dwarf-therapist-original, dwarf-fortress-original, makeWrapper }: { stdenv, symlinkJoin, lib, dwarf-therapist, dwarf-fortress, makeWrapper }:
let let
df = dwarf-fortress-original;
dt = dwarf-therapist-original;
platformSlug = if stdenv.targetPlatform.is32bit then platformSlug = if stdenv.targetPlatform.is32bit then
"linux32" else "linux64"; "linux32" else "linux64";
inifile = "linux/v0.${df.baseVersion}.${df.patchVersion}_${platformSlug}.ini"; inifile = "linux/v0.${dwarf-fortress.baseVersion}.${dwarf-fortress.patchVersion}_${platformSlug}.ini";
dfHashFile = "${df}/hash.md5";
in symlinkJoin { in symlinkJoin {
name = "dwarf-therapist-${dt.version}"; name = "dwarf-therapist-${dwarf-therapist.version}";
paths = [ dt ]; paths = [ dwarf-therapist ];
buildInputs = [ makeWrapper ]; buildInputs = [ makeWrapper ];
passthru = { inherit dwarf-fortress dwarf-therapist; };
postBuild = '' postBuild = ''
# DwarfTherapist assumes it's run in $out/share/dwarftherapist and # DwarfTherapist assumes it's run in $out/share/dwarftherapist and
# therefore uses many relative paths. # therefore uses many relative paths.
@ -23,10 +22,10 @@ in symlinkJoin {
rm -rf $out/share/dwarftherapist/memory_layouts/linux rm -rf $out/share/dwarftherapist/memory_layouts/linux
mkdir -p $out/share/dwarftherapist/memory_layouts/linux mkdir -p $out/share/dwarftherapist/memory_layouts/linux
origmd5=$(cat "${dfHashFile}.orig" | cut -c1-8) origmd5=$(cat "${dwarf-fortress}/hash.md5.orig" | cut -c1-8)
patchedmd5=$(cat "${dfHashFile}" | cut -c1-8) patchedmd5=$(cat "${dwarf-fortress}/hash.md5" | cut -c1-8)
substitute \ substitute \
${dt}/share/dwarftherapist/memory_layouts/${inifile} \ ${dwarf-therapist}/share/dwarftherapist/memory_layouts/${inifile} \
$out/share/dwarftherapist/memory_layouts/${inifile} \ $out/share/dwarftherapist/memory_layouts/${inifile} \
--replace "$origmd5" "$patchedmd5" --replace "$origmd5" "$patchedmd5"
''; '';

View File

@ -4,10 +4,10 @@
# Our own "unfuck" libs for macOS # Our own "unfuck" libs for macOS
, ncurses, fmodex, gcc , ncurses, fmodex, gcc
, dfVersion , dfVersion, df-hashes
}: }:
with lib; with builtins; with lib;
let let
libpath = makeLibraryPath [ stdenv.cc.cc stdenv.cc.libc dwarf-fortress-unfuck SDL ]; libpath = makeLibraryPath [ stdenv.cc.cc stdenv.cc.libc dwarf-fortress-unfuck SDL ];
@ -30,9 +30,8 @@ let
baseVersion = elemAt dfVersionTriple 1; baseVersion = elemAt dfVersionTriple 1;
patchVersion = elemAt dfVersionTriple 2; patchVersion = elemAt dfVersionTriple 2;
games = fromJSON (readFile ./game.json); game = if hasAttr dfVersion df-hashes
game = if hasAttr dfVersion games then getAttr dfVersion df-hashes
then getAttr dfVersion games
else throw "Unknown Dwarf Fortress version: ${dfVersion}"; else throw "Unknown Dwarf Fortress version: ${dfVersion}";
dfPlatform = if hasAttr stdenv.system platforms dfPlatform = if hasAttr stdenv.system platforms
then getAttr stdenv.system platforms then getAttr stdenv.system platforms
@ -47,7 +46,7 @@ assert dwarf-fortress-unfuck != null ->
dwarf-fortress-unfuck.dfVersion == dfVersion; dwarf-fortress-unfuck.dfVersion == dfVersion;
stdenv.mkDerivation { stdenv.mkDerivation {
name = "dwarf-fortress-original-${dfVersion}"; name = "dwarf-fortress-${dfVersion}";
src = fetchurl { src = fetchurl {
url = "${homepage}df_${baseVersion}_${patchVersion}_${dfPlatform}.tar.bz2"; url = "${homepage}df_${baseVersion}_${patchVersion}_${dfPlatform}.tar.bz2";

View File

@ -1,4 +1,4 @@
{ stdenv, lib, buildEnv, dwarf-fortress-original, substituteAll { stdenv, lib, buildEnv, dwarf-fortress, substituteAll
, enableDFHack ? false, dfhack , enableDFHack ? false, dfhack
, enableSoundSense ? false, soundSense, jdk , enableSoundSense ? false, soundSense, jdk
, enableStoneSense ? false , enableStoneSense ? false
@ -20,10 +20,10 @@ let
themePkg = lib.optional (theme != null) ptheme; themePkg = lib.optional (theme != null) ptheme;
pkgs = lib.optional enableDFHack dfhack_ pkgs = lib.optional enableDFHack dfhack_
++ lib.optional enableSoundSense soundSense ++ lib.optional enableSoundSense soundSense
++ [ dwarf-fortress-original ]; ++ [ dwarf-fortress ];
env = buildEnv { env = buildEnv {
name = "dwarf-fortress-env-${dwarf-fortress-original.dfVersion}"; name = "dwarf-fortress-env-${dwarf-fortress.dfVersion}";
paths = themePkg ++ pkgs; paths = themePkg ++ pkgs;
pathsToLink = [ "/" "/hack" "/hack/scripts" ]; pathsToLink = [ "/" "/hack" "/hack/scripts" ];
@ -32,16 +32,16 @@ let
postBuild = lib.optionalString enableDFHack '' postBuild = lib.optionalString enableDFHack ''
rm $out/hack/symbols.xml rm $out/hack/symbols.xml
substitute ${dfhack_}/hack/symbols.xml $out/hack/symbols.xml \ substitute ${dfhack_}/hack/symbols.xml $out/hack/symbols.xml \
--replace $(cat ${dwarf-fortress-original}/hash.md5.orig) \ --replace $(cat ${dwarf-fortress}/hash.md5.orig) \
$(cat ${dwarf-fortress-original}/hash.md5) $(cat ${dwarf-fortress}/hash.md5)
''; '';
}; };
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "dwarf-fortress-${dwarf-fortress-original.dfVersion}"; name = "dwarf-fortress-${dwarf-fortress.dfVersion}";
compatible = lib.all (x: assert (x.dfVersion == dwarf-fortress-original.dfVersion); true) pkgs; compatible = lib.all (x: assert (x.dfVersion == dwarf-fortress.dfVersion); true) pkgs;
dfInit = substituteAll { dfInit = substituteAll {
name = "dwarf-fortress-init"; name = "dwarf-fortress-init";
@ -55,6 +55,8 @@ stdenv.mkDerivation rec {
runDFHack = ./dfhack.in; runDFHack = ./dfhack.in;
runSoundSense = ./soundSense.in; runSoundSense = ./soundSense.in;
passthru = { inherit dwarf-fortress; };
buildCommand = '' buildCommand = ''
mkdir -p $out/bin mkdir -p $out/bin