diff options
Diffstat (limited to 'nixpkgs/pkgs/games/cataclysm-dda')
-rw-r--r-- | nixpkgs/pkgs/games/cataclysm-dda/builder.nix | 49 | ||||
-rw-r--r-- | nixpkgs/pkgs/games/cataclysm-dda/common.nix | 104 | ||||
-rw-r--r-- | nixpkgs/pkgs/games/cataclysm-dda/default.nix | 43 | ||||
-rw-r--r-- | nixpkgs/pkgs/games/cataclysm-dda/git.nix | 54 | ||||
-rw-r--r-- | nixpkgs/pkgs/games/cataclysm-dda/lib.nix | 46 | ||||
-rw-r--r-- | nixpkgs/pkgs/games/cataclysm-dda/locale-path.patch | 18 | ||||
-rw-r--r-- | nixpkgs/pkgs/games/cataclysm-dda/pkgs/default.nix | 29 | ||||
-rw-r--r-- | nixpkgs/pkgs/games/cataclysm-dda/pkgs/tilesets/UndeadPeople/default.nix | 23 | ||||
-rw-r--r-- | nixpkgs/pkgs/games/cataclysm-dda/stable.nix | 66 | ||||
-rw-r--r-- | nixpkgs/pkgs/games/cataclysm-dda/wrapper.nix | 47 |
10 files changed, 479 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/games/cataclysm-dda/builder.nix b/nixpkgs/pkgs/games/cataclysm-dda/builder.nix new file mode 100644 index 000000000000..24128875f3a1 --- /dev/null +++ b/nixpkgs/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/nixpkgs/pkgs/games/cataclysm-dda/common.nix b/nixpkgs/pkgs/games/cataclysm-dda/common.nix new file mode 100644 index 000000000000..b2aa2878080b --- /dev/null +++ b/nixpkgs/pkgs/games/cataclysm-dda/common.nix @@ -0,0 +1,104 @@ +{ lib, stdenv, runtimeShell, pkg-config, gettext, ncurses, CoreFoundation +, tiles, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, freetype, Cocoa +, debug +, useXdgDir +}: + +let + inherit (lib) optionals optionalString; + + cursesDeps = [ gettext ncurses ] + ++ optionals stdenv.isDarwin [ CoreFoundation ]; + + tilesDeps = [ SDL2 SDL2_image SDL2_mixer SDL2_ttf freetype ] + ++ optionals stdenv.isDarwin [ Cocoa ]; + + patchDesktopFile = '' + substituteInPlace $out/share/applications/org.cataclysmdda.CataclysmDDA.desktop \ + --replace "Exec=cataclysm-tiles" "Exec=$out/bin/cataclysm-tiles" + ''; + + installMacOSAppLauncher = '' + app=$out/Applications/Cataclysm.app + install -D -m 444 build-data/osx/Info.plist -t $app/Contents + install -D -m 444 build-data/osx/AppIcon.icns -t $app/Contents/Resources + mkdir $app/Contents/MacOS + launcher=$app/Contents/MacOS/Cataclysm.sh + cat << EOF > $launcher + #!${runtimeShell} + $out/bin/cataclysm-tiles + EOF + chmod 555 $launcher + ''; +in + +stdenv.mkDerivation { + pname = "cataclysm-dda"; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = cursesDeps ++ optionals tiles tilesDeps; + + postPatch = '' + patchShebangs lang/compile_mo.sh + ''; + + makeFlags = [ + "PREFIX=$(out)" "LANGUAGES=all" + (if useXdgDir then "USE_XDG_DIR=1" else "USE_HOME_DIR=1") + ] ++ optionals (!debug) [ + "RELEASE=1" + ] ++ optionals tiles [ + "TILES=1" "SOUND=1" + ] ++ optionals stdenv.isDarwin [ + "NATIVE=osx" + "CLANG=1" + "OSX_MIN=${stdenv.hostPlatform.darwinMinVersion}" + ]; + + postInstall = optionalString tiles + ( if !stdenv.isDarwin + then patchDesktopFile + else installMacOSAppLauncher + ); + + dontStrip = debug; + enableParallelBuilding = true; + + passthru = { + isTiles = tiles; + isCurses = !tiles; + }; + + meta = with lib; { + description = "A free, post apocalyptic, zombie infested rogue-like"; + mainProgram = "cataclysm-tiles"; + longDescription = '' + Cataclysm: Dark Days Ahead is a roguelike set in a post-apocalyptic world. + Surviving is difficult: you have been thrown, ill-equipped, into a + landscape now riddled with monstrosities of which flesh eating zombies are + neither the strangest nor the deadliest. + + Yet with care and a little luck, many things are possible. You may try to + eke out an existence in the forests silently executing threats and + providing sustenance with your longbow. You can ride into town in a + jerry-rigged vehicle, all guns blazing, to settle matters in a fug of + smoke from your molotovs. You could take a more measured approach and + construct an impregnable fortress, surrounded by traps to protect you from + the horrors without. The longer you survive, the more skilled and adapted + you will get and the better equipped and armed to deal with the threats + you are presented with. + + In the course of your ordeal there will be opportunities and temptations + to improve or change your very nature. There are tales of survivors fitted + with extraordinary cybernetics giving great power and stories too of + gravely mutated survivors who, warped by their ingestion of exotic + substances or radiation, now more closely resemble insects, birds or fish + than their original form. + ''; + homepage = "https://cataclysmdda.org/"; + license = licenses.cc-by-sa-30; + maintainers = with maintainers; [ mnacamura DeeUnderscore ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/games/cataclysm-dda/default.nix b/nixpkgs/pkgs/games/cataclysm-dda/default.nix new file mode 100644 index 000000000000..1649cd031a4b --- /dev/null +++ b/nixpkgs/pkgs/games/cataclysm-dda/default.nix @@ -0,0 +1,43 @@ +{ newScope, darwin }: + +let + 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 + attachPkgs; + + inherit pkgs; + }; +in + +self diff --git a/nixpkgs/pkgs/games/cataclysm-dda/git.nix b/nixpkgs/pkgs/games/cataclysm-dda/git.nix new file mode 100644 index 000000000000..155f900e96f3 --- /dev/null +++ b/nixpkgs/pkgs/games/cataclysm-dda/git.nix @@ -0,0 +1,54 @@ +{ stdenv, lib, callPackage, CoreFoundation, fetchFromGitHub, fetchpatch, pkgs, wrapCDDA, attachPkgs +, tiles ? true, Cocoa +, debug ? false +, useXdgDir ? false +, version ? "2022-08-20" +, rev ? "f65b2bc4c6dea24bd9a993b8df146e5698e7e36f" +, sha256 ? "sha256-00Tp9OmsM39PYwAJXKKRS9zmn7KsGQ9s1eVmEqghkpw=" +}: + +let + common = callPackage ./common.nix { + inherit CoreFoundation tiles Cocoa debug useXdgDir; + }; + + self = common.overrideAttrs (common: rec { + pname = common.pname + "-git"; + inherit version; + + src = fetchFromGitHub { + owner = "CleverRaven"; + repo = "Cataclysm-DDA"; + inherit rev sha256; + }; + + patches = [ + # Unconditionally look for translation files in $out/share/locale + ./locale-path.patch + # Fixes for failing build with GCC 13, remove on updating next release after 0.G + (fetchpatch { + url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-dangling-reference-warning.patch"; + hash = "sha256-9nPbyz49IYBOVHqr7jzCIyS8z/SQgpK4EjEz1fruIPE="; + }) + (fetchpatch { + url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-cstdint.patch"; + hash = "sha256-8IBW2OzAHVgEJZoViQ490n37sl31hA55ePuqDL/lil0="; + }) + (fetchpatch { + url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-keyword-requires.patch"; + hash = "sha256-8yvHh0YKC7AC/qzia7AZAfMewMC0RiSepMXpOkMXRd8="; + }) + ]; + + makeFlags = common.makeFlags ++ [ + "VERSION=git-${version}-${lib.substring 0 8 src.rev}" + ]; + + meta = common.meta // { + maintainers = with lib.maintainers; + common.meta.maintainers ++ [ rardiol ]; + }; + }); +in + +attachPkgs pkgs self diff --git a/nixpkgs/pkgs/games/cataclysm-dda/lib.nix b/nixpkgs/pkgs/games/cataclysm-dda/lib.nix new file mode 100644 index 000000000000..f2b38a16aa53 --- /dev/null +++ b/nixpkgs/pkgs/games/cataclysm-dda/lib.nix @@ -0,0 +1,46 @@ +{ callPackage }: + +rec { + buildMod = callPackage ./builder.nix { + type = "mod"; + }; + + buildSoundPack = callPackage ./builder.nix { + type = "soundpack"; + }; + + buildTileSet = callPackage ./builder.nix { + type = "tileset"; + }; + + wrapCDDA = callPackage ./wrapper.nix {}; + + # Required to fix `pkgs` and `withMods` attrs after applying `overrideAttrs`. + # + # Example: + # let + # myBuild = cataclysmDDA.jenkins.latest.tiles.overrideAttrs (_: { + # x = "hello"; + # }); + # + # # This refers to the derivation before overriding! So, `badExample.x` is not accessible. + # badExample = myBuild.withMods (_: []); + # + # # `myBuild` is correctly referred by `withMods` and `goodExample.x` is accessible. + # goodExample = let + # inherit (cataclysmDDA) attachPkgs pkgs; + # in + # (attachPkgs pkgs myBuild).withMods (_: []); + # in + # goodExample.x # returns "hello" + attachPkgs = pkgs: super: + let + self = super.overrideAttrs (old: { + passthru = old.passthru // { + pkgs = pkgs.override { build = self; }; + withMods = wrapCDDA self; + }; + }); + in + self; +} diff --git a/nixpkgs/pkgs/games/cataclysm-dda/locale-path.patch b/nixpkgs/pkgs/games/cataclysm-dda/locale-path.patch new file mode 100644 index 000000000000..03f103a548fd --- /dev/null +++ b/nixpkgs/pkgs/games/cataclysm-dda/locale-path.patch @@ -0,0 +1,18 @@ +diff --git a/src/translations.cpp b/src/translations.cpp +index 76bdfd0..6dd6109 100644 +--- a/src/translations.cpp ++++ b/src/translations.cpp +@@ -61,13 +61,11 @@ std::string locale_dir() + #define BSD + #endif + +-#if !defined(__ANDROID__) && ((defined(__linux__) || defined(BSD) || (defined(MACOSX) && !defined(TILES)))) + if( !PATH_INFO::base_path().empty() ) { + loc_dir = PATH_INFO::base_path() + "share/locale"; + } else { + loc_dir = PATH_INFO::langdir(); + } +-#endif + #endif // LOCALIZE + return loc_dir; + } diff --git a/nixpkgs/pkgs/games/cataclysm-dda/pkgs/default.nix b/nixpkgs/pkgs/games/cataclysm-dda/pkgs/default.nix new file mode 100644 index 000000000000..72b2c814389a --- /dev/null +++ b/nixpkgs/pkgs/games/cataclysm-dda/pkgs/default.nix @@ -0,0 +1,29 @@ +{ lib, callPackage, build ? null }: + +let + pkgs = { + mod = { + }; + + soundpack = { + }; + + tileset = { + UndeadPeople = callPackage ./tilesets/UndeadPeople {}; + }; + }; + + pkgs' = lib.mapAttrs (_: mods: lib.filterAttrs isAvailable mods) pkgs; + + isAvailable = _: mod: + if (build == null) then + true + else if build.isTiles then + mod.forTiles or false + else if build.isCurses then + mod.forCurses or false + else + false; +in + +lib.makeExtensible (_: pkgs') diff --git a/nixpkgs/pkgs/games/cataclysm-dda/pkgs/tilesets/UndeadPeople/default.nix b/nixpkgs/pkgs/games/cataclysm-dda/pkgs/tilesets/UndeadPeople/default.nix new file mode 100644 index 000000000000..07465d137c3e --- /dev/null +++ b/nixpkgs/pkgs/games/cataclysm-dda/pkgs/tilesets/UndeadPeople/default.nix @@ -0,0 +1,23 @@ +{ lib, buildTileSet, fetchFromGitHub }: + +buildTileSet { + modName = "UndeadPeople"; + version = "2020-07-08"; + + src = fetchFromGitHub { + owner = "jmz-b"; + repo = "UndeadPeopleTileset"; + rev = "f7f13b850fafe2261deee051f45d9c611a661534"; + sha256 = "0r06srjr7rq51jk9yfyxz80nfgb98mkn86cbcjfxpibgbqvcp0zm"; + }; + + modRoot = "MSX++UnDeadPeopleEdition"; + + meta = with lib; { + description = "Cataclysm DDA tileset based on MSX++ tileset"; + homepage = "https://github.com/jmz-b/UndeadPeopleTileset"; + license = licenses.unfree; + maintainers = with maintainers; [ mnacamura ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/games/cataclysm-dda/stable.nix b/nixpkgs/pkgs/games/cataclysm-dda/stable.nix new file mode 100644 index 000000000000..90eab89a8349 --- /dev/null +++ b/nixpkgs/pkgs/games/cataclysm-dda/stable.nix @@ -0,0 +1,66 @@ +{ lib +, callPackage +, CoreFoundation +, fetchFromGitHub +, fetchpatch +, pkgs +, wrapCDDA +, attachPkgs +, tiles ? true +, Cocoa +, debug ? false +, useXdgDir ? false +}: + +let + common = callPackage ./common.nix { + inherit CoreFoundation tiles Cocoa debug useXdgDir; + }; + + self = common.overrideAttrs (common: rec { + version = "0.G"; + + src = fetchFromGitHub { + owner = "CleverRaven"; + repo = "Cataclysm-DDA"; + rev = version; + sha256 = "sha256-Hda0dVVHNeZ8MV5CaCbSpdOCG2iqQEEmXdh16vwIBXk="; + }; + + patches = [ + # Unconditionally look for translation files in $out/share/locale + ./locale-path.patch + # Fixes for failing build with GCC 13, remove on updating next release after 0.G + (fetchpatch { + url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-dangling-reference-warning.patch"; + hash = "sha256-9nPbyz49IYBOVHqr7jzCIyS8z/SQgpK4EjEz1fruIPE="; + }) + (fetchpatch { + url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-cstdint.patch"; + hash = "sha256-8IBW2OzAHVgEJZoViQ490n37sl31hA55ePuqDL/lil0="; + }) + (fetchpatch { + url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-keyword-requires.patch"; + hash = "sha256-8yvHh0YKC7AC/qzia7AZAfMewMC0RiSepMXpOkMXRd8="; + }) + ]; + + makeFlags = common.makeFlags ++ [ + # Makefile declares version as 0.F, with no minor release number + "VERSION=${version}" + ]; + + env.NIX_CFLAGS_COMPILE = toString [ + # Needed with GCC 12 + "-Wno-error=array-bounds" + ]; + + meta = common.meta // { + maintainers = with lib.maintainers; + common.meta.maintainers; + changelog = "https://github.com/CleverRaven/Cataclysm-DDA/blob/${version}/data/changelog.txt"; + }; + }); +in + +attachPkgs pkgs self diff --git a/nixpkgs/pkgs/games/cataclysm-dda/wrapper.nix b/nixpkgs/pkgs/games/cataclysm-dda/wrapper.nix new file mode 100644 index 000000000000..28189fa7375a --- /dev/null +++ b/nixpkgs/pkgs/games/cataclysm-dda/wrapper.nix @@ -0,0 +1,47 @@ +{ 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 + + # Launch the wrapped program + replaceProgram() { + cp "$1" "''${1}.bk" + unlink "$1" + mv "''${1}.bk" "$1" + sed -i "$1" -e "s,${builtins.storeDir}/.\+\(/bin/cataclysm-tiles\),$out\1," + } + for script in "$out/share/applications/cataclysm-dda.desktop" \ + "$out/Applications/Cataclysm.app/Contents/MacOS/Cataclysm.sh" + do + if [ -e "$script" ]; then + replaceProgram "$script" + fi + done + ''; +} |