summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authorworldofpeace <worldofpeace@protonmail.ch>2020-07-22 16:18:32 -0400
committerGitHub <noreply@github.com>2020-07-22 16:18:32 -0400
commit8b6e9818a5079102299c0ed54bae35bc27d9538c (patch)
tree4e4f62612d74edb9d8d04e6766232a3dffef4a84 /pkgs/games
parentd74da4fe5273a3350719a07ae230e92dcc705de1 (diff)
parentf2b2347b2950e78e45216b05034cf074f75c4108 (diff)
downloadnixpkgs-8b6e9818a5079102299c0ed54bae35bc27d9538c.tar
nixpkgs-8b6e9818a5079102299c0ed54bae35bc27d9538c.tar.gz
nixpkgs-8b6e9818a5079102299c0ed54bae35bc27d9538c.tar.bz2
nixpkgs-8b6e9818a5079102299c0ed54bae35bc27d9538c.tar.lz
nixpkgs-8b6e9818a5079102299c0ed54bae35bc27d9538c.tar.xz
nixpkgs-8b6e9818a5079102299c0ed54bae35bc27d9538c.tar.zst
nixpkgs-8b6e9818a5079102299c0ed54bae35bc27d9538c.zip
Merge pull request #84873 from mnacamura/cdda-mods
cataclysmDDA: add modding interface
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/cataclysm-dda/builder.nix49
-rw-r--r--pkgs/games/cataclysm-dda/common.nix187
-rw-r--r--pkgs/games/cataclysm-dda/default.nix51
-rw-r--r--pkgs/games/cataclysm-dda/git.nix54
-rw-r--r--pkgs/games/cataclysm-dda/lib.nix17
-rw-r--r--pkgs/games/cataclysm-dda/patches/fix_locale_dir.patch18
-rw-r--r--pkgs/games/cataclysm-dda/patches/fix_locale_dir_git.patch20
-rw-r--r--pkgs/games/cataclysm-dda/pkgs/default.nix27
-rw-r--r--pkgs/games/cataclysm-dda/pkgs/tilesets/UndeadPeople/default.nix23
-rw-r--r--pkgs/games/cataclysm-dda/stable.nix34
-rw-r--r--pkgs/games/cataclysm-dda/wrapper.nix47
11 files changed, 357 insertions, 170 deletions
diff --git a/pkgs/games/cataclysm-dda/builder.nix b/pkgs/games/cataclysm-dda/builder.nix
new file mode 100644
index 00000000000..24128875f3a
--- /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 f904a3c0f35..9ec73cdebe0 100644
--- a/pkgs/games/cataclysm-dda/common.nix
+++ b/pkgs/games/cataclysm-dda/common.nix
@@ -1,6 +1,7 @@
-{ stdenv, fetchFromGitHub, pkgconfig, gettext, ncurses, CoreFoundation
+{ stdenv, runtimeShell, pkgconfig, gettext, ncurses, CoreFoundation
 , tiles, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, freetype, Cocoa
-, debug, runtimeShell
+, debug
+, useXdgDir
 }:
 
 let
@@ -12,98 +13,100 @@ let
   tilesDeps = [ SDL2 SDL2_image SDL2_mixer SDL2_ttf freetype ]
     ++ optionals stdenv.isDarwin [ Cocoa ];
 
-  common = {
-    nativeBuildInputs = [ pkgconfig ];
-
-    buildInputs = cursesDeps ++ optionals tiles tilesDeps;
-
-    postPatch = ''
-      patchShebangs .
-    '';
+  installXDGAppLauncher = ''
+    launcher="$out/share/applications/cataclysm-dda.desktop"
+    install -D -m 444 data/xdg/*cataclysm-dda.desktop -T "$launcher"
+    sed -i "$launcher" -e "s,\(Exec=\)\(cataclysm-tiles\),\1$out/bin/\2,"
+    install -D -m 444 data/xdg/cataclysm-dda.svg -t $out/share/icons/hicolor/scalable/apps
+  '';
+
+  installMacOSAppLauncher = ''
+    app=$out/Applications/Cataclysm.app
+    install -D -m 444 data/osx/Info.plist -t $app/Contents
+    install -D -m 444 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
 
-    makeFlags = [
-      "PREFIX=$(out)" "USE_HOME_DIR=1" "LANGUAGES=all"
-    ] ++ optionals (!debug) [
-      "RELEASE=1"
-    ] ++ optionals tiles [
-      "TILES=1" "SOUND=1"
-    ] ++ optionals stdenv.isDarwin [
-      "NATIVE=osx" "CLANG=1"
-    ];
-
-    postInstall = optionalString tiles
-    ( if !stdenv.isDarwin
-      then utils.installXDGAppLauncher
-      else utils.installMacOSAppLauncher
-    );
-
-    dontStrip = debug;
-
-    # https://hydra.nixos.org/build/65193254
-    # src/weather_data.cpp:203:1: fatal error: opening dependency file obj/tiles/weather_data.d: No such file or directory
-    # make: *** [Makefile:687: obj/tiles/weather_data.o] Error 1
-    enableParallelBuilding = false;
-
-    meta = with stdenv.lib; {
-      description = "A free, post apocalyptic, zombie infested rogue-like";
-      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 ];
-      platforms = platforms.unix;
-    };
+stdenv.mkDerivation {
+  pname = "cataclysm-dda";
+
+  nativeBuildInputs = [ pkgconfig ];
+
+  buildInputs = cursesDeps ++ optionals tiles tilesDeps;
+
+  postPatch = ''
+    patchShebangs .
+
+    # Locale patch required for Darwin builds, see:
+    # https://github.com/NixOS/nixpkgs/pull/74064#issuecomment-560083970
+    sed -i src/translations.cpp \
+        -e 's@#elif (defined(__linux__) || (defined(MACOSX) && !defined(TILES)))@#elif 1@'
+  '';
+
+  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"
+  ];
+
+  postInstall = optionalString tiles
+  ( if !stdenv.isDarwin
+    then installXDGAppLauncher
+    else installMacOSAppLauncher
+  );
+
+  dontStrip = debug;
+
+  # https://hydra.nixos.org/build/65193254
+  # src/weather_data.cpp:203:1: fatal error: opening dependency file obj/tiles/weather_data.d: No such file or directory
+  # make: *** [Makefile:687: obj/tiles/weather_data.o] Error 1
+  enableParallelBuilding = false;
+
+  passthru = {
+    isTiles = tiles;
+    isCurses = !tiles;
   };
 
-  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"
-      sed -i "$launcher" -e "s,\(Exec=\)\(cataclysm-tiles\),\1$out/bin/\2,"
-      install -D -m 444 data/xdg/cataclysm-dda.svg -t $out/share/icons/hicolor/scalable/apps
-    '';
-
-    installMacOSAppLauncher = ''
-      app=$out/Applications/Cataclysm.app
-      install -D -m 444 data/osx/Info.plist -t $app/Contents
-      install -D -m 444 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
+  meta = with stdenv.lib; {
+    description = "A free, post apocalyptic, zombie infested rogue-like";
+    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 ];
+    platforms = platforms.unix;
   };
-in
-
-{ inherit common utils; }
+}
diff --git a/pkgs/games/cataclysm-dda/default.nix b/pkgs/games/cataclysm-dda/default.nix
index c046b0d3a2d..ada212ea7e9 100644
--- a/pkgs/games/cataclysm-dda/default.nix
+++ b/pkgs/games/cataclysm-dda/default.nix
@@ -1,25 +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";
-  name = "cataclysm-dda-${version}";
+  stable = rec {
+    tiles = callPackage ./stable.nix {
+      inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa;
+    };
 
-  src = fetchFromCleverRaven {
-    rev = version;
-    sha256 = "15l6w6lxays7qmsv0ci2ry53asb9an9dh7l7fc13256k085qcg68";
+    curses = tiles.override { tiles = false; };
   };
 
-  patches = [ ./patches/fix_locale_dir.patch ];
+  git = rec {
+    tiles = callPackage ./git.nix {
+      inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa;
+    };
 
-  meta = with stdenv.lib.maintainers; common.meta // {
-    maintainers = common.meta.maintainers ++ [ skeidel ];
+    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 8e3c3e33994..36f37f7aeba 100644
--- a/pkgs/games/cataclysm-dda/git.nix
+++ b/pkgs/games/cataclysm-dda/git.nix
@@ -1,33 +1,41 @@
-{ stdenv, callPackage, CoreFoundation
+{ lib, callPackage, CoreFoundation, fetchFromGitHub, pkgs, wrapCDDA
 , tiles ? true, Cocoa
 , debug ? false
+, useXdgDir ? false
+, version ? "2019-11-22"
+, rev ? "a6c8ece992bffeae3788425dd4b3b5871e66a9cd"
+, sha256 ? "0ww2q5gykxm802z1kffmnrfahjlx123j1gfszklpsv0b1fccm1ab"
 }:
 
 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 CoreFoundation tiles Cocoa debug useXdgDir;
+  };
 
-stdenv.mkDerivation (common // rec {
-  version = "2019-11-22";
-  name = "cataclysm-dda-git-${version}";
+  self = common.overrideAttrs (common: rec {
+    pname = common.pname + "-git";
+    inherit version;
 
-  src = fetchFromCleverRaven {
-    rev = "a6c8ece992bffeae3788425dd4b3b5871e66a9cd";
-    sha256 = "0ww2q5gykxm802z1kffmnrfahjlx123j1gfszklpsv0b1fccm1ab";
-  };
+    src = fetchFromGitHub {
+      owner = "CleverRaven";
+      repo = "Cataclysm-DDA";
+      inherit rev sha256;
+    };
 
-  patches = [
-    # Locale patch required for Darwin builds, see: https://github.com/NixOS/nixpkgs/pull/74064#issuecomment-560083970
-    ./patches/fix_locale_dir_git.patch
-  ];
+    makeFlags = common.makeFlags ++ [
+      "VERSION=git-${version}-${lib.substring 0 8 src.rev}"
+    ];
 
-  makeFlags = common.makeFlags ++ [
-    "VERSION=git-${version}-${substring 0 8 src.rev}"
-  ];
+    passthru = common.passthru // {
+      pkgs = pkgs.override { build = self; };
+      withMods = wrapCDDA self;
+    };
 
-  meta = with stdenv.lib.maintainers; common.meta // {
-    maintainers = common.meta.maintainers ++ [ rardiol ];
-  };
-})
+    meta = common.meta // {
+      maintainers = with lib.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 00000000000..02678ed0228
--- /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/patches/fix_locale_dir.patch b/pkgs/games/cataclysm-dda/patches/fix_locale_dir.patch
deleted file mode 100644
index 5bfff892d2a..00000000000
--- a/pkgs/games/cataclysm-dda/patches/fix_locale_dir.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/src/translations.cpp
-+++ b/src/translations.cpp
-@@ -212,14 +212,12 @@ void set_language()
-     auto env = getenv( "LANGUAGE" );
-     locale_dir = std::string( PATH_INFO::base_path() + "lang/mo/" + ( env ? env : "none" ) +
-                               "/LC_MESSAGES/cataclysm-dda.mo" );
--#elif (defined(__linux__) || (defined(MACOSX) && !defined(TILES)))
-+#else
-     if( !PATH_INFO::base_path().empty() ) {
-         locale_dir = PATH_INFO::base_path() + "share/locale";
-     } else {
-         locale_dir = "lang/mo";
-     }
--#else
--    locale_dir = "lang/mo";
- #endif
- 
-     const char *locale_dir_char = locale_dir.c_str();
diff --git a/pkgs/games/cataclysm-dda/patches/fix_locale_dir_git.patch b/pkgs/games/cataclysm-dda/patches/fix_locale_dir_git.patch
deleted file mode 100644
index 79b442ff5c9..00000000000
--- a/pkgs/games/cataclysm-dda/patches/fix_locale_dir_git.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-diff --git a/src/translations.cpp b/src/translations.cpp
-index 067e2cd77d..5660d18b3d 100644
---- a/src/translations.cpp
-+++ b/src/translations.cpp
-@@ -211,14 +211,12 @@ void set_language()
-     auto env = getenv( "LANGUAGE" );
-     locale_dir = std::string( FILENAMES["base_path"] + "lang/mo/" + ( env ? env : "none" ) +
-                               "/LC_MESSAGES/cataclysm-dda.mo" );
--#elif (defined(__linux__) || (defined(MACOSX) && !defined(TILES)))
-+#else
-     if( !FILENAMES["base_path"].empty() ) {
-         locale_dir = FILENAMES["base_path"] + "share/locale";
-     } else {
-         locale_dir = "lang/mo";
-     }
--#else
--    locale_dir = "lang/mo";
- #endif
-
-     const char *locale_dir_char = locale_dir.c_str();
diff --git a/pkgs/games/cataclysm-dda/pkgs/default.nix b/pkgs/games/cataclysm-dda/pkgs/default.nix
new file mode 100644
index 00000000000..6f3df09a786
--- /dev/null
+++ b/pkgs/games/cataclysm-dda/pkgs/default.nix
@@ -0,0 +1,27 @@
+{ lib, callPackage, build ? null }:
+
+let
+  pkgs = {
+    mod = {
+    };
+
+    soundpack = {
+    };
+
+    tileset = {
+      UndeadPeople = callPackage ./tilesets/UndeadPeople {};
+    };
+  };
+
+  pkgs' = lib.mapAttrs (_: mod: lib.filterAttrs availableForBuild mod) pkgs;
+
+  availableForBuild = _: mod:
+  if isNull build then
+    true
+  else if build.isTiles then
+    mod.forTiles
+  else
+    mod.forCurses;
+in
+
+lib.makeExtensible (_: pkgs')
diff --git a/pkgs/games/cataclysm-dda/pkgs/tilesets/UndeadPeople/default.nix b/pkgs/games/cataclysm-dda/pkgs/tilesets/UndeadPeople/default.nix
new file mode 100644
index 00000000000..7a58cea8208
--- /dev/null
+++ b/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 = "SomeDeadGuy";
+    repo = "UndeadPeopleTileset";
+    rev = "f7f13b850fafe2261deee051f45d9c611a661534";
+    sha256 = "0r06srjr7rq51jk9yfyxz80nfgb98mkn86cbcjfxpibgbqvcp0zm";
+  };
+
+  modRoot = "MSX++UnDeadPeopleEdition";
+
+  meta = with lib; {
+    description = "Cataclysm DDA tileset based on MSX++ tileset";
+    homepage = "https://github.com/SomeDeadGuy/UndeadPeopleTileset";
+    license = licenses.unfree;
+    maintainers = with maintainers; [ mnacamura ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/games/cataclysm-dda/stable.nix b/pkgs/games/cataclysm-dda/stable.nix
new file mode 100644
index 00000000000..076a33a9e89
--- /dev/null
+++ b/pkgs/games/cataclysm-dda/stable.nix
@@ -0,0 +1,34 @@
+{ lib, callPackage, CoreFoundation, fetchFromGitHub, pkgs, wrapCDDA
+, 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.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 = common.meta // {
+      maintainers = with lib.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 00000000000..a73c320f9c6
--- /dev/null
+++ b/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,/nix/store/.\+\(/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
+  '';
+}