feat: add panel configuration with API service and Caddy integration
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
441b049e2b
commit
fe4d3f4432
4 changed files with 81 additions and 70 deletions
78
panel.nix
Normal file
78
panel.nix
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
{ 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 0755 reudy panelroutes -"
|
||||
"d /var/lib/containers/stacks 0750 reudy panelroutes -"
|
||||
"d /var/lib/containers/volumes 0750 reudy panelroutes -"
|
||||
"d /var/lib/containers/routes 0755 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 0664 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.sudo
|
||||
pkgs.coreutils
|
||||
pkgs.zip
|
||||
pkgs.unzip
|
||||
];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = "reudy";
|
||||
Group = "panelroutes";
|
||||
Restart = "always";
|
||||
RestartSec = 3;
|
||||
WorkingDirectory = "/home/reudy";
|
||||
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";
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue