mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 14:01:34 +01:00
Refactor web services to use a unified web-services namespace
This commit is contained in:
parent
308ee43ec4
commit
02846ab16f
22 changed files with 103 additions and 99 deletions
|
|
@ -1,11 +1,11 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.custom.services.actualbudget;
|
||||
cfg = config.custom.web-services.actualbudget;
|
||||
|
||||
inherit (config.services.actual.settings) dataDir;
|
||||
in
|
||||
{
|
||||
options.custom.services.actualbudget = {
|
||||
options.custom.web-services.actualbudget = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.custom.services.alloy;
|
||||
cfg = config.custom.web-services.alloy;
|
||||
in
|
||||
{
|
||||
options.custom.services.alloy = {
|
||||
options.custom.web-services.alloy = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
@ -121,7 +121,7 @@ in
|
|||
text = ''
|
||||
prometheus.scrape "victorialogs" {
|
||||
targets = [{
|
||||
__address__ = "localhost:${toString config.custom.services.victorialogs.port}",
|
||||
__address__ = "localhost:${toString config.custom.web-services.victorialogs.port}",
|
||||
job = "victorialogs",
|
||||
instance = constants.hostname,
|
||||
}]
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.filebrowser;
|
||||
cfg = config.custom.web-services.filebrowser;
|
||||
|
||||
dataDir = "/var/lib/filebrowser";
|
||||
in
|
||||
{
|
||||
options.custom.services.filebrowser = {
|
||||
options.custom.web-services.filebrowser = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.custom.services.forgejo;
|
||||
cfg = config.custom.web-services.forgejo;
|
||||
in
|
||||
{
|
||||
options.custom.services.forgejo = {
|
||||
options.custom.web-services.forgejo = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.custom.services.forgejo.ssh;
|
||||
cfg = config.custom.web-services.forgejo.ssh;
|
||||
in
|
||||
{
|
||||
options.custom.services.forgejo.ssh = {
|
||||
options.custom.web-services.forgejo.ssh = {
|
||||
enable = lib.mkEnableOption "";
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.freshrss;
|
||||
cfg = config.custom.web-services.freshrss;
|
||||
|
||||
inherit (config.services.freshrss) dataDir;
|
||||
in
|
||||
{
|
||||
options.custom.services.freshrss = {
|
||||
options.custom.web-services.freshrss = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.gatus;
|
||||
cfg = config.custom.web-services.gatus;
|
||||
dataDir = "/var/lib/gatus";
|
||||
in
|
||||
{
|
||||
options.custom.services.gatus = {
|
||||
options.custom.web-services.gatus = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
@ -169,40 +169,38 @@ in
|
|||
systemd.services.gatus.environment.GATUS_DELAY_START_SECONDS = "5";
|
||||
|
||||
custom = {
|
||||
services = {
|
||||
gatus.endpoints =
|
||||
let
|
||||
defaultEndpoints =
|
||||
self.nixosConfigurations
|
||||
|> lib.mapAttrs (_: value: value.config.meta.domains.local)
|
||||
|> lib.concatMapAttrs (
|
||||
hostName: domains:
|
||||
domains
|
||||
|> lib.filter (domain: domain != cfg.domain)
|
||||
|> lib.map (
|
||||
domain:
|
||||
lib.nameValuePair (lib'.subdomainOf domain) {
|
||||
inherit domain;
|
||||
group = hostName;
|
||||
}
|
||||
)
|
||||
|> lib.listToAttrs
|
||||
);
|
||||
in
|
||||
lib.mkIf cfg.generateDefaultEndpoints (
|
||||
defaultEndpoints
|
||||
// {
|
||||
"healthchecks.io" = {
|
||||
group = "external";
|
||||
domain = "hc-ping.com";
|
||||
path = "/\${HEALTHCHECKS_PING_KEY}/${config.networking.hostName}-gatus-uptime?create=1";
|
||||
interval = "2h";
|
||||
};
|
||||
}
|
||||
);
|
||||
web-services.gatus.endpoints =
|
||||
let
|
||||
defaultEndpoints =
|
||||
self.nixosConfigurations
|
||||
|> lib.mapAttrs (_: value: value.config.meta.domains.local)
|
||||
|> lib.concatMapAttrs (
|
||||
hostName: domains:
|
||||
domains
|
||||
|> lib.filter (domain: domain != cfg.domain)
|
||||
|> lib.map (
|
||||
domain:
|
||||
lib.nameValuePair (lib'.subdomainOf domain) {
|
||||
inherit domain;
|
||||
group = hostName;
|
||||
}
|
||||
)
|
||||
|> lib.listToAttrs
|
||||
);
|
||||
in
|
||||
lib.mkIf cfg.generateDefaultEndpoints (
|
||||
defaultEndpoints
|
||||
// {
|
||||
"healthchecks.io" = {
|
||||
group = "external";
|
||||
domain = "hc-ping.com";
|
||||
path = "/\${HEALTHCHECKS_PING_KEY}/${config.networking.hostName}-gatus-uptime?create=1";
|
||||
interval = "2h";
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
caddy.virtualHosts.${cfg.domain}.port = cfg.port;
|
||||
};
|
||||
services.caddy.virtualHosts.${cfg.domain}.port = cfg.port;
|
||||
|
||||
persistence.directories = [ dataDir ];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.grafana;
|
||||
cfg = config.custom.web-services.grafana;
|
||||
in
|
||||
{
|
||||
options.custom.services.grafana = {
|
||||
options.custom.web-services.grafana = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.it-tools;
|
||||
cfg = config.custom.web-services.it-tools;
|
||||
in
|
||||
{
|
||||
options.custom.services.it-tools = {
|
||||
options.custom.web-services.it-tools = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.memos;
|
||||
cfg = config.custom.web-services.memos;
|
||||
|
||||
dataDir = config.services.memos.settings.MEMOS_DATA;
|
||||
in
|
||||
{
|
||||
options.custom.services.memos = {
|
||||
options.custom.web-services.memos = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.custom.services.ntfy;
|
||||
cfg = config.custom.web-services.ntfy;
|
||||
in
|
||||
{
|
||||
options.custom.services.ntfy = {
|
||||
options.custom.web-services.ntfy = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.outline;
|
||||
cfg = config.custom.web-services.outline;
|
||||
in
|
||||
{
|
||||
options.custom.services.outline = {
|
||||
options.custom.web-services.outline = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.personal-blog;
|
||||
cfg = config.custom.web-services.personal-blog;
|
||||
|
||||
dataDir = "/var/lib/personal-blog";
|
||||
in
|
||||
{
|
||||
options.custom.services.personal-blog = {
|
||||
options.custom.web-services.personal-blog = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.custom.services.privatebin;
|
||||
cfg = config.custom.web-services.privatebin;
|
||||
in
|
||||
{
|
||||
options.custom.services.privatebin = {
|
||||
options.custom.web-services.privatebin = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.radicale;
|
||||
cfg = config.custom.web-services.radicale;
|
||||
|
||||
dataDir = config.services.radicale.settings.storage.filesystem_folder;
|
||||
in
|
||||
{
|
||||
options.custom.services.radicale = {
|
||||
options.custom.web-services.radicale = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.custom.services.stirling-pdf;
|
||||
cfg = config.custom.web-services.stirling-pdf;
|
||||
in
|
||||
{
|
||||
options.custom.services.stirling-pdf = {
|
||||
options.custom.web-services.stirling-pdf = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.custom.services.uptime-kuma;
|
||||
cfg = config.custom.web-services.uptime-kuma;
|
||||
in
|
||||
{
|
||||
options.custom.services.uptime-kuma = {
|
||||
options.custom.web-services.uptime-kuma = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.victorialogs;
|
||||
cfg = config.custom.web-services.victorialogs;
|
||||
in
|
||||
{
|
||||
options.custom.services.victorialogs = {
|
||||
options.custom.web-services.victorialogs = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.victoriametrics;
|
||||
cfg = config.custom.web-services.victoriametrics;
|
||||
in
|
||||
{
|
||||
options.custom.services.victoriametrics = {
|
||||
options.custom.web-services.victoriametrics = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue