From 2668dcc5a855b66303a4843352625219bb3516b3 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Mon, 19 Oct 2026 15:38:59 -0500 Subject: [PATCH] fix(nixos): add operator to homelab-operators and configure daemon systemd sandbox Closes #4 --- nixos/configuration.nix | 7 ++++--- nixos/modules/homeserver.nix | 8 ++++++-- scripts/appctl_daemon.py | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index afb0cdb..a2ac096 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -63,9 +63,10 @@ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICAVPPMk+WApUd/fo78+lsRGnLKSlY4GDZiNGKwBAifD" ]; extraGroups = [ - "wheel" # sudo access - "docker" # run docker without sudo - "networkmanager" # modify network settings + "wheel" # sudo access + "docker" # run docker without sudo + "homelab-operators" # access /run/homelab/appctl.sock + "networkmanager" # modify network settings ]; }; diff --git a/nixos/modules/homeserver.nix b/nixos/modules/homeserver.nix index b7983b9..f74ace7 100644 --- a/nixos/modules/homeserver.nix +++ b/nixos/modules/homeserver.nix @@ -109,7 +109,7 @@ serviceConfig = { Type = "simple"; User = config.homelab.operatorUser; - SupplementaryGroups = [ "docker" ]; + SupplementaryGroups = [ "docker" "homelab-operators" ]; WorkingDirectory = config.homelab.coreDir; ExecStart = "${pkgs.webhook}/bin/webhook -hooks ${pkgs.writeText "hooks.json" (builtins.toJSON [ { @@ -137,12 +137,13 @@ ReadWritePaths = [ config.homelab.sitesDir "/home/${config.homelab.operatorUser}/.local/state/homelab" + "/run/homelab" ]; }; }; # Declarative Users and Groups for Control Plane Service Identity - users.groups.homelab-operators = {}; + users.groups.homelab-operators.members = [ config.homelab.operatorUser ]; users.users.homelab-appctl = { isSystemUser = true; group = "homelab-operators"; @@ -168,6 +169,9 @@ ]; environment = { + HOME = "/var/lib/homelab/appctl"; + DOCKER_CONFIG = "/var/lib/homelab/appctl/.docker"; + HOMELAB_DOMAIN = config.homelab.domain; APPCTL_SOCKET_PATH = "/run/homelab/appctl.sock"; APPCTL_HTTP_HOST = "127.0.0.1"; APPCTL_HTTP_PORT = "9001"; diff --git a/scripts/appctl_daemon.py b/scripts/appctl_daemon.py index 7599fe2..b720b41 100755 --- a/scripts/appctl_daemon.py +++ b/scripts/appctl_daemon.py @@ -484,7 +484,7 @@ class AppctlDaemon: try: os.chmod(self.socket_path, 0o660) except OSError as e: - logger.warning("Could not set mode 0660 on socket %s: %e", self.socket_path, e) + logger.warning("Could not set mode 0660 on socket %s: %s", self.socket_path, e) # 2. Prepare and bind TCP listener self.tcp_server = ThreadingHTTPServer((self.http_host, self.http_port), AppctlHTTPHandler)