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. # This is a placeholder.
# The real .sops.yaml is generated via: nix build .#sops-config # 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: [] creation_rules: []

View file

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

View file

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

View file

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