I’m trying to convert my nixos-config to Flakes, and it works well, but I found one edge case where I’m not sure what do do. I have a role that imports a service definition from nixos-unstable for mtr-exporter. In my flake.nix I do provide unstable channel:
But does not work for imports when adding the service definition from unstable:
I just get:
error: cannot look up '<nixos-unstable>' in pure evaluation mode (use '--impure' to override)
at /nix/store/iggskbhd3rl7cy9wb0d70bsxb2yjvsnr-source/roles/mtr-exporter.nix:5:5:
4| imports = [
5| <nixos-unstable>/nixos/modules/services/networking/mtr-exporter.nix
| ^
6| ];
But I have no idea if nixos modules can be mixed that way. I usually copy a module and then change it to match my needs if it’s not available on a current branch.
Actually, for some reason if I use the specialArgs method it does work!
I think I get where the error: infinite recursion encountered err or is coming from.
If I get unstable from pkgs.unstable then i get the unstable.legacyPackages.${prev.system}; verison, but if I get unstable from module argument via specialArgs, then I’m getting the value from inputs, which is unstable.url = "nixpkgs/nixos-unstable". Those are two different things!
Thanks for the suggestion, it helped me identify the loop. I need to think about how to solve this though.
My fix uses specialArgs to pass the unstablechannel instead of unstablepackages:
I tried passing it via overlay as channels.unstable = unstable, but for some reason that also caused an infinite recursion error.
It works, but I’m not sure if it’s the best way to solve this issue. But hopefully once 22.05 is out I won’t have a need for loading additional nixos modules.