Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keen4: convert away from builder.sh #146713

Merged
merged 1 commit into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions pkgs/games/keen4/builder.sh

This file was deleted.

35 changes: 32 additions & 3 deletions pkgs/games/keen4/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,45 @@

stdenv.mkDerivation {
name = "keen4";
builder = ./builder.sh;

dist = fetchurl {
src = fetchurl {
url = "http://tarballs.nixos.org/keen4.zip";
sha256 = "12rnc9ksl7v6l8wsxvr26ylkafzq80dbsa7yafzw9pqc8pafkhx1";
};

nativeBuildInputs = [ unzip ];

inherit dosbox;
installPhase = ''
mkdir -p $out/share/keen4
Copy link
Contributor

@l0b0 l0b0 Nov 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable substitutions should be quoted to allow for whitespace in filenames. Ditto in the rest of the script.

Copy link
Member Author

@SuperSandro2000 SuperSandro2000 Nov 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$out cannot contain any whitespace or everything will fall apart. There are probably many more changes required to make this work with whitespaces and should probably be an RFC.

mv * $out/share/keen4

mkdir -p $out/bin
cat > $out/bin/keen4 <<EOF
#! $SHELL -e
if test -z "\$HOME"; then
echo "HOME directory not set"
exit 1
fi

# Game wants to write in the current directory, but of course we can't
# let it write in the Nix store. So create symlinks to the game files
# in ~/.keen4 and execute game from there.
mkdir -p \$HOME/.keen4
cd \$HOME/.keen4

ln -sf $out/share/keen4/* .

${dosbox}/bin/dosbox ./KEEN4E.EXE -fullscreen -exit || true

# Cleanup the symlinks.
for i in *; do
if test -L "\$i"; then
rm "\$i"
fi
done
EOF
chmod +x $out/bin/keen4
'';

meta = {
description = "Commander Keen Episode 4: Secret of the Oracle";
Expand Down