feat: updated abstractions

This commit is contained in:
Nick 2025-12-10 18:09:00 -06:00
parent 4512d7a5d9
commit 9aab8c6444
31 changed files with 70 additions and 97 deletions

0
modules/config/instances/config/photoprism.nix Normal file → Executable file
View file

View file

@ -3,46 +3,63 @@ let
inherit (flake.config.machines.devices) mars;
inherit (flake.config.services) instances;
svc = service: interface: { inherit service interface; };
makeBookmarks =
{
suffix,
urlTemplate,
services,
}:
builtins.map (name: {
name = "${instances.${name}.label} ${suffix}";
url = urlTemplate name;
tags = instances.${name}.tags;
keyword = instances.${name}.short;
}) (builtins.map (service: instances.${service}.name) services);
builtins.map (
{ service, interface }:
let
name = instances.${service}.name;
interfaceData = instances.${name}.interfaces.${interface};
in
{
name = "${instances.${name}.label} ${suffix}";
url = urlTemplate name interfaceData;
tags = instances.${name}.tags;
keyword = instances.${name}.short;
}
) services;
instanceList = [
instances.firefly-iii.name
instances.forgejo.name
instances.jellyfin.name
instances.mastodon.name
instances.ollama.name
instances.qbittorrent.name
instances.vaultwarden.name
];
bookmarkConfigs = [
{
suffix = "(Remote)";
urlTemplate = name: "https://${instances.${name}.domains.url0}";
services = instanceList;
urlTemplate = name: iface: "https://${iface.domain}";
services = [
(svc instances.firefly-iii.name "interface0")
(svc instances.forgejo.name "interface0")
(svc instances.jellyfin.name "interface0")
(svc instances.mastodon.name "interface0")
(svc instances.ollama.name "interface0")
(svc instances.qbittorrent.name "interface0")
(svc instances.vaultwarden.name "interface0")
];
}
{
suffix = "(Server)";
urlTemplate =
name: "http://${instances.${name}.interface.ip}:${builtins.toString instances.${name}.ports.port0}";
services = instanceList;
name: iface: "http://${iface.microvm.ip}:${builtins.toString instances.${name}.ports.port0}";
services = [
(svc instances.firefly-iii.name "interface0")
(svc instances.forgejo.name "interface0")
(svc instances.jellyfin.name "interface0")
(svc instances.mastodon.name "interface0")
(svc instances.ollama.name "interface0")
(svc instances.qbittorrent.name "interface0")
(svc instances.vaultwarden.name "interface0")
];
}
{
suffix = "(Desktop)";
urlTemplate = name: "http://${mars.ip.address0}:${builtins.toString instances.${name}.ports.port0}";
urlTemplate =
name: iface: "http://${mars.ip.address0}:${builtins.toString instances.${name}.ports.port0}";
services = [
instances.ollama.name
instances.syncthing.name
(svc instances.ollama.name "interface0")
(svc instances.syncthing.name "interface0")
];
}
];
@ -52,7 +69,7 @@ let
flatBookmarks = [
{
name = instances.web.label;
url = "http://${instances.web.localhost.address2}";
url = "http://${instances.web.addresses.address2}";
tags = instances.web.tags;
keyword = instances.web.label;
}

View file

@ -1,9 +1,6 @@
{ flake, osConfig, ... }:
{ flake, ... }:
let
inherit (flake.config.services) instances;
inherit (flake.config.machines) devices;
localhost = instances.web.localhost.address0;
hostname = osConfig.networking.hostName;
in
{
"${instances.jellyfin.label}" = {
@ -13,26 +10,26 @@ in
icon = ./icons/jf.png;
urls = [
{
template = "https://${instances.jellyfin.subdomain}.${instances.web.domains.url0}/web/#/search.html?query={searchTerms}";
}
];
};
"${instances.searx.label}" = {
definedAliases = [
"@sx"
];
icon = ./icons/sx.png;
urls = [
{
template =
(
if hostname == devices.mars.name then
"http://${localhost}:${toString instances.searx.ports.port0}"
else
"https://${instances.searx.subdomain}.${instances.web.domains.url0}"
)
+ "/search?q={searchTerms}";
template = "https://${instances.jellyfin.interfaces.interface0.domain}/web/#/search.html?query={searchTerms}";
}
];
};
# "${instances.searx.label}" = {
# definedAliases = [
# "@sx"
# ];
# icon = ./icons/sx.png;
# urls = [
# {
# template =
# (
# if hostname == devices.mars.name then
# "http://${localhost}:${toString instances.searx.ports.port0}"
# else
# "https://${instances.searx.subdomain}.${instances.web.domains.url0}"
# )
# + "/search?q={searchTerms}";
# }
# ];
# };
}

View file

@ -8,7 +8,7 @@ let
web
;
service = ollama;
localhost = web.localhost.address0;
localhost = web.addresses.address0;
in
{
agent = {

View file

@ -1,10 +1,10 @@
{ flake, matchHelper, ... }:
let
inherit (flake.config.services.instances) forgejo mastodon web;
inherit (flake.config.services) instances;
in
[
(matchHelper ":dotfiles" "https://gitlab.com/upRootNutrition/dotfiles")
(matchHelper ":website" "https://${web.domains.url1}")
(matchHelper ":forgejo" "https://${forgejo.domains.url0}")
(matchHelper ":mastodon" "https://${mastodon.domains.url0}")
(matchHelper ":website" "https://${instances.jellyfin.interfaces.interface0.domain}")
(matchHelper ":forgejo" "https://${instances.forgejo.interfaces.interface0.domain}")
(matchHelper ":mastodon" "https://${instances.mastodon.interfaces.interface0.domain}")
]

0
modules/nixos/homelab/caddy/config/forgejo/default.nix Normal file → Executable file
View file

View file

View file

View file

View file

View file

0
modules/nixos/homelab/caddy/config/website/default.nix Normal file → Executable file
View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

0
modules/nixos/homelab/helpers.nix Normal file → Executable file
View file

0
modules/nixos/homelab/nasDirs/default.nix Normal file → Executable file
View file

View file

@ -8,19 +8,4 @@ let
in
{
imports = importList;
services = {
samba = {
enable = true;
};
};
networking = {
firewall = {
allowedTCPPorts = [
445
];
};
};
}

View file

@ -12,6 +12,7 @@ in
# sudo smbpasswd -a username
services = {
samba = {
enable = true;
# package = pkgs.samba4Full;
openFirewall = true;
settings = {

View file

@ -10,6 +10,7 @@ in
# sudo smbpasswd -a username
services = {
samba = {
enable = true;
openFirewall = true;
settings = {
"storage" = {

View file

@ -6,7 +6,6 @@
}:
let
inherit (flake.config.machines) devices;
inherit (flake.config.services) instances;
hostname = config.networking.hostName;
dotPath = "~/projects/dotfiles";
mkLocalRebuild = ''
@ -21,18 +20,6 @@ let
${name}:
ssh ${ip}
'';
mkMicrVMSshCommands = name: ssh: ''
${name}:
ssh -p ${builtins.toString ssh} root@localhost
'';
balanceHosts = lib.concatStringsSep ", " [
''{name: "${devices.ceres.name}", ssh: "${devices.ceres.ip.address0}"}''
''{name: "${devices.eris.name}", ssh: "${devices.eris.ip.address0}"}''
''{name: "${devices.mars.name}", ssh: "${devices.mars.ip.address0}"}''
''{name: "${devices.deimos.name}", ssh: "${devices.deimos.ip.address0}"}''
''{name: "${devices.phobos.name}", ssh: "${devices.phobos.ip.address0}"}''
''{name: "${devices.lamdagibson.short}", ssh: "-o StrictHostKeyChecking=no denise@${devices.lamdagibson.ip.address0}"}''
];
systemRecords =
command:
lib.concatStrings [
@ -43,31 +30,14 @@ let
(command devices.phobos.name devices.phobos.ip.address0)
(command "lamba" "-o StrictHostKeyChecking=no denise@192.168.50.131")
];
instanceRecords =
command:
lib.concatStrings [
(command instances.vaultwarden.name instances.vaultwarden.interface.ssh)
(command instances.jellyfin.name instances.jellyfin.interface.ssh)
(command instances.forgejo.name instances.forgejo.interface.ssh)
(command instances.firefly-iii.name instances.firefly-iii.interface.ssh)
(command instances.mastodon.name instances.mastodon.interface.ssh)
];
localRebuild = mkLocalRebuild;
remoteRebuild = systemRecords mkRemoteRebuild;
sshCommand = systemRecords mkSshCommands;
microVMSshCommand = instanceRecords mkMicrVMSshCommands;
in
{
text = ''
${localRebuild}
${remoteRebuild}
${sshCommand}
${microVMSshCommand}
balance:
#!/usr/bin/env nu
let results = [${balanceHosts}] | each { |h| let val = (^ssh ...($h.ssh | split row " ") 'nu -c "open /var/lib/defenseio-data/MidnightMiner/balances.json | get snapshots | last | get balance"' | into float); print $"($h.name):"; print $val; $val }
print "---"
print "total:"
$results | math sum
'';
}

View file

@ -52,11 +52,13 @@ in
22 # SSH
25 # SMTP
139 # SMTP
445 # Samba
587 # SMTP
2525 # SMTP
9999 # NC
wireguardService.ports.port0 # WireGuard
];
allowedUDPPorts = [
wireguardService.ports.port0 # WireGuard
wireguardService.ports.port1 # WireGuard

View file

@ -17,7 +17,7 @@ in
sops =
let
sopsPath = secret: {
path = "${service.sops.path0}/${service.name}-${secret}";
# path = "${service.sops.path0}/${service.name}-${secret}";
owner = "root";
mode = "600";
};