Files
unciv/unciv.nix
stubbfelnewpc d211d67165 add nginx
2022-08-30 21:04:56 +00:00

47 lines
1.3 KiB
Nix

# nix-build unciv.rix
{ pkgs ? import <nixpkgs> { }, stateDir ? "/var/lib/unciv", port ? "80", nginxEnableACME ? true, nginxForceSSL ? true, nginxIsDefault ? true }:
let
jarFile = pkgs.fetchurl {
url = "https://github.com/yairm210/Unciv/releases/download/4.2.6/UncivServer.jar";
sha256 = "sha256-7YJQnNPng87n1EN+533EBsGgVa3w+B8PuLO0xECcDug=";
};
uncivServerCmd = pkgs.writeShellScriptBin "UncivServer.sh" ''
${pkgs.jre}/bin/java -jar ${jarFile} "$@"
'';
in
{
packages = uncivServerCmd;
systemd.services.unciv = {
description = "unciv server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig.Restart = "always";
script = ''
mkdir -p "${stateDir}"
${uncivServerCmd}/bin/UncivServer.sh -f "${stateDir}" -p "${port}"
'';
};
nginx.virtualHosts.unciv = {
enableACME = nginxEnableACME;
forceSSL = nginxForceSSL;
default = nginxIsDefault;
locations."/".proxyPass = "http://localhost:${port}";
};
meta = {
description = "The multiplayer server for Unciv - An open-source, mod-friendly Android+Desktop remake of Civ V.";
homepage = https://yairm210.itch.io/unciv;
maintainers = "stubbfel";
license = pkgs.lib.licenses.mpl2;
platforms = pkgs.lib.platforms.unix;
};
}