feat(blarm): modularize Zabbix and Samba services
Some checks failed
CI / build (push) Has been cancelled

This commit is contained in:
Philipp 2026-09-09 11:46:08 +02:00
commit e145afa53f
Signed by: Philipp
GPG key ID: B27C3DE2FD94AFC3
3 changed files with 124 additions and 25 deletions

View file

@ -0,0 +1,62 @@
{
config,
lib,
namespace,
...
}:
with lib;
with lib.${namespace};
let
cfg = config.${namespace}.services.samba;
in
{
options.${namespace}.services.samba = {
enable = mkEnableOption "Samba network share for OpenCloud user storage";
shareName = mkOption {
description = "Name of the Samba share.";
type = types.str;
default = "opencloud";
};
path = mkOption {
description = "OpenCloud user storage path exposed through Samba.";
type = types.path;
default = "/data/opencloud/data/storage/users/users/5f2947ff-0cc3-44e5-886a-7ed07d70690b";
};
user = mkOption {
description = "Authenticated Samba user allowed to access the share.";
type = types.str;
default = "philipp";
};
};
config = mkIf cfg.enable {
services.samba = {
enable = true;
openFirewall = true;
settings = {
global = {
workgroup = "WORKGROUP";
"server string" = "blarm";
security = "user";
"map to guest" = "Bad User";
"hosts allow" = "192.168.1.0/24";
"hosts deny" = "0.0.0.0/0";
};
"${cfg.shareName}" = {
path = cfg.path;
browseable = "yes";
"read only" = "no";
"guest ok" = "no";
"valid users" = cfg.user;
"force user" = "opencloud";
"force group" = "opencloud";
"create mask" = "0660";
"directory mask" = "0770";
};
};
};
};
}

View file

@ -0,0 +1,60 @@
{
config,
lib,
namespace,
...
}:
with lib;
with lib.${namespace};
let
cfg = config.${namespace}.services.zabbix;
in
{
options.${namespace}.services.zabbix = {
enable = mkEnableOption "Zabbix monitoring server and agent";
domain = mkOption {
description = "Public Zabbix web interface domain.";
type = types.str;
default = "zabbix.stahl.sh";
};
hostname = mkOption {
description = "Zabbix host name used by the local agent.";
type = types.str;
default = "blarm";
};
};
config = mkIf cfg.enable {
${namespace}.services.acme.enable = true;
services.zabbixServer = {
enable = true;
database = {
type = "pgsql";
createLocally = true;
};
};
services.zabbixWeb = {
enable = true;
frontend = "nginx";
hostname = cfg.domain;
database.type = "pgsql";
nginx.virtualHost = {
forceSSL = true;
useACMEHost = "stahl.sh";
};
};
services.zabbixAgent = {
enable = true;
server = "127.0.0.1";
settings = {
Hostname = cfg.hostname;
ServerActive = "127.0.0.1";
};
};
};
}

View file

@ -59,6 +59,8 @@ with lib.${namespace};
forgejo = enabled;
kanidm = enabled;
opencloud = enabled;
samba = enabled;
zabbix = enabled;
searxng = enabled;
#immich = enabled; # We wait for the proper version to be in nixpkgs
paperless = enabled;
@ -73,31 +75,6 @@ with lib.${namespace};
cli.neovim = enabled;
};
services.samba = {
enable = true;
openFirewall = true;
settings = {
global = {
workgroup = "WORKGROUP";
"server string" = "blarm";
security = "user";
"map to guest" = "Bad User";
"hosts allow" = "192.168.1.0/24";
"hosts deny" = "0.0.0.0/0";
};
opencloud = {
path = "/data/opencloud/data/storage/users/users/5f2947ff-0cc3-44e5-886a-7ed07d70690b";
browseable = "yes";
"read only" = "no";
"guest ok" = "no";
"valid users" = "philipp";
"force user" = "opencloud";
"force group" = "opencloud";
"create mask" = "0660";
"directory mask" = "0770";
};
};
};
environment.systemPackages = with pkgs; [
git