Home-manager neovim collision

Hi there,

I’m new to NixOS and am loving it so far, but came across this weird issue when trying to configure neovim with home-manager, as specified in appendix a.

I have my system managed in a flake and directly configure all my home-manager stuff in said flake. Despite being a little disorganized, I’ve been able to configure plenty of programs via home-manager in this fashion, including zsh and alacritty. In addition, I was able to install neovim by including it in the home.packages list. However, as soon as I try to add something like this:

programs.neovim.enable = true;

and then rebuild the system flake, I get this:

error: collision between `/nix/store/k5d145kij795v7745sdz6afjf69xpmd6-neovim-0.5.1/bin/nvim' and `/nix/store/x10krvikl12chrrx5211nmp3lxfflq1h-neovim-0.5.1/bin/nvim'

I have checked nixos-env --query and neovim is not in the output. I even tried rebuilding directly with home-manager and I get the same error. For reference, here is my flake.nix file that I use to manage my system:

{
    description = "system flake";

    inputs = {
        nixpkgs.url = "nixpkgs/nixos-21.11";
        home-manager.url = "github:nix-community/home-manager/release-21.11";
        home-manager.inputs.nixpkgs.follows = "nixpkgs";
        nixos-hardware.url = "github:NixOS/nixos-hardware/master";
    };

    outputs = { nixpkgs, home-manager, nixos-hardware, ... }:
    let
        system = "x86_64-linux";
        pkgs = import nixpkgs {
          inherit system;
          config = { allowUnfree = true; };
        };
        theme = (import ./users/matt/themes.nix).nord;
    in {
        nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
            inherit system;
            modules = [

                nixos-hardware.nixosModules.lenovo-thinkpad-t420

                ./system/configuration.nix

                home-manager.nixosModules.home-manager {
                    home-manager.users.matt = { config, pkgs, lib, ... }: {
                        nixpkgs.config.allowUnfree = true;

                        imports = [
                          ./users/matt/qtile.nix
                        ];

                        home.stateVersion = lib.mkForce "21.11";

                        home.packages = with pkgs; [
                            alacritty
                            #dmenu
                            exa
                            feh
                            git
                            gnupg
                            networkmanager_dmenu
                            neovim
                            nodejs
                            pass
                            pinentry-qt
                            python
                            rofi
                            spotify-tui
                            xclip
                            zoom-us
                        ];

                        programs.gpg = {
                            enable = true;
                        };

                        services.gpg-agent = {
                            enable = true;
                            pinentryFlavor = "qt";
                        };

                        programs.git = {
                            enable = true;
                            userName = "Matt Muldowney";
                            userEmail = "matt.muldowney@gmail.com";
                            extraConfig = {
                                github.user = "mmuldo";
                                pull.rebase = true;
                            };
                        };

                        programs.zsh = {
                            enable = true;
                            enableAutosuggestions = true;
                            enableSyntaxHighlighting = true;
                            enableCompletion = true;
                            autocd = true;
                            initExtra = ''
                                bindkey -v
                                bindkey '^ ' autosuggest-accept
                            '';
                            oh-my-zsh = {
                                enable = true;
                                custom = "$HOME/.oh-my-zsh/custom";
                                plugins = [
                                    "git"
                                    "zsh-vi-mode"
                                ];
                                theme = "agnoster";
                            };
                            sessionVariables = {
                                PATH = "$HOME/.emacs.d/bin:$HOME/.local/bin:$HOME/.poetry/bin:$HOME/code/jasminix/bin:$PATH";
                                XDG_CONFIG_HOME = "$HOME/.config";
                            };
                            shellAliases = {
                                gaa = "git add -A";
                                gc = "git commit";
                                gcm = "git commit -m";
                                gs = "git status";
                                ls = "exa";
                                vim = "nvim";
                                v = "nvim";
                                vc = "nvim ~/code/jasminix/system/configuration.nix";
                                vh = "nvim ~/code/jasminix/users/matt/home.nix";
                                vf = "nvim ~/code/jasminix/flake.nix";
                            };
                        };

                        programs.qtile = {
                            enable = true;
                            theme = theme;
                        };

                        home.file.".config/qtile/autostart.sh" = {
                            text = ''
                                #!/bin/sh
                                feh --no-fehbg --bg-fill '/home/matt/wallpapers/minimal-25-nordified.jpg' '/home/matt/wallpapers/minimal-25-nordified.jpg'
                                #picom --experimental-backends &
                                #dropbox &
                            '';
                            executable = true;
                        };

                        programs.alacritty = {
                            enable = true;
                            settings = {
                                env.TERM = "alacritty";
                                font.size = 9;
                                draw_bold_text_with_bright_colors = true;
                                selection.save_to_clipboard = false;
                                live_config_reload = true;
                                colors = {
                                    primary = {
                                        background = "${theme.normal.black}";
                                        foreground =  "${theme.normal.white}";
                                        dim_foreground =  "${theme.dim.white}";
                                    };
                                    cursor = {
                                        text =  "CellBackground";
                                        cursor =  "CellForeground";
                                    };
                                    selection = {
                                        text =  "CellBackground";
                                        background =  "CellForeground";
                                    };
                                    normal = {
                                        black =     "${theme.normal.black}";
                                        red =       "${theme.normal.red}";
                                        green =     "${theme.normal.green}";
                                        yellow =    "${theme.normal.yellow}";
                                        blue =      "${theme.normal.blue}";
                                        magenta =   "${theme.normal.magenta}";
                                        cyan =      "${theme.normal.cyan}";
                                        white =     "${theme.normal.white}";
                                    };
                                    bright = {
                                        black =     "${theme.bright.black}";
                                        red =       "${theme.bright.red}";
                                        green =     "${theme.bright.green}";
                                        yellow =    "${theme.bright.yellow}";
                                        blue =      "${theme.bright.blue}";
                                        magenta =   "${theme.bright.magenta}";
                                        cyan =      "${theme.bright.cyan}";
                                        white =     "${theme.bright.white}";
                                    };
                                    dim = {
                                        black =     "${theme.dim.black}";
                                        red =       "${theme.dim.red}";
                                        green =     "${theme.dim.green}";
                                        yellow =    "${theme.dim.yellow}";
                                        blue =      "${theme.dim.blue}";
                                        magenta =   "${theme.dim.magenta}";
                                        cyan =      "${theme.dim.cyan}";
                                        white =     "${theme.dim.white}";
                                    };
                                };
                            };
                        };

                        programs.neovim.enable = true;
                        #programs.neovim = {
                            #enable = true;
                            #coc = {
                            #  enable = true;
                            #};
                            #extraConfig = ''
                            #  filetype plugin indent on
                            #  set nocompatible 
                            #  set showmatch ignorecase smartcase hlsearch incsearch
                            #  set tabstop=4 softtabstop=4 shiftwidth=4 expandtab smarttab autoindent
                            #  set number
                            #  set wildmode=longest,list
                            #  set cursorline
                            #  set ttyfast
                            #  set clipboard+=unnamedplus
                            #  set cc=80
                            #  set title
                            #'';
                        #};

                        programs.rofi = {
                            enable = true;
                            pass.enable = true;
                        };

                        programs.browserpass.enable = true;

                    };
                }

            ];
        };
    };
}

Please let me know if I should include anything else and thanks in advance!

Solution

Remove neovim from your home.packages set.

Explanation

The programs.neovim.enable configuration already adds that. This is true as well for any other packages you’ve enabled with a programs.* module (such as alacritty). You haven’t run into this problem before because the other modules you use are adding the same package to home.package, but the programs.neovim module doesn’t. It instead uses pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped { /* config */ }, which produces something that looks like neovim but is a separate derivation and thus conflicts.

If you look at the programs.neovim module you can see this in the configuration specified for programs.neovim.finalPackage (which is what ends up in home.packages).

In general, any package you enable via a module should not be added separately to home.packages.

4 Likes