format code

This commit is contained in:
Austreelis 2024-06-22 18:38:34 +02:00
parent 5098f7789b
commit 4b9b9c3506
Failed to generate hash of commit

View file

@ -205,52 +205,57 @@ in
let
# Simple backtracking algorithm to generate all combinations of a list's
# elements without ordering, in .
combinations = set:
combinations =
set:
let
n = builtins.length set;
genIndices = combinations':
genIndices =
combinations':
let
prev = builtins.head combinations';
k = builtins.length prev;
first = builtins.head prev;
next' =
# Generate the next combination of length k
if k > 0 && first+1 < n then [(first+1)] ++ (builtins.tail prev)
if k > 0 && first + 1 < n then
[ (first + 1) ] ++ (builtins.tail prev)
# We have generated all combinations of length k, generate the first
# (trivial) combination of length k+1
else builtins.genList (i: i) (k+1);
else
builtins.genList (i: i) (k + 1);
next = builtins.deepSeq next' next';
in
# Generate the very first (trivial) combination
if combinations' == [ ] then genIndices [ [ ] ]
if combinations' == [ ] then
genIndices [ [ ] ]
# We have generated all combinations of length 0 to n, return
else if k >= n then combinations'
else if k >= n then
combinations'
# Generate the next combination and continue
else genIndices ([next] ++ combinations');
else
genIndices ([ next ] ++ combinations');
select = indices: builtins.map (builtins.elemAt set) indices;
in
if set == [ ] then [ ]
else builtins.map select (genIndices []);
if set == [ ] then [ ] else builtins.map select (genIndices [ ]);
keys = combinations (lib.modules.VALID_KEYS ++ lib.modules.VALID_INCLUDE_KEYS);
sets =
builtins.map
(names:
builtins.listToAttrs
(builtins.map (name: { value = null; inherit name; }) names)
sets = builtins.map (
names:
builtins.listToAttrs (
builtins.map (name: {
value = null;
inherit name;
}) names
)
keys;
validated =
builtins.map
(set: {
) keys;
validated = builtins.map (set: {
inherit set;
include = lib.modules.validate.include set;
module = lib.modules.validate.keys set;
})
sets;
bothValid = {include, module, ...}: include && module;
}) sets;
bothValid = { include, module, ... }: include && module;
in
! builtins.any bothValid validated;
!builtins.any bothValid validated;
};
"normalize" = {