-
Notifications
You must be signed in to change notification settings - Fork 47
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
Cannot import a custom nixosModule in a separate file #274
Comments
I see that you're importing into the The following would fix it. systems = nixpkgs.lib.systems.flakeExposed;
- flake = {
- imports = [
- ./mymodule1.nix
- ];
+ imports = [
+ ./mymodule1.nix
+ ];
+ flake = { # ./mymodule1.nix
{ moduleWithSystem, ... }:
{
- nixosModules.mymodule1 = moduleWithSystem (
+ flake.nixosModules.mymodule1 = moduleWithSystem (
perSystem@{ config }: # NOTE: only explicit params will be in perSystem I don't think |
In https://flake.parts/getting-started.html we find outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
flake = {
# Put your original flake attributes here.
};
systems = [
# systems for which you want to build the `perSystem` attributes
"x86_64-linux"
# ...
];
perSystem = { config, ... }: {
};
}; This strongly suggests putting top-level imports under flake, which I think makes more sense. Furthermore, adding the argument |
Thank you for connecting this back to that page. I think this would have helped:
Right, I think it's important to make a distinction here.
|
I am unable to import custom modules from a local file and use them in my own nixosConfigurations. For some reason the
moduleWithSystem
argument is not passed to paths underflake.imports
even though the documentation would lead me to believe this is the case.nix build .#nixosConfigurations.mymodule1.config.system.build.toplevel
give meerror: attribute 'moduleWithSystem' missing
nix build .#nixosConfigurations.mymodule2.config.system.build.toplevel
works, only erroring out later because the configuration is not bootable.EDIT: as a bonus, it would be nice do something like
The text was updated successfully, but these errors were encountered: