Skip to content

Commit

Permalink
the-dark-mod: init at 2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
pluiedev committed Dec 2, 2024
1 parent 1433132 commit b341e66
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
88 changes: 88 additions & 0 deletions pkgs/by-name/th/the-dark-mod/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
lib,
symlinkJoin,
makeDesktopItem,
iconConvTools,

the-dark-mod-unwrapped,
the-dark-mod-assets,
writableDirWrapper,
}:
let
runScript = writableDirWrapper rec {
name = "the-dark-mod";
inherit (the-dark-mod-unwrapped) version;
path = "\${XDG_DATA_HOME:-$HOME/.local/share}/darkmod";

links = [ { src = the-dark-mod-assets; } ];

postLink = ''
# Log directory override - by default TDM puts the logs directly in PWD.
# We don't want that. If the user does not already have a darkmod.ini, we
# generate a default one with the correct log path
rm darkmod.ini
if [[ ! -e "${path}/darkmod.ini" ]]; then
logDir="''${XDG_STATE_HOME:-$HOME/.local/state}/darkmod"
mkdir -p "$logDir"
printf "[Debug]\nLogFile=%s/Darkmod.log" "$logDir" > darkmod.ini
fi
'';

run = ''
${lib.getExe the-dark-mod-unwrapped} \
+set fs_basepath "${path}" \
+set fs_savepath "${path}" \
+set fs_modSavePath "${path}/fms" \
'';
};

description = "Dark and moody stealth game inspired by the Thief series by Looking Glass Studios";

desktopItem = makeDesktopItem {
name = "the-dark-mod";
desktopName = "The Dark Mod";
comment = description;
icon = "the-dark-mod";
exec = "the-dark-mod";
categories = [
"Game"
"ActionGame"
"AdventureGame"
"RolePlaying"
];
keywords = [
"Stealth"
"Steampunk"
"Thief"
];
prefersNonDefaultGPU = true;
};
in
symlinkJoin {
pname = "the-dark-mod";
inherit (the-dark-mod-unwrapped) version;

paths = [
runScript
desktopItem
];

nativeBuildInputs = [ iconConvTools ];

postBuild = ''
icoFileToHiColorTheme ${the-dark-mod-assets}/darkmod.ico the-dark-mod $out
'';

meta = {
inherit (the-dark-mod-unwrapped.meta)
homepage
changelog
platforms
maintainers
;
inherit description;
license = the-dark-mod-unwrapped.meta.license ++ the-dark-mod-assets.meta.license;
mainProgram = "the-dark-mod";
};
}
33 changes: 33 additions & 0 deletions pkgs/by-name/th/the-dark-mod/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p subversion common-updater-scripts

attr=the-dark-mod
svnUrl=https://svn.thedarkmod.com/publicsvn/darkmod_src/tags

versions=$(svn list $svnUrl | rg "^\d+.\d+/\$" | tr -d '/')
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; $attr.version" | tr -d '"')

echo "Current TDM version: $currentVersion"
for version in $versions; do
[ "$version" = "$(printf '%s\n%s' "$version" "$currentVersion" | sort -V | head -n1)" ] && continue

echo "New version found: $version";
rev=$(svn info $svnUrl/$version --show-item last-changed-revision)

echo "Updating engine";
update-source-version "$attr-unwrapped" "$version" --rev="$rev"

echo "Updating assets";
oldAssetsHash=$(nix-instantiate --eval --strict -A "the-dark-mod-assets.drvAttrs.outputHash" | tr -d '"')
nix-build --no-out-link -A "the-dark-mod-assets" 2>&1 | tee assets.log
newAssetsHash=$(grep -P --only-matching "got: +.+[:-]\K.+" assets.log)

sed -i.cmp 's,$oldAssetsHash,$newAssetsHash,' pkgs/by-name/th/the-dark-mod-assets/package.nix

echo "Update complete!";

exit 0
done

echo "Already at latest version"

0 comments on commit b341e66

Please sign in to comment.