mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
cataclysmDDA: add very basic framework for packaging mods
Add new namespace 'cataclysmDDA', in which package builders, games, and mods are listed.
This commit is contained in:
parent
bf71f12cb5
commit
ac8555486f
49
pkgs/games/cataclysm-dda/builder.nix
Normal file
49
pkgs/games/cataclysm-dda/builder.nix
Normal file
@ -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";
|
||||
};
|
||||
})
|
@ -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
|
||||
|
@ -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;
|
||||
callPackage = newScope self;
|
||||
|
||||
stable = rec {
|
||||
tiles = callPackage ./stable.nix {
|
||||
inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa;
|
||||
};
|
||||
|
||||
curses = tiles.override { tiles = false; };
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
stdenv.mkDerivation (common // rec {
|
||||
version = "0.E-2";
|
||||
|
||||
src = fetchFromCleverRaven {
|
||||
rev = version;
|
||||
sha256 = "15l6w6lxays7qmsv0ci2ry53asb9an9dh7l7fc13256k085qcg68";
|
||||
};
|
||||
|
||||
meta = with stdenv.lib.maintainers; common.meta // {
|
||||
maintainers = common.meta.maintainers ++ [ skeidel ];
|
||||
};
|
||||
})
|
||||
self
|
||||
|
@ -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;
|
||||
common = callPackage ./common.nix {
|
||||
inherit tiles CoreFoundation Cocoa debug;
|
||||
};
|
||||
|
||||
self = common.overrideAttrs (common: rec {
|
||||
pname = common.pname + "-git";
|
||||
version = "2019-11-22";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "CleverRaven";
|
||||
repo = "Cataclysm-DDA";
|
||||
rev = "a6c8ece992bffeae3788425dd4b3b5871e66a9cd";
|
||||
sha256 = "0ww2q5gykxm802z1kffmnrfahjlx123j1gfszklpsv0b1fccm1ab";
|
||||
};
|
||||
|
||||
makeFlags = common.makeFlags ++ [
|
||||
"VERSION=git-${version}-${lib.substring 0 8 src.rev}"
|
||||
];
|
||||
|
||||
passthru = common.passthru // {
|
||||
pkgs = pkgs.override { build = self; };
|
||||
withMods = wrapCDDA self;
|
||||
};
|
||||
|
||||
meta = with lib.maintainers; common.meta // {
|
||||
maintainers = common.meta.maintainers ++ [ rardiol ];
|
||||
};
|
||||
});
|
||||
in
|
||||
|
||||
stdenv.mkDerivation (common // rec {
|
||||
pname = common.pname + "-git";
|
||||
version = "2019-11-22";
|
||||
|
||||
src = fetchFromCleverRaven {
|
||||
rev = "a6c8ece992bffeae3788425dd4b3b5871e66a9cd";
|
||||
sha256 = "0ww2q5gykxm802z1kffmnrfahjlx123j1gfszklpsv0b1fccm1ab";
|
||||
};
|
||||
|
||||
makeFlags = common.makeFlags ++ [
|
||||
"VERSION=git-${version}-${substring 0 8 src.rev}"
|
||||
];
|
||||
|
||||
meta = with stdenv.lib.maintainers; common.meta // {
|
||||
maintainers = common.meta.maintainers ++ [ rardiol ];
|
||||
};
|
||||
})
|
||||
self
|
||||
|
17
pkgs/games/cataclysm-dda/lib.nix
Normal file
17
pkgs/games/cataclysm-dda/lib.nix
Normal file
@ -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 {};
|
||||
}
|
24
pkgs/games/cataclysm-dda/pkgs/default.nix
Normal file
24
pkgs/games/cataclysm-dda/pkgs/default.nix
Normal file
@ -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
|
32
pkgs/games/cataclysm-dda/stable.nix
Normal file
32
pkgs/games/cataclysm-dda/stable.nix
Normal file
@ -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
|
32
pkgs/games/cataclysm-dda/wrapper.nix
Normal file
32
pkgs/games/cataclysm-dda/wrapper.nix
Normal file
@ -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
|
||||
'';
|
||||
}
|
@ -23864,13 +23864,11 @@ in
|
||||
inherit (darwin.apple_sdk.frameworks) Carbon CoreServices;
|
||||
};
|
||||
|
||||
cataclysm-dda = callPackage ../games/cataclysm-dda {
|
||||
inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa;
|
||||
};
|
||||
cataclysmDDA = callPackage ../games/cataclysm-dda { };
|
||||
|
||||
cataclysm-dda-git = callPackage ../games/cataclysm-dda/git.nix {
|
||||
inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa;
|
||||
};
|
||||
cataclysm-dda = cataclysmDDA.stable.tiles;
|
||||
|
||||
cataclysm-dda-git = cataclysmDDA.git.tiles;
|
||||
|
||||
chessdb = callPackage ../games/chessdb { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user