Add shared services infrastructure for cross-host data
Created centralized service definitions in shared/services.nix to store service metadata (domains, IPs, ports) that need to be accessible across multiple hosts. This replaces the per-service split DNS module approach with a single source of truth. Services are now exported through utils.nix for easy access in host configs.
This commit is contained in:
parent
2289f0e6e4
commit
af444584d0
3 changed files with 63 additions and 61 deletions
|
|
@ -1,39 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
utils = import ../../utils.nix { inherit inputs lib; };
|
||||
inherit (utils) mkNginxVHosts;
|
||||
in
|
||||
|
||||
{
|
||||
virtualisation.oci-containers.containers."librespeed" = {
|
||||
image = "lscr.io/linuxserver/librespeed:latest";
|
||||
environment = {
|
||||
TZ = "America/Bahia";
|
||||
};
|
||||
ports = [ "127.0.0.1:58080:80" ];
|
||||
extraOptions = [
|
||||
"--pull=newer"
|
||||
"--label=io.containers.autoupdate=registry"
|
||||
];
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts = mkNginxVHosts {
|
||||
acmeHost = "baduhai.dev";
|
||||
domains."speedtest.baduhai.dev".locations."/".proxyPass = "http://127.0.0.1:58080/";
|
||||
};
|
||||
|
||||
# Register this domain for split DNS
|
||||
services.splitDNS.entries = [
|
||||
{
|
||||
domain = "speedtest.baduhai.dev";
|
||||
lanIP = "192.168.15.142";
|
||||
tailscaleIP = "100.76.19.50";
|
||||
}
|
||||
];
|
||||
}
|
||||
39
shared/services.nix
Normal file
39
shared/services.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# Shared service definitions for cross-host configuration
|
||||
# Used by:
|
||||
# - alexandria: DNS server (LAN) + service hosting (vaultwarden, nextcloud, jellyfin)
|
||||
# - trantor: DNS server (Tailnet) + service hosting (forgejo)
|
||||
{
|
||||
services = [
|
||||
{
|
||||
name = "vaultwarden";
|
||||
domain = "vault.baduhai.dev";
|
||||
host = "alexandria";
|
||||
lanIP = "192.168.15.142";
|
||||
tailscaleIP = "100.76.19.50";
|
||||
port = 8222;
|
||||
}
|
||||
{
|
||||
name = "forgejo";
|
||||
domain = "git.baduhai.dev";
|
||||
host = "trantor";
|
||||
tailscaleIP = "100.108.5.90";
|
||||
port = 3000;
|
||||
}
|
||||
{
|
||||
name = "nextcloud";
|
||||
domain = "cloud.baduhai.dev";
|
||||
host = "alexandria";
|
||||
lanIP = "192.168.15.142";
|
||||
tailscaleIP = "100.76.19.50";
|
||||
port = 443;
|
||||
}
|
||||
{
|
||||
name = "jellyfin";
|
||||
domain = "jellyfin.baduhai.dev";
|
||||
host = "alexandria";
|
||||
lanIP = "192.168.15.142";
|
||||
tailscaleIP = "100.76.19.50";
|
||||
port = 8096;
|
||||
}
|
||||
];
|
||||
}
|
||||
46
utils.nix
46
utils.nix
|
|
@ -8,9 +8,14 @@ let
|
|||
home-manager
|
||||
agenix
|
||||
;
|
||||
|
||||
# Import shared service definitions
|
||||
sharedServices = import ./shared/services.nix;
|
||||
in
|
||||
|
||||
{
|
||||
# Re-export shared services for use in host configs
|
||||
inherit (sharedServices) services;
|
||||
# Tag-based host configuration system
|
||||
mkHost =
|
||||
{
|
||||
|
|
@ -196,27 +201,24 @@ in
|
|||
mkSplitDNS =
|
||||
entries:
|
||||
let
|
||||
# Generate view entries for a single domain
|
||||
mkEntry =
|
||||
{
|
||||
domain,
|
||||
lanIP,
|
||||
tailscaleIP,
|
||||
}:
|
||||
[
|
||||
{
|
||||
name = "tailscale";
|
||||
view-first = true;
|
||||
local-zone = ''"baduhai.dev." transparent'';
|
||||
local-data = ''"${domain}. IN A ${tailscaleIP}"'';
|
||||
}
|
||||
{
|
||||
name = "lan";
|
||||
view-first = true;
|
||||
local-zone = ''"baduhai.dev." transparent'';
|
||||
local-data = ''"${domain}. IN A ${lanIP}"'';
|
||||
}
|
||||
];
|
||||
# Generate local-data entries for all domains
|
||||
tailscaleData = map (e: ''"${e.domain}. IN A ${e.tailscaleIP}"'') entries;
|
||||
lanData = map (e: ''"${e.domain}. IN A ${e.lanIP}"'') entries;
|
||||
in
|
||||
builtins.concatMap mkEntry entries;
|
||||
[
|
||||
# Single Tailscale view with all domains
|
||||
{
|
||||
name = "tailscale";
|
||||
view-first = true;
|
||||
local-zone = ''"baduhai.dev." transparent'';
|
||||
local-data = tailscaleData;
|
||||
}
|
||||
# Single LAN view with all domains
|
||||
{
|
||||
name = "lan";
|
||||
view-first = true;
|
||||
local-zone = ''"baduhai.dev." transparent'';
|
||||
local-data = lanData;
|
||||
}
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue