-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Submodule refactor #108833
Submodule refactor #108833
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ lib, ... }: { | ||
options.submodule = lib.mkOption { | ||
default = {}; | ||
type = lib.types.submoduleWith { | ||
modules = [ ({ options, ... }: { | ||
options.value = lib.mkOption {}; | ||
|
||
options.internalFiles = lib.mkOption { | ||
default = options.value.files; | ||
}; | ||
})]; | ||
}; | ||
}; | ||
|
||
imports = [ | ||
{ | ||
_file = "the-file.nix"; | ||
submodule.value = 10; | ||
} | ||
]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -467,15 +467,10 @@ rec { | |
let | ||
inherit (lib.modules) evalModules; | ||
|
||
coerce = unify: value: if isFunction value | ||
then setFunctionArgs (args: unify (value args)) (functionArgs value) | ||
else unify (if shorthandOnlyDefinesConfig then { config = value; } else value); | ||
|
||
allModules = defs: modules ++ imap1 (n: { value, file }: | ||
if isAttrs value || isFunction value then | ||
# Annotate the value with the location of its definition for better error messages | ||
coerce (lib.modules.unifyModuleSyntax file "${toString file}-${toString n}") value | ||
else value | ||
if isAttrs value && shorthandOnlyDefinesConfig | ||
then { _file = file; config = value; } | ||
else { _file = file; imports = [ value ]; } | ||
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.
So it doesn't seem to be purely refactoring. In all fairness those messages aren't great, but this change is a small step back. Perhaps we could revisit those error messages and make them report an imports "trace" with actual file/line/column positions. 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. Boy was I wrong. This seems to be a solution to the same problem that #177157 solves.
I don't think these occur frequently, and if they do they're a problem that can be solved separately. Adding more off-topic section 🐢
Picking nits...
Something with |
||
) defs; | ||
|
||
freeformType = (evalModules { | ||
|
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.