mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 15:11:34 +01:00
Add global domains list
This commit is contained in:
parent
7a9796e02c
commit
f3c3d3268c
2 changed files with 68 additions and 55 deletions
|
|
@ -6,26 +6,6 @@
|
|||
}:
|
||||
let
|
||||
cfg = config.meta.ports;
|
||||
|
||||
duplicatedPorts =
|
||||
options.meta.ports.list.definitionsWithLocations
|
||||
|> lib.concatMap (
|
||||
entry:
|
||||
map (port: {
|
||||
file = entry.file;
|
||||
inherit port;
|
||||
}) entry.value
|
||||
)
|
||||
|> lib.groupBy (entry: toString entry.port)
|
||||
|> lib.filterAttrs (port: entries: lib.length entries > 1);
|
||||
|
||||
errorMessage =
|
||||
duplicatedPorts
|
||||
|> lib.mapAttrsToList (
|
||||
port: entries:
|
||||
"Duplicate port ${port} found in:\n" + lib.concatMapStrings (entry: " - ${entry.file}\n") entries
|
||||
)
|
||||
|> lib.concatStrings;
|
||||
in
|
||||
{
|
||||
options.meta.ports = {
|
||||
|
|
@ -40,11 +20,33 @@ in
|
|||
};
|
||||
|
||||
config = lib.mkIf cfg.assertUnique {
|
||||
assertions = [
|
||||
{
|
||||
assertion = duplicatedPorts == { };
|
||||
message = errorMessage;
|
||||
}
|
||||
];
|
||||
assertions =
|
||||
let
|
||||
duplicatePorts =
|
||||
options.meta.ports.list.definitionsWithLocations
|
||||
|> lib.concatMap (
|
||||
entry:
|
||||
map (port: {
|
||||
inherit (entry) file;
|
||||
inherit port;
|
||||
}) entry.value
|
||||
)
|
||||
|> lib.groupBy (entry: toString entry.port)
|
||||
|> lib.filterAttrs (port: entries: lib.length entries > 1);
|
||||
|
||||
errorMessage =
|
||||
duplicatePorts
|
||||
|> lib.mapAttrsToList (
|
||||
port: entries:
|
||||
"Duplicate port ${port} found in:\n" + lib.concatMapStrings (entry: " - ${entry.file}\n") entries
|
||||
)
|
||||
|> lib.concatStrings;
|
||||
in
|
||||
[
|
||||
{
|
||||
assertion = duplicatePorts == { };
|
||||
message = errorMessage;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue