diff options
author | Mitsuhiro Nakamura <m.nacamura@gmail.com> | 2020-04-08 10:46:57 +0900 |
---|---|---|
committer | Mitsuhiro Nakamura <m.nacamura@gmail.com> | 2020-07-18 14:23:19 +0900 |
commit | ac8555486fe9f6c6d346192096b474d3b6a1f5a2 (patch) | |
tree | 67df74b9188abcaa1f3edc7e6abb54f4da436644 /pkgs/games/cataclysm-dda | |
parent | bf71f12cb5e9868d8427160d0680fde48c2316c2 (diff) |
cataclysmDDA: add very basic framework for packaging mods
Add new namespace 'cataclysmDDA', in which package builders, games, and
mods are listed.
Diffstat (limited to 'pkgs/games/cataclysm-dda')
-rw-r--r-- | pkgs/games/cataclysm-dda/builder.nix | 49 | ||||
-rw-r--r-- | pkgs/games/cataclysm-dda/common.nix | 18 | ||||
-rw-r--r-- | pkgs/games/cataclysm-dda/default.nix | 50 | ||||
-rw-r--r-- | pkgs/games/cataclysm-dda/git.nix | 47 | ||||
-rw-r--r-- | pkgs/games/cataclysm-dda/lib.nix | 17 | ||||
-rw-r--r-- | pkgs/games/cataclysm-dda/pkgs/default.nix | 24 | ||||
-rw-r--r-- | pkgs/games/cataclysm-dda/stable.nix | 32 | ||||
-rw-r--r-- | pkgs/games/cataclysm-dda/wrapper.nix | 32 |
8 files changed, 225 insertions, 44 deletions
diff --git a/pkgs/games/cataclysm-dda/builder.nix b/pkgs/games/cataclysm-dda/builder.nix new file mode 100644 index 000000000000..24128875f3a1 --- /dev/null +++ b/pkgs/games/cataclysm-dda/builder.nix @@ -0,0 +1,49 @@ +{ stdenvNoCC, lib, type }: + +assert lib.elem type [ + "mod" + "soundpack" + "tileset" +]; + +{ modName, version, src, ... } @ args: + +stdenvNoCC.mkDerivation (args // rec { + pname = args.pname or "cataclysm-dda-${type}-${modName}"; + + modRoot = args.modRoot or "."; + + configurePhase = args.configurePhase or '' + runHook preConfigure + runHook postConfigure + ''; + + buildPhase = args.buildPhase or '' + runHook preBuild + runHook postBuild + ''; + + checkPhase = args.checkPhase or '' + runHook preCheck + runHook postCheck + ''; + + installPhase = let + baseDir = { + mod = "mods"; + soundpack = "sound"; + tileset = "gfx"; + }.${type}; + in args.installPhase or '' + runHook preInstall + destdir="$out/share/cataclysm-dda/${baseDir}" + mkdir -p "$destdir" + cp -R "${modRoot}" "$destdir/${modName}" + runHook postInstall + ''; + + passthru = { + forTiles = true; + forCurses = type == "mod"; + }; +}) diff --git a/pkgs/games/cataclysm-dda/common.nix b/pkgs/games/cataclysm-dda/common.nix index 48941bdb01f6..3cbda9479070 100644 --- a/pkgs/games/cataclysm-dda/common.nix +++ b/pkgs/games/cataclysm-dda/common.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchFromGitHub, pkgconfig, gettext, ncurses, CoreFoundation +{ stdenv, pkgconfig, gettext, ncurses, CoreFoundation , tiles, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, freetype, Cocoa , debug, runtimeShell }: @@ -12,7 +12,7 @@ let tilesDeps = [ SDL2 SDL2_image SDL2_mixer SDL2_ttf freetype ] ++ optionals stdenv.isDarwin [ Cocoa ]; - common = { + common = stdenv.mkDerivation { pname = "cataclysm-dda"; nativeBuildInputs = [ pkgconfig ]; @@ -51,6 +51,11 @@ let # make: *** [Makefile:687: obj/tiles/weather_data.o] Error 1 enableParallelBuilding = false; + passthru = { + isTiles = tiles; + isCurses = !tiles; + }; + meta = with stdenv.lib; { description = "A free, post apocalyptic, zombie infested rogue-like"; longDescription = '' @@ -84,13 +89,6 @@ let }; utils = { - fetchFromCleverRaven = { rev, sha256 }: - fetchFromGitHub { - owner = "CleverRaven"; - repo = "Cataclysm-DDA"; - inherit rev sha256; - }; - installXDGAppLauncher = '' launcher="$out/share/applications/cataclysm-dda.desktop" install -D -m 444 data/xdg/*cataclysm-dda.desktop -T "$launcher" @@ -113,4 +111,4 @@ let }; in -{ inherit common utils; } +common diff --git a/pkgs/games/cataclysm-dda/default.nix b/pkgs/games/cataclysm-dda/default.nix index ed3fe7fdfc7a..ada212ea7e9f 100644 --- a/pkgs/games/cataclysm-dda/default.nix +++ b/pkgs/games/cataclysm-dda/default.nix @@ -1,22 +1,42 @@ -{ stdenv, callPackage, CoreFoundation -, tiles ? true, Cocoa -, debug ? false -}: +{ newScope, darwin }: let - inherit (callPackage ./common.nix { inherit tiles CoreFoundation Cocoa debug; }) common utils; - inherit (utils) fetchFromCleverRaven; -in + callPackage = newScope self; -stdenv.mkDerivation (common // rec { - version = "0.E-2"; + stable = rec { + tiles = callPackage ./stable.nix { + inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa; + }; - src = fetchFromCleverRaven { - rev = version; - sha256 = "15l6w6lxays7qmsv0ci2ry53asb9an9dh7l7fc13256k085qcg68"; + curses = tiles.override { tiles = false; }; }; - meta = with stdenv.lib.maintainers; common.meta // { - maintainers = common.meta.maintainers ++ [ skeidel ]; + git = rec { + tiles = callPackage ./git.nix { + inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa; + }; + + curses = tiles.override { tiles = false; }; + }; + + lib = callPackage ./lib.nix {}; + + pkgs = callPackage ./pkgs {}; + + self = { + inherit + callPackage + stable + git; + + inherit (lib) + buildMod + buildSoundPack + buildTileSet + wrapCDDA; + + inherit pkgs; }; -}) +in + +self diff --git a/pkgs/games/cataclysm-dda/git.nix b/pkgs/games/cataclysm-dda/git.nix index 8e803ed63dff..89af582b3c07 100644 --- a/pkgs/games/cataclysm-dda/git.nix +++ b/pkgs/games/cataclysm-dda/git.nix @@ -1,28 +1,37 @@ -{ stdenv, callPackage, CoreFoundation +{ lib, callPackage, CoreFoundation, fetchFromGitHub, pkgs, wrapCDDA , tiles ? true, Cocoa , debug ? false }: let - inherit (stdenv.lib) substring; - inherit (callPackage ./common.nix { inherit tiles CoreFoundation Cocoa debug; }) common utils; - inherit (utils) fetchFromCleverRaven; -in + common = callPackage ./common.nix { + inherit tiles CoreFoundation Cocoa debug; + }; -stdenv.mkDerivation (common // rec { - pname = common.pname + "-git"; - version = "2019-11-22"; + self = common.overrideAttrs (common: rec { + pname = common.pname + "-git"; + version = "2019-11-22"; - src = fetchFromCleverRaven { - rev = "a6c8ece992bffeae3788425dd4b3b5871e66a9cd"; - sha256 = "0ww2q5gykxm802z1kffmnrfahjlx123j1gfszklpsv0b1fccm1ab"; - }; + src = fetchFromGitHub { + owner = "CleverRaven"; + repo = "Cataclysm-DDA"; + rev = "a6c8ece992bffeae3788425dd4b3b5871e66a9cd"; + sha256 = "0ww2q5gykxm802z1kffmnrfahjlx123j1gfszklpsv0b1fccm1ab"; + }; - makeFlags = common.makeFlags ++ [ - "VERSION=git-${version}-${substring 0 8 src.rev}" - ]; + makeFlags = common.makeFlags ++ [ + "VERSION=git-${version}-${lib.substring 0 8 src.rev}" + ]; - meta = with stdenv.lib.maintainers; common.meta // { - maintainers = common.meta.maintainers ++ [ rardiol ]; - }; -}) + passthru = common.passthru // { + pkgs = pkgs.override { build = self; }; + withMods = wrapCDDA self; + }; + + meta = with lib.maintainers; common.meta // { + maintainers = common.meta.maintainers ++ [ rardiol ]; + }; + }); +in + +self diff --git a/pkgs/games/cataclysm-dda/lib.nix b/pkgs/games/cataclysm-dda/lib.nix new file mode 100644 index 000000000000..02678ed0228e --- /dev/null +++ b/pkgs/games/cataclysm-dda/lib.nix @@ -0,0 +1,17 @@ +{ callPackage }: + +{ + buildMod = callPackage ./builder.nix { + type = "mod"; + }; + + buildSoundPack = callPackage ./builder.nix { + type = "soundpack"; + }; + + buildTileSet = callPackage ./builder.nix { + type = "tileset"; + }; + + wrapCDDA = callPackage ./wrapper.nix {}; +} diff --git a/pkgs/games/cataclysm-dda/pkgs/default.nix b/pkgs/games/cataclysm-dda/pkgs/default.nix new file mode 100644 index 000000000000..fb5571243f53 --- /dev/null +++ b/pkgs/games/cataclysm-dda/pkgs/default.nix @@ -0,0 +1,24 @@ +{ lib, callPackage, build ? null }: + +let + pkgs = { + mod = { + }; + + soundpack = { + }; + + tileset = { + }; + }; + + availableForBuild = _: mod: + if isNull build then + true + else if build.isTiles then + mod.forTiles + else + mod.forCurses; +in + +lib.mapAttrs (_: mod: lib.filterAttrs availableForBuild mod) pkgs diff --git a/pkgs/games/cataclysm-dda/stable.nix b/pkgs/games/cataclysm-dda/stable.nix new file mode 100644 index 000000000000..e142f67d190a --- /dev/null +++ b/pkgs/games/cataclysm-dda/stable.nix @@ -0,0 +1,32 @@ +{ lib, callPackage, CoreFoundation, fetchFromGitHub, pkgs, wrapCDDA +, tiles ? true, Cocoa +, debug ? false +}: + +let + common = callPackage ./common.nix { + inherit tiles CoreFoundation Cocoa debug; + }; + + self = common.overrideAttrs (common: rec { + version = "0.E-2"; + + src = fetchFromGitHub { + owner = "CleverRaven"; + repo = "Cataclysm-DDA"; + rev = version; + sha256 = "15l6w6lxays7qmsv0ci2ry53asb9an9dh7l7fc13256k085qcg68"; + }; + + passthru = common.passthru // { + pkgs = pkgs.override { build = self; }; + withMods = wrapCDDA self; + }; + + meta = with lib.maintainers; common.meta // { + maintainers = common.meta.maintainers ++ [ skeidel ]; + }; + }); +in + +self diff --git a/pkgs/games/cataclysm-dda/wrapper.nix b/pkgs/games/cataclysm-dda/wrapper.nix new file mode 100644 index 000000000000..0a3727c2c1c1 --- /dev/null +++ b/pkgs/games/cataclysm-dda/wrapper.nix @@ -0,0 +1,32 @@ +{ lib, symlinkJoin, makeWrapper }: + +unwrapped: + +pkgsSpec: + +let + mods = if lib.isFunction pkgsSpec + then pkgsSpec unwrapped.pkgs + else pkgsSpec; +in + +if builtins.length mods == 0 +then unwrapped +else symlinkJoin { + name = unwrapped.name + "-with-mods"; + + paths = [ unwrapped ] ++ mods; + + nativeBuildInputs = [ makeWrapper ]; + + postBuild = '' + if [ -x $out/bin/cataclysm ]; then + wrapProgram $out/bin/cataclysm \ + --add-flags "--datadir $out/share/cataclysm-dda/" + fi + if [ -x $out/bin/cataclysm-tiles ]; then + wrapProgram $out/bin/cataclysm-tiles \ + --add-flags "--datadir $out/share/cataclysm-dda/" + fi + ''; +} |