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
This commit is contained in:
parent
22111b5dc7
commit
aad8139fdc
2 changed files with 30 additions and 4 deletions
15
users/erwin/download-factorio.sh
Normal file
15
users/erwin/download-factorio.sh
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# 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}"
|
|
@ -11,10 +11,21 @@ let
|
||||||
homeCfg = config.home-manager.users.erwin;
|
homeCfg = config.home-manager.users.erwin;
|
||||||
bt = config.eboskma.bluetooth;
|
bt = config.eboskma.bluetooth;
|
||||||
|
|
||||||
downloadFactorio = pkgs.writeShellScriptBin "download-factorio" ''
|
downloadFactorio = pkgs.writeShellApplication {
|
||||||
version=$(${pkgs.xh}/bin/xhs factorio.com/api/latest-releases | ${pkgs.jaq}/bin/jaq -r '.stable.alpha')
|
name = "download-factorio";
|
||||||
${pkgs.nix}/bin/nix-prefetch-url --name factorio_alpha_x64-''${version}.tar.xz https://factorio.com/get-download/''${version}/alpha/linux64\?username=eboskma\&token=$(cat ${config.sops.secrets.factorio-token.path})
|
text = builtins.readFile ./download-factorio.sh;
|
||||||
'';
|
runtimeInputs = with pkgs; [
|
||||||
|
jaq
|
||||||
|
nix
|
||||||
|
xh
|
||||||
|
];
|
||||||
|
runtimeEnv = {
|
||||||
|
FACTORIO_TOKEN_FILE = config.sops.secrets.factorio-token.path;
|
||||||
|
};
|
||||||
|
derivationArgs = {
|
||||||
|
version = "0.0.1";
|
||||||
|
};
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = mkIf cfg.home {
|
config = mkIf cfg.home {
|
||||||
|
|
Loading…
Reference in a new issue