From e145afa53fc7a27f5107016eea33eed68b970b67 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 9 Sep 2026 11:46:08 +0200 Subject: [PATCH] feat(blarm): modularize Zabbix and Samba services --- modules/nixos/services/samba/default.nix | 62 +++++++++++++++++++++++ modules/nixos/services/zabbix/default.nix | 60 ++++++++++++++++++++++ systems/x86_64-linux/blarm/default.nix | 27 +--------- 3 files changed, 124 insertions(+), 25 deletions(-) create mode 100644 modules/nixos/services/samba/default.nix create mode 100644 modules/nixos/services/zabbix/default.nix diff --git a/modules/nixos/services/samba/default.nix b/modules/nixos/services/samba/default.nix new file mode 100644 index 0000000..9a5c61d --- /dev/null +++ b/modules/nixos/services/samba/default.nix @@ -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"; + }; + }; + }; + }; +} diff --git a/modules/nixos/services/zabbix/default.nix b/modules/nixos/services/zabbix/default.nix new file mode 100644 index 0000000..50a9d82 --- /dev/null +++ b/modules/nixos/services/zabbix/default.nix @@ -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"; + }; + }; + }; +} diff --git a/systems/x86_64-linux/blarm/default.nix b/systems/x86_64-linux/blarm/default.nix index 8b6141f..87bdcb2 100644 --- a/systems/x86_64-linux/blarm/default.nix +++ b/systems/x86_64-linux/blarm/default.nix @@ -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