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
|
||||
|
||||
result/
|
||||
tmp/
|
||||
result
|
||||
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
|
||||
{ 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;
|
||||
|
||||
Reference in New Issue
Block a user