nixos-config/pkgs/factorio-headless/update.sh

15 lines
570 B
Bash
Raw Normal View History

2024-10-31 19:59:35 -03:00
#!/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))"
2024-11-23 23:41:28 -03:00
sd --fixed-strings "$current_version" "$new_version" ./default.nix
sd --fixed-strings "$current_hash" "$new_hash" ./default.nix