nixos-config/pkgs/factorio-headless/update.sh
Leonardo Eugênio 961fb02d9a factorio: update
2024-11-23 23:41:28 -03:00

15 lines
570 B
Bash
Executable file

#!/bin/sh
set -xe
cd "$(dirname $0)"
current_version="$(rg '^.*?version\s*=\s*"(.+)".*?$' --replace '$1' ./default.nix)"
current_hash="$(rg '^.*?hash\s*=\s*"(.+)".*?$' --replace '$1' ./default.nix)"
new_version="$(curl https://factorio.com/api/latest-releases | jq -r .stable.headless)"
new_hash="$(nix-hash --to-sri --type sha256 $(nix-prefetch-url --type sha256 https://www.factorio.com/get-download/${new_version}/headless/linux64))"
sd --fixed-strings "$current_version" "$new_version" ./default.nix
sd --fixed-strings "$current_hash" "$new_hash" ./default.nix