Add agenix, spigot-server and ionos-dyndns to gilgamesh config
Check / Lint Ansible Files (push) Successful in 3m1s

This commit is contained in:
2023-11-19 03:09:42 +01:00
parent e61a07f8d3
commit f2f12a2688
2 changed files with 43 additions and 12 deletions
+36 -4
View File
@@ -1,9 +1,16 @@
{ config, pkgs, lib, ... }:
{
let
agenix = builtins.fetchTarball {
url = "https://github.com/ryantm/agenix/archive/daf42cb35b2dc614d1551e37f96406e4c4a2d3e4.tar.gz";
sha256 = "0gbn01hi8dh7s9rc66yawnmixcasadf20zci4ijzpd143ph492ad";
};
in {
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
./spigot.nix
"${agenix}/modules/age.nix"
../modules/spigot-server.nix
../modules/ionos-dyndns.nix
];
# Use the GRUB 2 boot loader.
@@ -77,13 +84,38 @@
nssmdns = true;
};
services.spigot = {
services.spigot-server = {
enable = true;
user = "spigot";
};
# Secrets management
age.secrets = {
ionos-prefix = {
file = ../secrets/ionos-prefix.age;
owner = "ionos-dyndns";
group = "ionos-dyndns";
};
ionos-secret = {
file = ../secrets/ionos-secret.age;
owner = "ionos-dyndns";
group = "ionos-dyndns";
};
};
# DynDNS stuff. IONOS has a (proprietary?) API for this,
# so we're using a Python script from the interwebs :shrug:
# TODO: Config using agenix
services.ionos-dyndns = {
enable = true;
# Must match the user owning the secrets below. See agenix config
# above for more details.
user = "ionos-dyndns";
apiPrefixPath = config.age.secrets.ionos-prefix.path;
apiSecretPath = config.age.secrets.ionos-secret.path;
aaaa = true;
fqdn = "blocks.beany.club";
interface = "enp0s25";
};
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [ 25565 ];
-83
View File
@@ -1,83 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
ionos-dyndns = pkgs.callPackage ../packages/ionos-dyndns.nix {};
spigot-server = pkgs.callPackage ../packages/spigot-server.nix {};
cfg = config.services.spigot;
name = "spigot";
StateDirectory = "spigot-server";
in {
options = {
services.spigot = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to turn on the Spigot Minecraft server.
'';
};
user = mkOption {
type = types.str;
default = name;
description = ''
The user account and group that Spigot runs as.
'';
};
};
};
config = mkIf cfg.enable {
users.users = {
${name} = {
isSystemUser = true;
group = name;
description = "Spigot Minecraft server user";
};
};
users.groups = {
${name} = {
};
};
systemd = {
services.spigot-server = {
description = "Spigot Minecraft server";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
User = "${cfg.user}";
Sockets = "spigot-server.socket";
StandardInput = "socket";
StandardOutput = "journal";
StandardError = "journal";
inherit StateDirectory;
WorkingDirectory = "/var/lib/${StateDirectory}";
ExecStart = "${spigot-server}/bin/spigot-server -nogui";
ExecStop = [
"${pkgs.bash}/bin/bash -c '${pkgs.coreutils}/bin/echo save-all > /run/spigot-server.stdin'"
"${pkgs.bash}/bin/bash -c '${pkgs.coreutils}/bin/echo stop > /run/spigot-server.stdin'"
# Wait for the main process to exit
# If we don't do this systemd tries to nudge Java to stop, causing a race condition
# that leads to an ungraceful shutdown
"${pkgs.coreutils}/bin/echo \"Waiting for \${MAINPID} to exit...\""
"${pkgs.bash}/bin/bash -c 'while ${pkgs.coreutils}/bin/kill -s 0 $MAINPID 2>/dev/null; do sleep 0.5; done'"
];
};
};
sockets.spigot-server = {
description = "Spigot Minecraft server socket for commands and stuff";
unitConfig = {
# Automatically start and stop socket along with the service
PartOf = "spigot-server.service";
};
socketConfig = {
ListenFIFO = "/run/spigot-server.stdin";
};
};
};
};
}