In the container documentation, we say:
The declarative approach implies that containers get upgraded along with your host system when you run nixos-rebuild, which is often not what you want. By contrast, in the imperative approach, containers are configured and updated independently from the host system.
It seems like we could reduce the pain around the "often not what you want" part by allowing the container spec to state what environment nixpkgs it wants to run against. I don't know the best mechanism for how to specify that, but it I could imagine saying that I want to point one container against nixos-unstable while its host runs on nixos-14.12, or vice-versa.
In general, it would be cool if the nixpkgs version could be specified in configuration.nix. The version could be specified as branch name (auto-updates when you nixos-rebuild) or commit hash.
The new fetchTarball builtin could make this quite pleasant, if the container mechanism just let us specify what we wanted to evaluate the config with.
@edolstra @nbp any ideas?
Implementing this in a more general manner for all configurations, as @bjornfor suggests, could also allow me to use that mechanism in the configure-from-EC2-userdata work I was doing. I currently specify the channel in a specially formatted comment at the top of the file, but would rather use something standard if it existed.
@copumpkin , I think this would be doable by adding an additional option to specify a different nixpkgs sources that you want to use.
https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/virtualisation/containers.nix#L134
If you only want a different set of packages, but keep newer modules, then you should only set the following option:
https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/misc/nixpkgs.nix#L75
Close as this issue is solved by #11106.
@nbp beautiful, thanks!
As #11106 has been reverted by d4636fa2548a1980b3541dd386b6977c56218964, should this issue be reopened?
Yup
@edolstra, as #11106 got reverted, do we have a solution for this?
Removing milestone as this won't make it until tomorrow.
(triage) any updates?
Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
still important to me
Most helpful comment
In general, it would be cool if the nixpkgs version could be specified in configuration.nix. The version could be specified as branch name (auto-updates when you nixos-rebuild) or commit hash.