Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Submodule refactor #108833

wants to merge 2 commits into from

Conversation

infinisil
Copy link
Member

Originally these commits were included in #98952, but they are independent of that PR. Just a test and a small refactoring for more clarity (and less reliance on module internals). Ping @roberth

The module system already uses the parent modules _type as a fallback,
so we don't need to inject the file in a weird way
else value
if isAttrs value && shorthandOnlyDefinesConfig
then { _file = file; config = value; }
else { _file = file; imports = [ value ]; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • n is now unused.
  • Usually an extra imports indirection doesn't matter, but some error messages print a path through the import graph. Those will be a bit harder to understand after this change

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.

Copy link
Member

Choose a reason for hiding this comment

The 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.

  • n is now unused.

n was a technicality of a previous solution for adding _file. Nothing more, nothing less.

Usually an extra imports indirection doesn't matter, but some error messages print a path through the import graph.

I don't think these occur frequently, and if they do they're a problem that can be solved separately. Adding more _file, like this code does, may prevent such messages in the first place.


off-topic section 🐢

So it doesn't seem to be purely refactoring.

Picking nits...

Perhaps we could revisit those error messages and make them report an imports "trace" with actual file/line/column positions.

Something with unsafeGetAttrPos seems like a better path for improving location reporting.

@stale
Copy link

stale bot commented Jul 9, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 9, 2021
@infinisil infinisil added the 6.topic: module system About NixOS module system internals label Mar 1, 2022
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 1, 2022
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 }:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
allModules = defs: modules ++ imap1 (n: { value, file }:
allModules = defs: modules ++ map ({ value, file }:

@roberth roberth mentioned this pull request Jun 14, 2022
15 tasks
@infinisil infinisil deleted the submodule-refactor branch June 14, 2022 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants