1
0
Fork 0

Services: parse domain from service URL (there's probably a better way to do this)

This commit is contained in:
Aires 2024-09-08 22:34:29 -04:00
parent 51a11039d7
commit 10c0e42954
8 changed files with 57 additions and 59 deletions

View file

@ -137,7 +137,6 @@ in
deluge = {
enable = true;
home = "${services-root}/deluge";
domain = config.secrets.networking.domains.primary;
url = config.secrets.services.deluge.url;
};
duplicacy-web = {
@ -147,7 +146,6 @@ in
forgejo = {
enable = true;
home = "${services-root}/forgejo";
domain = config.secrets.networking.domains.primary;
url = config.secrets.services.forgejo.url;
actions = {
enable = true;
@ -157,13 +155,11 @@ in
jellyfin = {
enable = true;
home = "${services-root}/jellyfin";
domain = config.secrets.networking.domains.primary;
url = config.secrets.services.jellyfin.url;
};
msmtp.enable = true;
netdata = {
enable = true;
domain = config.secrets.networking.domains.primary;
type = "parent";
url = config.secrets.services.netdata.url;
auth = {

View file

@ -124,7 +124,6 @@ in
deluge = {
enable = true;
home = "${services-root}/deluge";
domain = config.secrets.networking.domains.primary;
url = config.secrets.services.deluge.url;
};
duplicacy-web = {
@ -134,7 +133,6 @@ in
forgejo = {
enable = true;
home = "${services-root}/forgejo";
domain = config.secrets.networking.domains.primary;
url = config.secrets.services.forgejo.url;
actions = {
enable = true;
@ -144,19 +142,16 @@ in
home-assistant = {
enable = false;
home = "${services-root}/home-assistant";
domain = config.secrets.networking.domains.primary;
url = config.secrets.services.home-assistant.url;
};
jellyfin = {
enable = true;
home = "${services-root}/jellyfin";
domain = config.secrets.networking.domains.primary;
url = config.secrets.services.jellyfin.url;
};
msmtp.enable = true;
netdata = {
enable = true;
domain = config.secrets.networking.domains.primary;
type = "parent";
url = config.secrets.services.netdata.url;
auth = {

View file

@ -16,12 +16,6 @@ in
type = lib.types.str;
description = "Where to store Airsonic's files";
};
domain = lib.mkOption {
default = "";
type = lib.types.str;
description = "The root domain that Airsonic will be hosted on.";
example = "example.com";
};
url = lib.mkOption {
default = "";
type = lib.types.str;
@ -37,7 +31,14 @@ in
services = {
nginx.virtualHosts."${cfg.url}" = {
useACMEHost = cfg.domain;
useACMEHost =
let
parsedURL = (lib.strings.splitString "." cfg.url);
in
builtins.concatStringsSep "." [
(builtins.elemAt parsedURL 1)
(builtins.elemAt parsedURL 2)
];
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:4040";

View file

@ -1,4 +1,3 @@
# This is an example of a blank module.
{ config, lib, ... }:
let
@ -13,12 +12,6 @@ in
type = lib.types.str;
description = "Where to store Deluge's files";
};
domain = lib.mkOption {
default = "";
type = lib.types.str;
description = "The root domain that Deluge will be hosted on.";
example = "example.com";
};
url = lib.mkOption {
default = "";
type = lib.types.str;
@ -32,7 +25,14 @@ in
config = lib.mkIf cfg.enable {
services = {
nginx.virtualHosts."${cfg.url}" = {
useACMEHost = cfg.domain;
useACMEHost =
let
parsedURL = (lib.strings.splitString "." cfg.url);
in
builtins.concatStringsSep "." [
(builtins.elemAt parsedURL 1)
(builtins.elemAt parsedURL 2)
];
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:8112";

View file

@ -25,12 +25,6 @@ in
options = {
aux.system.services.forgejo = {
enable = lib.mkEnableOption "Enables Forgejo Git hosting service.";
domain = lib.mkOption {
default = "/var/lib/forgejo";
type = lib.types.str;
description = "The root domain that Forgejo will be hosted on.";
example = "example.com";
};
home = lib.mkOption {
default = "";
type = lib.types.str;
@ -63,7 +57,14 @@ in
forgejo = {
enable = true;
settings.server = {
DOMAIN = cfg.domain;
DOMAIN =
let
parsedURL = (lib.strings.splitString "." cfg.url);
in
builtins.concatStringsSep "." [
(builtins.elemAt parsedURL 1)
(builtins.elemAt parsedURL 2)
];
ROOT_URL = cfg.url;
HTTP_PORT = 3000;
};
@ -71,7 +72,14 @@ in
} // lib.optionalAttrs (cfg.home != null) { stateDir = cfg.home; };
nginx.virtualHosts."${cfg.url}" = {
useACMEHost = cfg.domain;
useACMEHost =
let
parsedURL = (lib.strings.splitString "." cfg.url);
in
builtins.concatStringsSep "." [
(builtins.elemAt parsedURL 1)
(builtins.elemAt parsedURL 2)
];
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:3000";

View file

@ -1,9 +1,4 @@
{
config,
lib,
pkgs,
...
}:
{ config, lib, ... }:
let
cfg = config.aux.system.services.home-assistant;
@ -12,12 +7,6 @@ in
options = {
aux.system.services.home-assistant = {
enable = lib.mkEnableOption "Enables Home Assistant.";
domain = lib.mkOption {
default = "";
type = lib.types.str;
description = "The root domain that Home Assistant will be hosted on.";
example = "example.com";
};
home = lib.mkOption {
default = "/etc/home-assistant";
type = lib.types.str;
@ -60,7 +49,14 @@ in
};
};
nginx.virtualHosts."${cfg.url}" = {
useACMEHost = cfg.domain;
useACMEHost =
let
parsedURL = (lib.strings.splitString "." cfg.url);
in
builtins.concatStringsSep "." [
(builtins.elemAt parsedURL 1)
(builtins.elemAt parsedURL 2)
];
forceSSL = true;
locations."/" = {
proxyPass = "http://[::1]:8123";

View file

@ -20,12 +20,6 @@ in
type = lib.types.str;
description = "Where to store Jellyfin's files";
};
domain = lib.mkOption {
default = "";
type = lib.types.str;
description = "The root domain that Jellyfin will be hosted on.";
example = "example.com";
};
url = lib.mkOption {
default = "";
type = lib.types.str;
@ -40,7 +34,14 @@ in
services = {
nginx.virtualHosts."${cfg.url}" = {
useACMEHost = cfg.domain;
useACMEHost =
let
parsedURL = (lib.strings.splitString "." cfg.url);
in
builtins.concatStringsSep "." [
(builtins.elemAt parsedURL 1)
(builtins.elemAt parsedURL 2)
];
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:8096";

View file

@ -28,12 +28,6 @@ in
description = "API key for streaming data from a child to a parent.";
};
};
domain = lib.mkOption {
default = "";
type = lib.types.str;
description = "The root domain that Netdata will be hosted on.";
example = "example.com";
};
type = lib.mkOption {
default = "parent";
type = lib.types.enum [
@ -56,7 +50,14 @@ in
(lib.mkIf (cfg.enable && cfg.type == "parent") {
services = {
nginx.virtualHosts."${cfg.url}" = {
useACMEHost = cfg.domain;
useACMEHost =
let
parsedURL = (lib.strings.splitString "." cfg.url);
in
builtins.concatStringsSep "." [
(builtins.elemAt parsedURL 1)
(builtins.elemAt parsedURL 2)
];
forceSSL = true;
basicAuth = {
"${cfg.auth.user}" = cfg.auth.password;