Files
hearth/nixos/system/neuro/minecraft/horizon.nix
T
yukkop 845e68316d
runner nix smoke / nix label and flake smoke (push) Failing after 1m37s
feat: add horizon
2026-11-02 22:16:56 +00:00

84 lines
2.2 KiB
Nix

{ pkgs, ... }:
let
horizon = pkgs.hectic.horizon;
eulaFile = pkgs.writeText "horizon-eula.txt" ''
eula=true
'';
serverConfig = pkgs.writeText "horizon-server.toml" ''
[server]
port = 25569
online_mode = true
whitelist = true
[world]
name = "world"
[engine]
path = "${horizon}/libexec/horizon/horizon-engine"
resources = "/var/lib/horizon/resources"
restart_on_crash = true
[backups]
every = "6h"
keep = 12
[panel]
bind = ""
allow_public = false
[api]
bind = "127.0.0.1:8131"
token = ""
allow_public = false
'';
in {
users.groups.horizon = {};
users.users.horizon = {
isSystemUser = true;
group = "horizon";
home = "/var/lib/horizon";
};
environment.systemPackages = [ horizon ];
networking.firewall.allowedTCPPorts = [ 25569 ];
systemd.services.horizon = {
description = "Horizon Minecraft server";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
unitConfig.ConditionPathExists = "/var/lib/horizon/resources/registries.json";
environment.HORIZON_NO_UPDATE_CHECK = "1";
restartTriggers = [ serverConfig eulaFile ];
preStart = ''
install -m 0640 ${serverConfig} /var/lib/horizon/server.toml
install -m 0640 ${eulaFile} /var/lib/horizon/eula.txt
'';
serviceConfig = {
User = "horizon";
Group = "horizon";
WorkingDirectory = "/var/lib/horizon";
ExecStart = "${horizon}/bin/horizon-server --dir /var/lib/horizon run";
Restart = "on-failure";
RestartSec = 10;
KillSignal = "SIGTERM";
TimeoutStopSec = 180;
StateDirectory = "horizon";
StateDirectoryMode = "0750";
UMask = "0027";
NoNewPrivileges = true;
PrivateDevices = true;
PrivateTmp = true;
ProtectHome = true;
ProtectSystem = "strict";
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectControlGroups = true;
RestrictSUIDSGID = true;
CapabilityBoundingSet = [ "" ];
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
};
};
}