-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
lib/modules: add 'index' to module.args of listOf submodule #445774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -719,27 +719,55 @@ let | |
| v2 = | ||
| { loc, defs }: | ||
| let | ||
| evals = filter (x: x.optionalValue ? value) ( | ||
| concatLists ( | ||
| imap1 ( | ||
| n: def: | ||
| imap1 ( | ||
| m: def': | ||
| (mergeDefinitions (loc ++ [ "[definition ${toString n}-entry ${toString m}]" ]) elemType [ | ||
| { | ||
| inherit (def) file; | ||
| value = def'; | ||
| } | ||
| ]) | ||
| ) def.value | ||
| ) defs | ||
| ) | ||
| ); | ||
| evals = | ||
| foldl' | ||
| (acc: def: { | ||
| # Problem: definitions lists dont have equal lengths -> maintain a total counter, to avoid re-iterating | ||
| # Can we do this better? Previously we used concatLists which is optimized | ||
| # Repeated list concatentation might be slow | ||
| res = | ||
| acc.res | ||
| ++ imap1 ( | ||
| m: def': | ||
| (mergeDefinitions (loc ++ [ "[definition ${toString acc.i}-entry ${toString m}]" ]) elemType ( | ||
| [ | ||
| { | ||
| inherit (def) file; | ||
| value = def'; | ||
| } | ||
| ] | ||
| ++ lib.optionals (elemType.name or null == "submodule") [ | ||
| { | ||
| file = "<internal>"; | ||
| value = { | ||
| _module.args.index = acc.total + m - 1; | ||
| }; | ||
| } | ||
| ] | ||
| )) | ||
| ) def.value; | ||
| total = acc.total + length def.value; | ||
| i = acc.i + 1; | ||
| }) | ||
| { | ||
| res = [ ]; | ||
| total = 0; | ||
| i = 0; | ||
| } | ||
| defs; | ||
| in | ||
| { | ||
| headError = checkDefsForError check loc defs; | ||
| value = map (x: x.optionalValue.value or x.mergedValue) evals; | ||
| valueMeta.list = map (v: v.checkedAndMerged.valueMeta) evals; | ||
| # Filtering doesn't affect submodules. | ||
| # Because the root of a submodule cannot be used with mkIf. | ||
| # If this worked, filtering would introduces paradoxons, for example: | ||
| # [ (mkIf (index == 0) { }) { } ] | ||
| value = map (x: x.optionalValue.value or x.mergedValue) ( | ||
| filter (x: x.optionalValue ? value) evals.res | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC assuming |
||
| ); | ||
| valueMeta.list = map (v: v.checkedAndMerged.valueMeta) ( | ||
| filter (x: x.optionalValue ? value) evals.res | ||
| ); | ||
| }; | ||
| }; | ||
| emptyValue = { | ||
|
|
@@ -1227,6 +1255,7 @@ let | |
| # would be used, and use of `<` and `>` would break the XML document. | ||
| # It shouldn't cause an issue since this is cosmetic for the manual. | ||
| _module.args.name = lib.mkOptionDefault "‹name›"; | ||
| _module.args.index = lib.mkOptionDefault "‹index›"; | ||
| } | ||
| ] | ||
| ++ modules; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with
imap0