Hi,
I’m still pretty new to NixOS, flakes, home-manager, and all this stuff.
I’m trying to understand how flakes and home-manager interact, in the context of NixOS.
My case here is about NixVim. I’m trying to get it to work in my Home-Manager.
Before I touch anything, my flake looks like that (full repo here):
{
inputs = {
...
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { ... } {
...
nixosConfigurations = {
desktop = nixpkgs.lib.nixosSystem {
modules = [
...
./hosts/desktop
];
};
...
};
};
}
And my ./hosts/desktop
import my home-manager config:
home-manager.users.bhasher = import ../../../home/bhasher.nix;
At the end, I would like to be able to use NixVim in my bhasher.nix
(more precisely, nvim.nix
imported by bhasher.nix
) with:
{ ... }: {
programs.nixvim.enable = true;
}
To accomplish this, I tried two ways:
1. Module in flake.nix
In my output, in added inputs.nixvim.nixosModules.nixvim
:
nixosConfigurations = {
desktop = nixpkgs.lib.nixosSystem {
modules = [
./hosts/desktop
inputs.nixvim.nixosModules.nixvim
];
};
};
But when I compile, I get:
error: The option `home-manager.users.bhasher.programs.nixvim' does not exist.
2. Import in nvim.nix
I also tried to import the Home-Manager module directly in nvim.nix
:
{ ... }: {
imports [ nixvim.homeManagerModules.nixvim ];
programs.nixvim.enable = true;
}
Here too, I receive an error:
error: infinite recursion encountered
I probably don’t understand correctly how NixOS, flake & Home-Manager interact. I saw a ton of examples based on homeManagerConfiguration
, but it seems to be only valid for non-nixos usages.
I’m probably confused by the 1000 ways to do almost everything in nix, and the mix between all options (nixos or not, home manager or not, flake or not, etc)
Thank you!