How to Properly Integrate NixVim with Home Manager?
I’ve been facing challenges integrating NixVim with Home Manager in my home.nix
configuration. I’m using a Nix flake-based setup, and I’m unsure if my integration approach is correct.
Here’s my flake.nix
file:
{
description = "NixOS - Declarative and user-friendly NixOS configuration with Home Manager and NixVim";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nixvim = {
url = "github:dc-tec/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
polymc = {
url = "github:PolyMC/PolyMC";
};
};
outputs = { self, ... }@inputs:
let
lib = inputs.nixpkgs.lib;
system = "x86_64-linux";
pkgs = inputs.nixpkgs.legacyPackages.${system};
pkgs-stable = inputs.nixpkgs.legacyPackages.${system};
userSettings = {
username = "miskat";
hostname = "nixos";
email = "miskatul.anwar.csecu@gmail.com";
editor = "nvim";
};
in {
nixosConfigurations = {
${userSettings.hostname} = lib.nixosSystem {
inherit system;
modules = [ ./nixos/configuration.nix ];
specialArgs = {
inherit inputs userSettings pkgs-stable;
};
};
};
homeConfigurations = {
${userSettings.username} = inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [ ./home-manager/home.nix ];
extraSpecialArgs = {
inherit inputs userSettings pkgs-stable;
};
};
};
};
}
And here’s my home.nix
file:
{ config, inputs, pkgs, pkgs-stable, userSettings, ... }:
{
imports = [
./modules/bundle.nix
inputs.nixvim.nixosModules
];
home.username = userSettings.username;
home.homeDirectory = "/home/" + userSettings.username;
programs.neovim.defaultEditor = true;
home.stateVersion = "24.05";
programs.nixvim = {
enable = true;
};
home.packages = [
pkgs.hello
pkgs.alacritty
(pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
];
home.file = {
".zshrc".text = ''
alias "ls"="lsd"
# other aliases...
'';
# Additional file sources...
};
home.sessionVariables = {
EDITOR = userSettings.editor;
CC = "clang";
CXX = "clang++";
};
programs.home-manager.enable = true;
}
The Issue
When I run home-manager switch --flake ~/.nix#miskat
, I get the following error:
error:
… while evaluating a branch condition
… while calling the 'length' builtin
error: attribute 'default' missing
I suspect the issue is related to how I reference NixVim in home.nix
. Specifically, I’m unsure whether inputs.nixvim.nixosModules
is the correct way to import NixVim into my configuration.
Questions
- Is my
flake.nix
andhome.nix
setup for NixVim correct? - How should I reference NixVim in
home.nix
to properly enable it? - Could the issue stem from missing or misconfigured imports for NixVim?
—home-manager switch --flake ~/.nix#miskat
error:
… while evaluating a branch condition
at /nix/store/frfyxcpzsdasdin76x83krbhpgkis8b0-source/lib/lists.nix:125:9:
124| fold’ = n:
125| if n == len
| ^
126| then nul
… while calling the 'length' builtin
at /nix/store/frfyxcpzsdasdin76x83krbhpgkis8b0-source/lib/lists.nix:123:13:
122| let
123| len = length list;
| ^
124| fold' = n:
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: The option `inputs' does not exist. Definition values:
- In `/nix/store/6jycrpdgq43vma9zrcvwipp864spbbvi-source/home-manager/home.nix':
{
nixvim = {
enable = true;
settings = {
plugins = [
...
Let me know if this needs further refinement!