nix-gog-games/games/settlers-2-gold.nix

78 lines
2.5 KiB
Nix

{ pkgs ? import <nixpkgs> {}, fetchgog }:
let
desktopItem = pkgs.makeDesktopItem {
desktopName = "settlers-2-gold-2";
name = "settlers-2-gold-2";
exec = "@out@/bin/settlers_2_gold";
icon = "settlers-2-gold-2";
terminal = "False";
type = "Application";
categories = "Game;StrategyGame";
genericName = "The Settlers 2 Gold";
};
in
pkgs.stdenv.mkDerivation rec {
name = "settlers-2-gold-2.0.0.14";
src = fetchgog {
name = "setup_${name}.exe";
sha256 = "19c88h972ydfpdbay61lz6pi4gnlm2lq5dcya5im9mmlin2nvyr7";
fileid = "the_settlers_2_gold_edition/en1installer0";
};
nativeBuildInputs = with pkgs; [ innoextract ];
buildInputs = with pkgs; [ bash dosbox unionfs-fuse ];
unpackPhase = ''
mkdir -p $out/share/settlers-2-gold
cd $out/share/settlers-2-gold
innoextract $src
mkdir -p $out/share/icons
ln -s $out/share/settlers-2-gold/app/gfw_high.ico $out/share/icons/gfw_high.ico
rm -rf tmp
'';
# patchPhase = ''
# sed -i "s;\\.\\.;$out/share/settlers-2-gold/app;g" $out/share/settlers-2-gold/app/dosboxSettlers2_editor.conf
# sed -i "s;\\.\\.;$out/share/settlers-2-gold/app;g" $out/share/settlers-2-gold/app/dosboxSettlers2_single.conf
# '';
installPhase = ''
mkdir -p $out/bin
cat << EOF > $out/bin/settlers_2_gold
#!${pkgs.bash}/bin/bash
tmpfolder=/tmp/settlers-2-gold_\$(head -c 5 /dev/urandom | base32)
mkdir -p \$tmpfolder
mkdir -p \$HOME/.local/share/settlers-2-gold
cd \$HOME/.local/share/settlers-2-gold
${pkgs.unionfs-fuse}/bin/unionfs -o cow -o uid=\$(id -u) -o gid=\$(id -g) -o umask=022 \$HOME/.local/share/settlers-2-gold/=RW:$out/share/settlers-2-gold/app/=RO \$tmpfolder
cd \$tmpfolder/DOSBOX
${pkgs.dosbox}/bin/dosbox -conf ../dosboxSettlers2.conf -conf ../dosboxSettlers2_single.conf
cd
fusermount -u \$tmpfolder
rmdir \$tmpfolder
EOF
chmod +x $out/bin/settlers_2_gold
install -Dm755 ${desktopItem}/share/applications/settlers-2-gold-2.desktop $out/share/applications/settlers-2-gold-2.desktop
'';
meta = with pkgs.stdenv.lib; {
description = "A realtime strategy game.";
homepage = https://www.gog.com/game/the_settlers_2_gold_edition;
license = licenses.unfree;
maintainers = [{
email = "jakob-nixos@truh.at";
github = "truh";
name = "Jakob Klepp";
}];
platforms = platforms.linux;
broken = true;
};
}