Refactor meta.{domains,ports}

This commit is contained in:
SebastianStork 2025-08-28 14:20:36 +02:00
parent db0569680e
commit b51d0d095d
4 changed files with 16 additions and 12 deletions

View file

@ -1,5 +1,5 @@
# This is a placeholder.
# The real .sops.yaml is generated via: nix build .#sops-config
# See ./flake/sops.nix for details.
# See flake/sops.nix for details.
creation_rules: []

View file

@ -68,7 +68,7 @@
openspeedtest = {
inherit (config.custom.services.openspeedtest) domain port;
tls = false;
extraReverseProxyConfig = ''
request_buffers 35MiB
response_buffers 35MiB

View file

@ -33,20 +33,21 @@ in
|> lib.concatLists
|> lib.concatMap (
entry:
lib.map (domain: {
file = entry.file;
entry.value
|> lib.map (domain: {
file = entry.file |> lib.removePrefix "${self}/";
inherit domain;
}) entry.value
})
)
|> lib.groupBy (entry: builtins.toString entry.domain)
|> lib.filterAttrs (domain: entries: lib.length entries > 1);
|> lib.filterAttrs (_: entries: lib.length entries > 1);
errorMessage =
duplicateDomains
|> lib.mapAttrsToList (
domain: entries:
"Duplicate domain \"${domain}\" found in:\n"
+ lib.concatMapStrings (entry: " - ${entry.file}\n") entries
+ (entries |> lib.map (entry: " - ${entry.file}") |> lib.concatLines)
)
|> lib.concatStrings;
in

View file

@ -1,6 +1,7 @@
{
config,
options,
self,
lib,
...
}:
@ -23,19 +24,21 @@ in
options.meta.ports.list.definitionsWithLocations
|> lib.concatMap (
entry:
lib.map (port: {
inherit (entry) file;
entry.value
|> lib.map (port: {
file = entry.file |> lib.removePrefix "${self}/";
inherit port;
}) entry.value
})
)
|> lib.groupBy (entry: builtins.toString entry.port)
|> lib.filterAttrs (port: entries: lib.length entries > 1);
|> lib.filterAttrs (_: entries: lib.length entries > 1);
errorMessage =
duplicatePorts
|> lib.mapAttrsToList (
port: entries:
"Duplicate port ${port} found in:\n" + lib.concatMapStrings (entry: " - ${entry.file}\n") entries
"Duplicate port ${port} found in:\n"
+ (entries |> lib.map (entry: " - ${entry.file}") |> lib.concatLines)
)
|> lib.concatStrings;
in