1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-14 16:46:09 +00:00
nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in
Cole Helbling 5db4a65384 dfhack: 0.47.04-alpha0 -> 0.47.04-r2
As of
56e43a0dde,
dfhack gets its goodies from the directory above the Dwarf_Fortress
executable, which leads to stock Dwarf Fortress and not the built
environment where all the dfhack resources are symlinked to (typically
~/.local/share/df_linux). This causes errors like `tweak is not a
recognized command` to be reported and dfhack to lose some of its
functionality.
2020-08-21 14:45:53 -07:00

45 lines
1.1 KiB
Plaintext

shopt -s extglob
[ -z "$DF_DIR" ] && export DF_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/df_linux"
env_dir="@env@"
exe="$env_dir/@exe@"
update_path() {
local path="$1"
mkdir -p "$DF_DIR/$(dirname "$path")"
# If user has replaced these data directories, let them stay.
if [ ! -e "$DF_DIR/$path" ] || [ -L "$DF_DIR/$path" ]; then
rm -f "$DF_DIR/$path"
ln -s "$env_dir/$path" "$DF_DIR/$path"
fi
}
forcecopy_path() {
local path="$1"
mkdir -p "$DF_DIR/$(dirname "$path")"
rm -rf "$DF_DIR/$path"
cp -rL --no-preserve=all "$env_dir/$path" "$DF_DIR/$path"
}
mkdir -p "$DF_DIR"
cat <<EOF >&2
Using $DF_DIR as Dwarf Fortress overlay directory.
If you do any changes in it, don't forget to clean it when updating the game version!
We try to detect changes based on data directories being symbolic links -- keep this in mind.
EOF
cd "$env_dir"
for i in data/init/* data/!(init|index|announcement) raw; do
update_path "$i"
done
forcecopy_path data/index
# For some reason, it's needed to be writable...
forcecopy_path data/announcement
forcecopy_path data/help
forcecopy_path data/dipscript