add nginx

This commit is contained in:
stubbfelnewpc
2022-08-30 21:04:56 +00:00
parent f9652b6d3b
commit d211d67165
3 changed files with 50 additions and 6 deletions

View File

@@ -1,11 +1,11 @@
# nix-build unciv.rix
{ pkgs ? import <nixpkgs> { }, stateDir ? "/var/lib/unciv", port ? "80", }:
{ 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/4.2.6/download/UncivServer.jar";
sha256 = "sha256-gGZCMG8+mqXK/2JgEN7ONBJ8QR7lAfl843EGB2j+N/E=";
url = "https://github.com/yairm210/Unciv/releases/download/4.2.6/UncivServer.jar";
sha256 = "sha256-7YJQnNPng87n1EN+533EBsGgVa3w+B8PuLO0xECcDug=";
};
uncivServerCmd = pkgs.writeShellScriptBin "UncivServer.sh" ''
@@ -18,13 +18,24 @@ in
packages = uncivServerCmd;
systemd.services.unciv = {
serviceConfig.Type = "oneshot";
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;