Attribute 'map' missing when setting up Nixvim

Hello again! I’m trying to set up Nixvim on my computer. Right now I have normal Neovim installed (through home-manager) with plugins courtesy of lazy.nvim, and I’m planning on switching from that to Nixvim so that it’s all Nix. When building I get an error saying that an “attribute ‘map’” is “missing”.
Here’s the log file for nixos-switch:

building the system configuration...
error:
       … while calling the 'head' builtin

         at /nix/store/cb1gs888vfqxawvc65q1dk6jzbayh3wz-source/lib/attrsets.nix:1541:11:

         1540|         || pred here (elemAt values 1) (head values) then
         1541|           head values
             |           ^
         1542|         else

       … while evaluating the attribute 'value'

         at /nix/store/cb1gs888vfqxawvc65q1dk6jzbayh3wz-source/lib/modules.nix:809:9:

          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: attribute 'map' missing

       at /nix/store/vs825kzqcls3f35kpidzi5x14gs0syc2-source/plugins/none-ls/sources.nix:10:38:

            9|     ++ (lib.flatten (
           10|       lib.mapAttrsToList (category: (lib.map (mkSourcePlugin category))) noneLsBuiltins
             |                                      ^
           11|     ));
       Did you mean one of imap, max, imap0, imap1 or min?

Here’s the relevant bit of my nix config:

let
  nixvim = import (builtins.fetchGit {
    url = "https://github.com/nix-community/nixvim";
  });
in
  {
    config,
    pkgs,
    inputs,
    ...
  }: {    
    # enable nixvim?
    imports = [nixvim.nixosModules.nixvim];

    programs.nixvim = {
      enable = true;
    };
  }

I’m barely used to flakes and home-manager, although I do have both set up. I switched from using flakes to install Nixvim to using my config in the home directory after I came across the same error. I’m new to Nix and NixOS in general, but if my eyes don’t decieve me then the code the error’s referencing is source code. I’m hoping there’s a way to fix it, but if not I’ll switch to using home-manager to configure Neovim.

It looks like you’re using an outdated Nixpkgs version, updating should fix it :slight_smile: . In particular, the error is saying that lib.map doesn’t exist, which was only introduced recently (also backported to the 24.05 release), and Nixvim started relying on that.

I wasn’t aware the lib aliases for builtins were only added recently, in June. That explains a few issues we ran into in nixvim!

I guess I assumed that since some builtins started off as nixpkgs lib functions before being promoted to builtin status, that all builtins had an alias in lib.

1 Like

That either can’t be it or my system is lying to me. I appear to be on 24.05, and before trying to set up Nixvim, I even added the unstable channel because Nixvim’s documentation said so.
Here’s the output of nix-info -m:

 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.23, NixOS, 24.05 (Uakari), 24.05.20240329.d8fe5e6`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - channels(root): `"nixos, nixos-unstable"`
 - nixpkgs: `/nix/store/cb1gs888vfqxawvc65q1dk6jzbayh3wz-source`

24.05 keeps changing as people backport changes to it. It looks like you’re using a version from March (the 20240329 gives the date), which indeed doesn’t contain lib.map yet.

While I’m not a fan of nix-channel, you should be able to update to the latest 24.05 revision using sudo nix-channel --update :wink:

The command appears to not have updated Nix. I’m still on 24.05.20240329, and the error still pops up.

Perhaps it’s a standalone home-manager installation? In that case, you might need a nix-channel --update not as root.

Well… actually, I take that back. You should probably have only one nixpkgs channel — the one that belongs to root. Do you happen to have any user channels? Try nix-channel --list.

That command outputs nothing, so I’m assuming no, I don’t have any user channels.

I should point out I’m moving my current Neovim config from using lazy.nvim to using home-manager instead. I’ll probably just use that instead of Nixvim if this ends up being unfixable.

What’s the output of sudo nix-channel --list?

nixos https://nixos.org/channels/nixos-unstable
nixos-unstable https://nixos.org/channels/nixos-unstable

NixOS stable and unstable. Again, I added unstable while trying to download Nixvim.

I don’t think you want this duplication. Back when I was using channels I think I had

nixos https://nixos.org/channels/nixpkgs-unstable

But I’m not sure how this can be the cause of your issue.

I removed the channel nixos-unstable, but Nixvim still isn’t installing.
I think I’ve had the problem of NixOS refusing to update properly for a while now. It couldn’t install zed-editor and just today I tried putting nodejs_22 in my config, only for it not to recognize it as a package.

Is there a command that lets us see what a local channel is currently pointing to?

I have no idea. Again, I’m relatively new to Nix and NixOS.

Try using something like this to find out whether channels successfully update:

cat $(nix-instantiate --eval --expr '<nixpkgs>')/.git-revision

Tried that exact command, it returned No such file or directory while trying to find /.git-revision in a Nix store.

How about this:

realpath $(nix-instantiate --eval --expr '<nixpkgs>')

That worked; it printed /nix/store/cb1gs888vfqxawvc65q1dk6jzbayh3wz-source

After you run sudo nix-channel --update, does this remain the same?