Skip to content

feat: Add nixosConfig option to nixosGenerate #365

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

Closed
wants to merge 1 commit into from
Closed

feat: Add nixosConfig option to nixosGenerate #365

wants to merge 1 commit into from

Conversation

shymega
Copy link

@shymega shymega commented Aug 25, 2024

WIP! WIP! WIP!

Currently doesn't work, but the idea is for an extra option (but not required) to nixosGenerate - a nixosSystem, which is then merged with the image attrset.

WIP! WIP! WIP!

Currently doesn't work, but the idea is for an extra option (but not
required) to `nixosGenerate` - a `nixosSystem`, which is then merged
with the `image` attrset.
@@ -100,7 +101,7 @@
formatModule
]
++ modules;
};
} // nixosConfig;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is needed. You can use the modules parameter to pass in your customizations. Also would needs to use imports so it merges correctly.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, meant to explain further in PR. I've tried passing through my nixosConfiguration as a module, and I get the following error:

nix build -L .\#packages.MTX-SRV
error:
       … while evaluating the attribute 'config.system.build."${(image).config.formatAttr}"'

         at /nix/store/5z81la6av4j0ckp0w1949lxiwjyyykks-source/lib/modules.nix:322:9:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);while calling the 'seq' builtin

         at /nix/store/5z81la6av4j0ckp0w1949lxiwjyyykks-source/lib/modules.nix:322:18:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: Could not load a value as a module, because it is of type "configuration", in file /nix/store/5z81la6av4j0ckp0w1949lxiwjyyykks-source/flake.nix. If you do intend to import this configuration, please only import the modules that make up the configuration. You may have to create a `let` binding, file or attribute to give yourself access to the relevant modules.
       While loading a configuration into the module system is a very sensible idea, it can not be done cleanly in practice.

I thought my PR might be a good starting point to get this working.

The source is here

Copy link
Member

@Mic92 Mic92 Aug 25, 2024

Choose a reason for hiding this comment

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

If you just want to generate for your nixos configuration than import nixos-generators.nixosModules.all-formats in your nixos configuration and than reference
nixosConfigurations.my-machine.config.formats.proxmox instead. One cannot import a nixos systems like that as a module. There is an example for that in the README.

Copy link
Author

Choose a reason for hiding this comment

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

Right, okay. Should I close the PR? It would be nice to be able to pass a nixosConfiguration to nixosGenerate, but I understand (as a maintainer) if you'd rather keep the current functionality.

@shymega
Copy link
Author

shymega commented Aug 25, 2024

I think #246 implements this anyway. My preference would be to let the community vote on whenever they'd like the proposed functionality. As this PR is a dupe of #246, closing as dupe.

@shymega shymega closed this Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants