Skip to content

Comments

Submodule refactor#108833

Closed
infinisil wants to merge 2 commits intoNixOS:masterfrom
infinisil:submodule-refactor
Closed

Submodule refactor#108833
infinisil wants to merge 2 commits intoNixOS:masterfrom
infinisil:submodule-refactor

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

@infinisil infinisil requested review from edolstra and nbp as code owners January 9, 2021 06:55
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
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Jan 9, 2021
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
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

Labels

6.topic: module system About "NixOS" module system internals 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants