factorio: automate updating server
This commit is contained in:
parent
a989bacbd7
commit
a7608ace94
|
@ -2,14 +2,7 @@
|
|||
{
|
||||
services.factorio = {
|
||||
enable = true;
|
||||
package = pkgs.unstable.factorio-headless.overrideAttrs (_: rec {
|
||||
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=";
|
||||
};
|
||||
});
|
||||
package = pkgs.factorio-headless; # I override this in ./pkgs
|
||||
public = true;
|
||||
lan = true;
|
||||
openFirewall = true;
|
||||
|
|
|
@ -8,4 +8,7 @@ rec {
|
|||
emmet-cli = pkgs.callPackage ./emmet-cli.nix { };
|
||||
material-wifi-icons = pkgs.callPackage ./material-wifi-icons.nix { };
|
||||
gnome-pass-search-provider = pkgs.callPackage ./gnome-pass-search-provider.nix { };
|
||||
factorio-headless = pkgs.callPackage ./factorio-headless {
|
||||
inherit (pkgs.unstable) factorio-headless;
|
||||
};
|
||||
}
|
||||
|
|
10
pkgs/factorio-headless/default.nix
Normal file
10
pkgs/factorio-headless/default.nix
Normal 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=";
|
||||
};
|
||||
})
|
14
pkgs/factorio-headless/update.sh
Executable file
14
pkgs/factorio-headless/update.sh
Executable 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
|
Loading…
Reference in a new issue