factorio: automate updating server

This commit is contained in:
Leonardo Eugênio 2024-10-31 19:59:35 -03:00
parent a989bacbd7
commit a7608ace94
4 changed files with 28 additions and 8 deletions

View file

@ -2,14 +2,7 @@
{ {
services.factorio = { services.factorio = {
enable = true; enable = true;
package = pkgs.unstable.factorio-headless.overrideAttrs (_: rec { package = pkgs.factorio-headless; # I override this in ./pkgs
version = "2.0.12";
src = pkgs.fetchurl {
name = "factorio_headless_x64-${version}.tar.xz";
url = "https://www.factorio.com/get-download/${version}/headless/linux64";
hash = "sha256-0vgg5eJ6ZEFO0TUixNsByCs8YyPGOArgqnXbT5RIjTE=";
};
});
public = true; public = true;
lan = true; lan = true;
openFirewall = true; openFirewall = true;

View file

@ -8,4 +8,7 @@ rec {
emmet-cli = pkgs.callPackage ./emmet-cli.nix { }; emmet-cli = pkgs.callPackage ./emmet-cli.nix { };
material-wifi-icons = pkgs.callPackage ./material-wifi-icons.nix { }; material-wifi-icons = pkgs.callPackage ./material-wifi-icons.nix { };
gnome-pass-search-provider = pkgs.callPackage ./gnome-pass-search-provider.nix { }; gnome-pass-search-provider = pkgs.callPackage ./gnome-pass-search-provider.nix { };
factorio-headless = pkgs.callPackage ./factorio-headless {
inherit (pkgs.unstable) factorio-headless;
};
} }

View file

@ -0,0 +1,10 @@
{ factorio-headless, pkgs }:
factorio-headless.overrideAttrs (_: rec {
version = "2.0.13";
src = pkgs.fetchurl {
name = "factorio_headless_x64-${version}.tar.xz";
url = "https://www.factorio.com/get-download/${version}/headless/linux64";
hash = "sha256-J7NpAaOeWTrfKEGMAoYULGx6n4PRVpY8c2m9QFolx9E=";
};
})

View file

@ -0,0 +1,14 @@
#!/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 "$current_version" "$new_version" ./default.nix
sd "$current_hash" "$new_hash" ./default.nix