mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 14:01:34 +01:00
Refactor meta.{domains,ports}
This commit is contained in:
parent
db0569680e
commit
b51d0d095d
4 changed files with 16 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue