add nginx
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -44,5 +44,6 @@
|
|||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,git
|
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,git
|
||||||
|
|
||||||
result/
|
result
|
||||||
tmp/
|
tmp
|
||||||
|
*.qcow2
|
||||||
32
examples/unciv-nixos.nix
Normal file
32
examples/unciv-nixos.nix
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# nix-build '<nixpkgs/nixos>' -A vm -I nixos-config="examples/unciv-nixos.nix" && result/bin/run-nixos-vm -nographic
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
uc = pkgs.callPackage ../unciv.nix {
|
||||||
|
port = "7443";
|
||||||
|
nginxEnableACME = false;
|
||||||
|
nginxForceSSL = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
||||||
|
|
||||||
|
services.nginx = {
|
||||||
|
enable = true;
|
||||||
|
appendHttpConfig = ''
|
||||||
|
server_names_hash_bucket_size 64;
|
||||||
|
'';
|
||||||
|
sslProtocols = "TLSv1 TLSv1.1 TLSv1.2";
|
||||||
|
recommendedGzipSettings = true;
|
||||||
|
recommendedOptimisation = true;
|
||||||
|
recommendedProxySettings = true;
|
||||||
|
recommendedTlsSettings = false;
|
||||||
|
virtualHosts."unciv.*" = uc.nginx.virtualHosts.unciv;
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.unciv = uc.systemd.services.unciv;
|
||||||
|
|
||||||
|
users.users.root.initialPassword = "root";
|
||||||
|
}
|
||||||
19
unciv.nix
19
unciv.nix
@@ -1,11 +1,11 @@
|
|||||||
# nix-build unciv.rix
|
# 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
|
let
|
||||||
|
|
||||||
jarFile = pkgs.fetchurl {
|
jarFile = pkgs.fetchurl {
|
||||||
url = "https://github.com/yairm210/Unciv/releases/4.2.6/download/UncivServer.jar";
|
url = "https://github.com/yairm210/Unciv/releases/download/4.2.6/UncivServer.jar";
|
||||||
sha256 = "sha256-gGZCMG8+mqXK/2JgEN7ONBJ8QR7lAfl843EGB2j+N/E=";
|
sha256 = "sha256-7YJQnNPng87n1EN+533EBsGgVa3w+B8PuLO0xECcDug=";
|
||||||
};
|
};
|
||||||
|
|
||||||
uncivServerCmd = pkgs.writeShellScriptBin "UncivServer.sh" ''
|
uncivServerCmd = pkgs.writeShellScriptBin "UncivServer.sh" ''
|
||||||
@@ -18,13 +18,24 @@ in
|
|||||||
packages = uncivServerCmd;
|
packages = uncivServerCmd;
|
||||||
|
|
||||||
systemd.services.unciv = {
|
systemd.services.unciv = {
|
||||||
serviceConfig.Type = "oneshot";
|
description = "unciv server";
|
||||||
|
after = [ "network.target" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
serviceConfig.Restart = "always";
|
||||||
script = ''
|
script = ''
|
||||||
mkdir -p "${stateDir}"
|
mkdir -p "${stateDir}"
|
||||||
${uncivServerCmd}/bin/UncivServer.sh -f "${stateDir}" -p "${port}"
|
${uncivServerCmd}/bin/UncivServer.sh -f "${stateDir}" -p "${port}"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nginx.virtualHosts.unciv = {
|
||||||
|
enableACME = nginxEnableACME;
|
||||||
|
forceSSL = nginxForceSSL;
|
||||||
|
default = nginxIsDefault;
|
||||||
|
locations."/".proxyPass = "http://localhost:${port}";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "The multiplayer server for Unciv - An open-source, mod-friendly Android+Desktop remake of Civ V.";
|
description = "The multiplayer server for Unciv - An open-source, mod-friendly Android+Desktop remake of Civ V.";
|
||||||
homepage = https://yairm210.itch.io/unciv;
|
homepage = https://yairm210.itch.io/unciv;
|
||||||
|
|||||||
Reference in New Issue
Block a user