nixos/panel.nix
Jakub Dorfman eeab4c1818 fix: remove unnecessary sudo rules and adjust permissions for container directories
Co-authored-by: Copilot <copilot@github.com>
2026-04-28 23:09:25 +02:00

77 lines
No EOL
2.2 KiB
Nix

{ config, pkgs, ... }:
{
environment.systemPackages = [
(pkgs.writeShellScriptBin "panelctl" (builtins.readFile ./panel/panelctl.sh))
];
users.groups.panelroutes = { };
users.users.reudy.extraGroups = [ "panelroutes" ];
users.users.caddy.extraGroups = [ "panelroutes" ];
systemd.tmpfiles.rules = [
"d /var/lib/containers 0750 reudy panelroutes -"
"d /var/lib/containers/stacks 0750 reudy panelroutes -"
"d /var/lib/containers/volumes 0750 reudy panelroutes -"
"d /var/lib/containers/routes 0750 reudy panelroutes -"
"d /var/lib/containers/state 0750 reudy panelroutes -"
"d /var/lib/containers/state/apps 0750 reudy panelroutes -"
"d /var/lib/containers/backups 0750 reudy panelroutes -"
"f /var/lib/containers/routes/routes.caddy 0640 reudy panelroutes -"
];
systemd.services.panel-api = {
description = "Minimal panel API service";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
path = [
pkgs.podman
pkgs.podman-compose
pkgs.curl
pkgs.coreutils
pkgs.zip
pkgs.unzip
];
serviceConfig = {
Type = "simple";
User = "reudy";
Group = "panelroutes";
Restart = "always";
RestartSec = 3;
WorkingDirectory = "/var/lib/containers";
ExecStart = "${pkgs.python3}/bin/python3 ${./panel/panel-api.py}";
};
environment = {
PANEL_API_BIND = "127.0.0.1";
PANEL_API_PORT = "9911";
PANEL_BASE_DIR = "/var/lib/containers";
PANELCTL_PATH = "/run/current-system/sw/bin/panelctl";
PANEL_FRONTEND_DIR = "${./panel/frontend}";
};
};
services.caddy.virtualHosts."panel.srazka.com".extraConfig = ''
forward_auth 127.0.0.1:9091 {
uri /api/authz/forward-auth
copy_headers Remote-User Remote-Groups Remote-Email Remote-Name
}
reverse_proxy 127.0.0.1:9911
'';
systemd.paths."caddy-routes-reload" = {
wantedBy = [ "multi-user.target" ];
pathConfig = {
PathChanged = "/var/lib/containers/routes/routes.caddy";
};
};
systemd.services."caddy-routes-reload" = {
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.systemd}/bin/systemctl reload caddy.service";
};
};
}