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

Cannot use nixpkgs.overlays #10

Open
knedlsepp opened this issue May 3, 2023 · 3 comments
Open

Cannot use nixpkgs.overlays #10

knedlsepp opened this issue May 3, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@knedlsepp
Copy link

Describe the bug

I tried setting up a system-manager flake where I consume another flake that exposes a custom package and a corresponding nixosModule with a systemd service. In the system-manager flake I could successfully consume the nixosModule, however the package required for the service could not be found in pkgs. I guess this might be related to no mention of overlays when evaluating nixpkgs.legacyPackages in

pkgs = nixpkgs.legacyPackages.${config.nixpkgs.hostPlatform};
.

Expected behavior

Being able to set nixpkgs.overlays.

@knedlsepp knedlsepp added the bug Something isn't working label May 3, 2023
@aanderse
Copy link
Contributor

aanderse commented May 3, 2023

A bit hacky but the following will currently work reasonably well:

  outputs = { self, flake-utils, system-manager, ... }: {
    systemConfigs.default = system-manager.lib.makeSystemConfig {
      extraSpecialArgs.pkgs = ... whatever you want;
    };
  }

reference:

specialArgs = { nixosModulesPath = "${nixos}/modules"; } // extraSpecialArgs;

It should be pretty straight forward to add something like this without hacks, though.

@r-vdp r-vdp self-assigned this May 4, 2023
@r-vdp
Copy link
Member

r-vdp commented May 4, 2023

Yeah so there are two approaches here. In general we tend to avoid using overlays for this when possible and instead add additional package sets to extraSpecialArgs, as shown by @aanderse above. This has the advantage of not having to potentially re-evaluate nixpkgs multiple times as overlays are being applied, and it makes it more explicit where specific packages are coming from. It is however also more verbose as you need to explicitly pass along the additional package set when calling makeSystemConfig, and then select the required package from that package set in your module.

There are however cases where you really want an overlay, and these are currently not yet taken into account in system-manager. So it would definitely be good if we would either allow the user to specify a list of overlays that we will pass to nixpkgs, or to allow the user to easily pass in their own instance of nixpkgs to which they can then apply any overlays that they want.

I will look into this as soon as I find the time.

@knedlsepp
Copy link
Author

Thank you @r-vdp for providing additional information. In the meantime I was able to work around the issue using the approach mentioned by @aanderse. 👍 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants