-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
the-dark-mod{,-assets}: init at 2.12
- Loading branch information
Showing
7 changed files
with
266 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
curl, | ||
xvfb-run, | ||
the-dark-mod, | ||
}: | ||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "the-dark-mod-assets"; | ||
inherit (the-dark-mod) version; | ||
|
||
nativeBuildInputs = [ | ||
curl | ||
xvfb-run # The installer needs an X11 environment even when unattended | ||
]; | ||
|
||
dontUnpack = true; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
mkdir build | ||
cd build | ||
# The installer *really* wants to live in a writable directory to dump its files in | ||
cp ${lib.getExe the-dark-mod.installer} ./installer | ||
while true; do | ||
code=0 | ||
xvfb-run ./installer \ | ||
--unattended \ | ||
--version "release${builtins.replaceStrings [ "." ] [ "" ] finalAttrs.version}" \ | ||
|| code=$? | ||
case $code in | ||
0) break ;; | ||
18) echo "spurious network error; retrying"; continue ;; | ||
*) echo "error: failed to install game assets"; exit $code ;; | ||
esac | ||
done | ||
runHook postBuild | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
# Filter out files: | ||
# * That aren't decidedly reproducible (logs, tmpfiles, any installer manifests), | ||
# * That we want to build ourselves (executables) | ||
# * That we want to replace with our own (darkmod.ini) | ||
find . \ | ||
! -name "*.log" \ | ||
! -path "./.zipsync/*" \ | ||
! -name "*.iniz" \ | ||
! \( -name "*.exe" -o -executable \) \ | ||
! -name "darkmod.ini" \ | ||
-exec install -Dm644 {} $out/{} \; | ||
runHook postInstall | ||
''; | ||
|
||
outputHashMode = "recursive"; | ||
outputHashAlgo = "sha256"; | ||
outputHash = "sha256-W2BzvKCqoIQYCT/U2Jks1ZtewVSo/ucevR67pnqZTvA="; | ||
|
||
meta = { | ||
inherit (the-dark-mod.meta) homepage changelog maintainers; | ||
description = "Assets for the Dark Mod"; | ||
license = with lib.licenses; [ cc-by-nc-sa-30 ]; | ||
platforms = lib.platforms.all; | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
fetchsvn, | ||
|
||
cmake, | ||
ninja, | ||
xorg, | ||
iconConvTools, | ||
makeDesktopItem, | ||
copyDesktopItems, | ||
writableDirWrapper, | ||
|
||
addDriverRunpath, | ||
libGL, | ||
alsa-lib, | ||
makeBinaryWrapper, | ||
the-dark-mod-assets, | ||
}: | ||
let | ||
libPath = lib.makeLibraryPath [ | ||
# GLFW | ||
addDriverRunpath.driverLink | ||
libGL | ||
xorg.libX11 | ||
xorg.libXcursor | ||
xorg.libXext | ||
xorg.libXrandr | ||
xorg.libXxf86vm | ||
|
||
# OpenAL | ||
alsa-lib | ||
]; | ||
|
||
gameDir = "\${XDG_DATA_HOME:-$HOME/.local/share}/darkmod"; | ||
|
||
description = "Dark and moody stealth game inspired by the Thief series by Looking Glass Studios"; | ||
in | ||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "the-dark-mod"; | ||
version = "2.12"; | ||
|
||
# We use the SVN repo as it contains built static binaries that are not | ||
# present in the Git mirror. Currently Nixpkgs only supports a limited set | ||
# of packages that can be statically linked (notably excluding ffmpeg, pulseaudio | ||
# and pipewire), so we couldn't build everything from scratch even if we want to :( | ||
src = fetchsvn { | ||
url = "https://svn.thedarkmod.com/publicsvn/darkmod_src/tags/${finalAttrs.version}"; | ||
rev = "10652"; | ||
hash = "sha256-jPQWoLlsUQqpBB1BECR9m/p+HwD0jJlpqwUaIqygwP0="; | ||
}; | ||
|
||
outputs = [ | ||
"out" | ||
"debug" | ||
]; | ||
|
||
nativeBuildInputs = [ | ||
cmake | ||
ninja | ||
makeBinaryWrapper | ||
iconConvTools | ||
copyDesktopItems | ||
writableDirWrapper | ||
]; | ||
|
||
buildInputs = [ | ||
xorg.xorgproto | ||
xorg.libX11 | ||
xorg.libXxf86vm | ||
xorg.libXext | ||
]; | ||
|
||
cmakeFlags = [ | ||
(lib.cmakeFeature "GAME_DIR" "${placeholder "out"}/bin") | ||
]; | ||
|
||
# O_O it installs stuff in buildPhase... | ||
preBuild = '' | ||
mkdir -p $out/bin | ||
''; | ||
|
||
dontUseNinjaInstall = true; | ||
|
||
desktopItems = [ | ||
(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; | ||
}) | ||
]; | ||
|
||
postInstall = '' | ||
icoFileToHiColorTheme ${the-dark-mod-assets}/darkmod.ico the-dark-mod $out | ||
''; | ||
|
||
postFixup = '' | ||
moveToOutput bin/thedarkmod.x64.debug $debug | ||
mv $out/bin/thedarkmod.x64 $out/bin/the-dark-mod | ||
wrapProgramInWritableDir $out/bin/the-dark-mod '${gameDir}' \ | ||
--prefix LD_LIBRARY_PATH : ${libPath} \ | ||
--set ALSOFT_CONF ${the-dark-mod-assets}/alsoft.ini \ | ||
--add-flags '+set fs_basepath "${the-dark-mod-assets}"' \ | ||
--add-flags '+set fs_savepath "${gameDir}"' \ | ||
--add-flags '+set fs_modSavePath "${gameDir}/fms"' | ||
''; | ||
|
||
passthru.installer = stdenv.mkDerivation { | ||
pname = "the-dark-mod-installer"; | ||
inherit (finalAttrs) version src; | ||
sourceRoot = "${finalAttrs.src.name}/tdm_installer"; | ||
|
||
nativeBuildInputs = [ | ||
cmake | ||
ninja | ||
]; | ||
buildInputs = [ | ||
xorg.libX11 | ||
xorg.libXext | ||
]; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
install -Dm755 tdm_installer.linux64 -t $out/bin | ||
runHook postInstall | ||
''; | ||
|
||
meta.mainProgram = "tdm_installer.linux64"; | ||
}; | ||
|
||
meta = { | ||
inherit description; | ||
homepage = "https://www.thedarkmod.com/"; | ||
changelog = "https://wiki.thedarkmod.com/index.php?title=What%27s_new_in_TDM_${finalAttrs.version}"; | ||
license = with lib.licenses; [ | ||
gpl3Plus # Portions based on Doom 3 | ||
bsd3 # Original code | ||
]; | ||
# Other Linux platforms may work (including i686-linux) but are not officially supported | ||
platforms = [ "x86_64-linux" ]; | ||
maintainers = with lib.maintainers; [ pluiedev ]; | ||
mainProgram = "the-dark-mod"; | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
Empty file.