imports = [
(import “${pkgs.callPackage ./packages/home-manager.nix {}}/nixos”)
];
I get it
dan4ik@nixos:~| ⇒ sudo nixos-rebuild switch
error: infinite recursion encountered, at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:305:28
(use ‘–show-trace’ to show detailed location information)
building Nix…
error: infinite recursion encountered, at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:305:28
(use ‘–show-trace’ to show detailed location information)
building the system configuration…
error: infinite recursion encountered, at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:305:28
(use ‘–show-trace’ to show detailed location information)
dan4ik@nixos:~| ⇒
imports are for nixos modules, not packages. Just use an overlay for adding new packages to your configuration and install them from environment.systemPackages.
I need to import my home-manager from 20.09 with i3 modules from 21.05. If I write it to system packages, nothing happens. What I need is import. Since this is a home manager
i try now.
get it
error: infinite recursion encountered, at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:305:28
(use ‘–show-trace’ to show detailed location information)
building Nix…
error: infinite recursion encountered, at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:305:28
(use ‘–show-trace’ to show detailed location information)
building the system configuration…
error: infinite recursion encountered, at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:305:28
(use ‘–show-trace’ to show detailed location information)
Perhaps (import ./packages/home-manager.nix { }).nixos is what you’re trying to achieve?
Things inside the imports list should only be NixOS modules or files which contain one.
You can’t use things given to you NixOS module as function args in the imports list because that creates a chicken-and-egg situation: The module declared to be imported could overlay the pkgs.callPackage which your module gets in its args and decides the imported module’s value.
The import influences its own value; that’s true recursion right there and thus an infinite recursion error.
I concur with @blaggacao, this sounds very much like an XY question. What are you trying to achieve?
I want to make a home-manager, but as if with a module from the unstable version, and the whole home-manager itself was 20.09, that is, stable. I wrote a build that copies 2 folders from the unstable home-manager i3 module which I need from unstable. Working build. But import home-manager should look like this.
1.import = [
…
(import “$ {builtins.fetchTarball https://github.com/rycee/home-manager/archive/master.tar.gz/nixos”)
];
2. let
home-manager = builtins.fetchGit {
url = “GitHub - nix-community/home-manager: Manage a user environment using Nix [maintainer=@rycee]”;
ref = “release-20.09”;
};
in
{
imports = [
(import “$ {home-manager} / nixos”)
];
Worker build. The module copies from unstable correctly. I just have to start my custom-home-manager, so to speak. But there were problems with this. I also need to import my creation.
As far as I know, home manager has support for specialArgs (the ones that you can pass to an imports key in the module system).
So all you’d need to do in a first iteration is to pass your umstable source as special args to the hm’s module system.
Unfortunately, I don’t have an example at hand.
But there is one more:
You might need to use the disabledModules from the nixpkgs modules system (afaik used as is in HM) to disable the “old modules” with the same (conflicting) declarations.