system-manager
system-manager copied to clipboard
Cannot use nixpkgs.overlays
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 https://github.com/numtide/system-manager/blob/af437440061b878c9b8a69037383e98d240b1619/nix/lib.nix#L20.
Expected behavior
Being able to set nixpkgs.overlays.
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: https://github.com/numtide/system-manager/blob/af437440061b878c9b8a69037383e98d240b1619/nix/lib.nix#L28
It should be pretty straight forward to add something like this without hacks, though.
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.
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. :+1: :heart:
https://github.com/numtide/system-manager/pull/184
#184
Closing this now that #184 was merged. I trust this works as advertised but I haven't tested it because I've switched away from system-manager to running NixOS containers using systemd-nspawn instead to great success. :)