Services: parse domain from service URL (there's probably a better way to do this)
This commit is contained in:
parent
51a11039d7
commit
10c0e42954
|
@ -137,7 +137,6 @@ in
|
||||||
deluge = {
|
deluge = {
|
||||||
enable = true;
|
enable = true;
|
||||||
home = "${services-root}/deluge";
|
home = "${services-root}/deluge";
|
||||||
domain = config.secrets.networking.domains.primary;
|
|
||||||
url = config.secrets.services.deluge.url;
|
url = config.secrets.services.deluge.url;
|
||||||
};
|
};
|
||||||
duplicacy-web = {
|
duplicacy-web = {
|
||||||
|
@ -147,7 +146,6 @@ in
|
||||||
forgejo = {
|
forgejo = {
|
||||||
enable = true;
|
enable = true;
|
||||||
home = "${services-root}/forgejo";
|
home = "${services-root}/forgejo";
|
||||||
domain = config.secrets.networking.domains.primary;
|
|
||||||
url = config.secrets.services.forgejo.url;
|
url = config.secrets.services.forgejo.url;
|
||||||
actions = {
|
actions = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -157,13 +155,11 @@ in
|
||||||
jellyfin = {
|
jellyfin = {
|
||||||
enable = true;
|
enable = true;
|
||||||
home = "${services-root}/jellyfin";
|
home = "${services-root}/jellyfin";
|
||||||
domain = config.secrets.networking.domains.primary;
|
|
||||||
url = config.secrets.services.jellyfin.url;
|
url = config.secrets.services.jellyfin.url;
|
||||||
};
|
};
|
||||||
msmtp.enable = true;
|
msmtp.enable = true;
|
||||||
netdata = {
|
netdata = {
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = config.secrets.networking.domains.primary;
|
|
||||||
type = "parent";
|
type = "parent";
|
||||||
url = config.secrets.services.netdata.url;
|
url = config.secrets.services.netdata.url;
|
||||||
auth = {
|
auth = {
|
||||||
|
|
|
@ -124,7 +124,6 @@ in
|
||||||
deluge = {
|
deluge = {
|
||||||
enable = true;
|
enable = true;
|
||||||
home = "${services-root}/deluge";
|
home = "${services-root}/deluge";
|
||||||
domain = config.secrets.networking.domains.primary;
|
|
||||||
url = config.secrets.services.deluge.url;
|
url = config.secrets.services.deluge.url;
|
||||||
};
|
};
|
||||||
duplicacy-web = {
|
duplicacy-web = {
|
||||||
|
@ -134,7 +133,6 @@ in
|
||||||
forgejo = {
|
forgejo = {
|
||||||
enable = true;
|
enable = true;
|
||||||
home = "${services-root}/forgejo";
|
home = "${services-root}/forgejo";
|
||||||
domain = config.secrets.networking.domains.primary;
|
|
||||||
url = config.secrets.services.forgejo.url;
|
url = config.secrets.services.forgejo.url;
|
||||||
actions = {
|
actions = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -144,19 +142,16 @@ in
|
||||||
home-assistant = {
|
home-assistant = {
|
||||||
enable = false;
|
enable = false;
|
||||||
home = "${services-root}/home-assistant";
|
home = "${services-root}/home-assistant";
|
||||||
domain = config.secrets.networking.domains.primary;
|
|
||||||
url = config.secrets.services.home-assistant.url;
|
url = config.secrets.services.home-assistant.url;
|
||||||
};
|
};
|
||||||
jellyfin = {
|
jellyfin = {
|
||||||
enable = true;
|
enable = true;
|
||||||
home = "${services-root}/jellyfin";
|
home = "${services-root}/jellyfin";
|
||||||
domain = config.secrets.networking.domains.primary;
|
|
||||||
url = config.secrets.services.jellyfin.url;
|
url = config.secrets.services.jellyfin.url;
|
||||||
};
|
};
|
||||||
msmtp.enable = true;
|
msmtp.enable = true;
|
||||||
netdata = {
|
netdata = {
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = config.secrets.networking.domains.primary;
|
|
||||||
type = "parent";
|
type = "parent";
|
||||||
url = config.secrets.services.netdata.url;
|
url = config.secrets.services.netdata.url;
|
||||||
auth = {
|
auth = {
|
||||||
|
|
|
@ -16,12 +16,6 @@ in
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "Where to store Airsonic's files";
|
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 {
|
url = lib.mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
|
@ -37,7 +31,14 @@ in
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
nginx.virtualHosts."${cfg.url}" = {
|
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;
|
forceSSL = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://127.0.0.1:4040";
|
proxyPass = "http://127.0.0.1:4040";
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# This is an example of a blank module.
|
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -13,12 +12,6 @@ in
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "Where to store Deluge's files";
|
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 {
|
url = lib.mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
|
@ -32,7 +25,14 @@ in
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
services = {
|
services = {
|
||||||
nginx.virtualHosts."${cfg.url}" = {
|
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;
|
forceSSL = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://127.0.0.1:8112";
|
proxyPass = "http://127.0.0.1:8112";
|
||||||
|
|
|
@ -25,12 +25,6 @@ in
|
||||||
options = {
|
options = {
|
||||||
aux.system.services.forgejo = {
|
aux.system.services.forgejo = {
|
||||||
enable = lib.mkEnableOption "Enables Forgejo Git hosting service.";
|
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 {
|
home = lib.mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
|
@ -63,7 +57,14 @@ in
|
||||||
forgejo = {
|
forgejo = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings.server = {
|
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;
|
ROOT_URL = cfg.url;
|
||||||
HTTP_PORT = 3000;
|
HTTP_PORT = 3000;
|
||||||
};
|
};
|
||||||
|
@ -71,7 +72,14 @@ in
|
||||||
} // lib.optionalAttrs (cfg.home != null) { stateDir = cfg.home; };
|
} // lib.optionalAttrs (cfg.home != null) { stateDir = cfg.home; };
|
||||||
|
|
||||||
nginx.virtualHosts."${cfg.url}" = {
|
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;
|
forceSSL = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://127.0.0.1:3000";
|
proxyPass = "http://127.0.0.1:3000";
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
{
|
{ config, lib, ... }:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.aux.system.services.home-assistant;
|
cfg = config.aux.system.services.home-assistant;
|
||||||
|
@ -12,12 +7,6 @@ in
|
||||||
options = {
|
options = {
|
||||||
aux.system.services.home-assistant = {
|
aux.system.services.home-assistant = {
|
||||||
enable = lib.mkEnableOption "Enables 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 {
|
home = lib.mkOption {
|
||||||
default = "/etc/home-assistant";
|
default = "/etc/home-assistant";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
|
@ -60,7 +49,14 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
nginx.virtualHosts."${cfg.url}" = {
|
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;
|
forceSSL = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://[::1]:8123";
|
proxyPass = "http://[::1]:8123";
|
||||||
|
|
|
@ -20,12 +20,6 @@ in
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "Where to store Jellyfin's files";
|
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 {
|
url = lib.mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
|
@ -40,7 +34,14 @@ in
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
nginx.virtualHosts."${cfg.url}" = {
|
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;
|
forceSSL = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://127.0.0.1:8096";
|
proxyPass = "http://127.0.0.1:8096";
|
||||||
|
|
|
@ -28,12 +28,6 @@ in
|
||||||
description = "API key for streaming data from a child to a parent.";
|
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 {
|
type = lib.mkOption {
|
||||||
default = "parent";
|
default = "parent";
|
||||||
type = lib.types.enum [
|
type = lib.types.enum [
|
||||||
|
@ -56,7 +50,14 @@ in
|
||||||
(lib.mkIf (cfg.enable && cfg.type == "parent") {
|
(lib.mkIf (cfg.enable && cfg.type == "parent") {
|
||||||
services = {
|
services = {
|
||||||
nginx.virtualHosts."${cfg.url}" = {
|
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;
|
forceSSL = true;
|
||||||
basicAuth = {
|
basicAuth = {
|
||||||
"${cfg.auth.user}" = cfg.auth.password;
|
"${cfg.auth.user}" = cfg.auth.password;
|
||||||
|
|
Loading…
Reference in a new issue