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

Add standard module path compatibility to extras/modules #262

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions extras/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,11 @@ in
apply = mapAttrs (k: mapAttrs (addInfo k));
};
};
config = {
# Copy over to old nixosModules and hmModules attributes
flake = {
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little wary of conditional attributes in the flake option, because the condition will have to be evaluated before self and self.outPath become accessible, producing an infinite recursion otherwise. (Fixing this for self.outPath needs a more or less breaking change in flakes / call-flake.nix)
In most cases this would be fine, but in the few where it's not, it produces an almost incomprehensible error.

With that in mind, it'd be safer to make this a module that users import separately.

Copy link
Author

Choose a reason for hiding this comment

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

Instead of a separate module that has to be imported, would an option that disables the behavior an okay compromise?

nixosModules = lib.optional (lib.hasAttr "nixos" lib.flake.modules) lib.flake.modules.nixos;
hmModules = lib.optional (lib.hasAttr "homeManager" lib.flake.modules) lib.flake.modules.homeManager;
};
};
}