nixos-config/users/erwin/download-factorio.sh
Erwin Boskma aad8139fdc
Update factorio download script to accept optional edition argument.
Possible values:
- alpha (default): The base game
- headless: For server use
- demo: The Factorio Demo
- expansion: Factorio: Space Age expansion
2024-11-12 15:00:14 +01:00

15 lines
445 B
Bash

# shellcheck shell=bash
edition=alpha
if [[ $# -ge 1 ]]; then
edition="${1}"
fi
releases_file=$(mktemp --suffix=.json)
xhs -o "${releases_file}" factorio.com/api/latest-releases
version=$(jaq -r '.stable.alpha' "${releases_file}")
token=$(cat "${FACTORIO_TOKEN_FILE:?}")
nix-prefetch-url --name "factorio_${edition}_x64-${version}.tar.xz" \
"https://factorio.com/get-download/${version}/${edition}/linux64?username=eboskma&token=${token}"