diff options
Diffstat (limited to '')
| -rw-r--r-- | modules/dashboard/bacchus-dashboard.service.nix | 2 | ||||
| -rw-r--r-- | modules/dashboard/dashboard-template.nix | 19 | ||||
| -rw-r--r-- | modules/dashboard/default.nix | 22 | ||||
| -rw-r--r-- | modules/media/default.nix | 2 | ||||
| -rw-r--r-- | modules/network/default.nix | 4 | ||||
| -rw-r--r-- | modules/service-router.service.nix | 49 |
6 files changed, 84 insertions, 14 deletions
diff --git a/modules/dashboard/bacchus-dashboard.service.nix b/modules/dashboard/bacchus-dashboard.service.nix index c14111b..12161c5 100644 --- a/modules/dashboard/bacchus-dashboard.service.nix +++ b/modules/dashboard/bacchus-dashboard.service.nix @@ -32,7 +32,7 @@ in config = { services.nginx = mkIf cfg.enable { enable = true; - virtualHosts."${cfg.host}" = { + virtualHosts.${cfg.host} = { listen = [ { addr = toString cfg.port; } ]; locations."/" = { root = pageDir; diff --git a/modules/dashboard/dashboard-template.nix b/modules/dashboard/dashboard-template.nix index a1df813..5a99e20 100644 --- a/modules/dashboard/dashboard-template.nix +++ b/modules/dashboard/dashboard-template.nix @@ -5,12 +5,11 @@ let if hasAttr attr link then value else def; linkHTML = link: '' - <div> - <a href="${link.url}" class="card" style="${withLinkAttr link "color" "" "--color-card-accent: ${link.color}"}"> - ${link.title} ${if hasAttr "key" link then "(${link.key})" else ""} - <div class="card-link">${link.url}</div> - </a> - </div> + <a href="${link.url}" class="card" style="${withLinkAttr link "color" "" "--color-card-accent: ${link.color}"}"> + ${link.title} ${if hasAttr "key" link then "(${link.key})" else ""} + <div class="card-link">${link.url}</div> + ${if hasAttr "altUrl" link then ''<div class="card-link">(Alt: ${link.altUrl})</div>'' else ""} + </a> ''; script = '' @@ -86,6 +85,14 @@ let padding-top: 1em; color: gray; } + button { + background: none; + padding: 0; + text-decoration: underline; + color: gray; + margin: 0; + border: 0; + } ''; headerHTML = '' diff --git a/modules/dashboard/default.nix b/modules/dashboard/default.nix index 54db0d9..9e434c2 100644 --- a/modules/dashboard/default.nix +++ b/modules/dashboard/default.nix @@ -9,32 +9,44 @@ in services.bacchus-dashboard = { enable = true; openFirewall = true; - title = "Dashboard"; + port = ports.dashboard; + title = "Bacchus Dashboard"; links = [ { title = "Jellyfin"; key = "j"; - url = "http://${settings.network.host}:${toString ports.jellyfin}"; + url = "http://jellyfin.local"; + altUrl = "http://${settings.network.host}:${toString ports.jellyfin}"; color = "#AA5CC3"; } { title = "Sonarr"; key = "s"; - url = "http://${settings.network.host}:${toString ports.sonarr}"; + url = "http://sonarr.local"; + altUrl = "http://${settings.network.host}:${toString ports.sonarr}"; color = "#4c82cf"; } { title = "Radarr"; key = "r"; - url = "http://${settings.network.host}:${toString ports.radarr}"; + url = "http://radarr.local"; + altUrl = "http://${settings.network.host}:${toString ports.radarr}"; color = "#fcbd00"; } { title = "Prowlarr"; key = "p"; - url = "http://${settings.network.host}:${toString ports.prowlarr}"; + url = "http://prowlarr.local"; + altUrl = "http://${settings.network.host}:${toString ports.prowlarr}"; color = "#ff9a7e"; } + { + title = "Syncthing"; + key = "y"; + url = "http://syncthing.local"; + altUrl = "http://${settings.network.host}:${toString ports.syncthing}"; + color = "#0891d1"; + } ]; }; } diff --git a/modules/media/default.nix b/modules/media/default.nix index 4c8edaa..aad65d0 100644 --- a/modules/media/default.nix +++ b/modules/media/default.nix @@ -11,7 +11,7 @@ in "d ${settings.media.tvDir} 0770 sonarr ${settings.media.group} - -" "d ${settings.media.moviesDir} 0770 radarr ${settings.media.group} - -" ]; - users.groups."${settings.media.group}" = { }; + users.groups.${settings.media.group} = { }; users.users.bacchus.extraGroups = [ settings.media.group ]; services.sonarr = { diff --git a/modules/network/default.nix b/modules/network/default.nix index 5a18f37..ee3462c 100644 --- a/modules/network/default.nix +++ b/modules/network/default.nix @@ -3,7 +3,9 @@ let settings = import ../../settings.nix { inherit lib; }; in { - imports = [ ./ssh.nix ]; + imports = [ + ./ssh.nix + ]; networking = { hostName = "bacchus"; diff --git a/modules/service-router.service.nix b/modules/service-router.service.nix new file mode 100644 index 0000000..0b9a873 --- /dev/null +++ b/modules/service-router.service.nix @@ -0,0 +1,49 @@ +{ config, lib, dns, ... }: +with lib; +let + cfg = config.services.service-router; + domainAZone = domain: record: { + A = [ record ]; + SOA = { + nameServer = "ns.${domain}."; + adminEmail = "dont@email.me"; + serial = 2019030800; + }; + NS = [ "ns.${domain}." ]; + }; +in { + options.services.service-router = { + enable = mkEnableOption "enable router"; + routes = mkOption { + type = types.attrsOf (types.submodule { options = { + port = mkOption { type = types.int; }; + host = mkOption { type = types.str; default = "127.0.0.1"; }; + protocol = mkOption { type = types.str; default = "http"; }; + }; }); + default = {}; + }; + }; + + config = lib.mkIf cfg.enable { + services.nginx = { + enable = true; + virtualHosts = lib.mapAttrs (_: val: { + locations."/" = { + proxyPass = "${val.protocol}://${val.host}:${toString val.port}"; + }; + }) cfg.routes; + }; + + services.nsd = { + enable = true; + interfaces = [ "0.0.0.0" ]; + zones = lib.mapAttrs (domain: val: { + data = dns.lib.toString domain (domainAZone domain val.host); + }) cfg.routes; + }; + networking.firewall.allowedTCPPorts = [ 53 ]; + networking.firewall.allowedUDPPorts = [ 53 ]; + + networking.hosts."127.0.0.1" = lib.mapAttrsToList (name: _: name) cfg.routes; + }; +} |
