Attribute 'map' missing when setting up Nixvim

Yes, tried again and it points to the same place in /nix/store.

Try using lib.fetchgit, instead.

I don’t think I understand what that means. I tried replacing import (builtins.fetchGit { ... }) with lib.fetchGit { ... }, but it didn’t know what lib was. I don’t have fetchGit anywhere else in my config so I don’t know anywhere else I would put lib.fetchGit.

Yes, that’s what I meant. You mean, you don’t know where to obtain lib from?

I looked it up, and I tried putting in lib as a library with config, pkgs, inputs, and it’s no longer complaining about lib but now it doesn’t recognize fetchgit (or fetchGit). I’m probably doing this wrong.
Here’s what the first bits of code look like now:

{
  config,
  pkgs,
  inputs,
  lib,
  ...
}: let
  nixvim = import (lib.fetchgit {
    url = "https://github.com/nix-community/nixvim";
  });

Woops. I’m sorry. I think it’s pkgs.fetchgit.

For some reason, now I’m getting an “infinite recursion” error after changing it to pkgs.fetchgit

error:
       … while calling the 'seq' builtin

         at /nix/store/cb1gs888vfqxawvc65q1dk6jzbayh3wz-source/lib/modules.nix:322:18:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       … while evaluating a branch condition

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

          260|       checkUnmatched =
          261|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |         ^
          262|           let

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

       error: infinite recursion encountered

       at /nix/store/cb1gs888vfqxawvc65q1dk6jzbayh3wz-source/lib/modules.nix:508:28:

          507|         builtins.addErrorContext (context name)
          508|           (args.${name} or config._module.args.${name})
             |                            ^
          509|       ) (lib.functionArgs f);

I pin-point infinite recursions by methodically commenting out/in Nix code. Never failed.

Thank you for sharing the full error! (People often don’t.)
This specific type of infrec is due to trying to use a module arg (one of the args at the top of a file) that you never passed into the module system (via _module.args).

Can you share the full file(s) involved in your config?

I’m new to NixOS and Linux, and so I’m not exactly sure if showing my whole file is a good idea, security wise. Here’s my main config module minus lots of comments, packages, user info, and paths:

{
  config,
  pkgs,
  inputs,
  ...
}: let
  nixvim = import (pkgs.fetchgit {
    url = "https://github.com/nix-community/nixvim";
  });
in {
  hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
  };

  hardware.opentabletdriver.enable = true;

  services.xserver.videoDrivers = ["nvidia"];

  hardware.nvidia = {
    modesetting.enable = true; # required
    powerManagement.enable = false;
    powerManagement.finegrained = false;
    open = false;
    nvidiaSettings = true;
    package = config.boot.kernelPackages.nvidiaPackages.beta;
  };

  services.jack = {
    alsa.enable = false;
    loopback = {
      enable = true;
    };
  };

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  boot.supportedFilesystems = ["ntfs"];

  services.devmon.enable = true;
  services.gvfs.enable = true;
  services.udisks2.enable = true;

  services.udev.packages = [pkgs.via];

  boot.initrd.systemd.enable = true;
  boot.kernelParams = ["quiet"];

  programs.bash.blesh.enable = true;
  services.atuin.enable = true;

  boot.plymouth = {
    enable = true;
    theme = "cuts";
    themePackages = [(pkgs.adi1090x-plymouth-themes.override {selected_themes = ["cuts"];})];
  };

  nix.settings.experimental-features = ["nix-command" "flakes"];

  programs.nix-ld.enable = true;

  networking.networkmanager.enable = true;

  services.xserver = {
    enable = true;
    desktopManager = {
      xterm.enable = false;
      xfce = {
        enable = true;
        noDesktop = true;
        enableXfwm = false;
      };
    };
    displayManager.defaultSession = "xfce";
  };

  services.xserver.windowManager.i3 = {
    enable = true;
    package = pkgs.i3;
    extraPackages = with pkgs; [
      rofi
      i3status
      i3lock
      i3blocks-gaps
      i3-auto-layout
      yabar
      # end of i3 pkgs
    ];
  };
  programs.xss-lock.enable = true; # enables xss-lock for 13wm

  xdg.portal.enable = true;
  xdg.portal.extraPortals = [pkgs.xdg-desktop-portal-gtk];

  environment.sessionVariables = {
    WLR_NO_HARDWARE_CURSORS = "1";
    NIXOS_OZONE_WL = "1";
  };

  services.picom = {
    enable = true;
    backend = "glx";
    vSync = true;
  };

  services.xserver = {
    layout = "us";
    xkbVariant = "";
  };

  services.printing.enable = true;

  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    jack.enable = true;
  };

  services.xserver.displayManager.autoLogin.enable = true;

  nixpkgs.config.allowUnfree = true;

  hardware.openrazer.enable = true;
  services.input-remapper.enable = true;

  virtualisation.virtualbox.host.enable = true;
  virtualisation.virtualbox.guest.enable = true;

  programs.steam.enable = true;

  # enable nixvim?
  imports = [nixvim];

  programs.nixvim = {
    enable = true;
  };

  # enable dconf for wpgtk
  programs.dconf.enable = true;

  services.hardware.openrgb = {
    enable = true;
    package = pkgs.openrgb-with-all-plugins;
    motherboard = "amd";
  };
}

I was going to do what @mightyiam suggested, but for some reason rebuilds are taking a while (where everything is on an SSD) and almost everything is in the config where I’m trying to import Nixvim, including stuff I don’t want to uninstall by commenting.

F.Y.I. I’m planning to move most of the user-specific stuff in my config to Home Manager. I’ll probably end up setting up Nixvim on there, if at all, since I already have Neovim configured there. I’m more doing this in case anyone is trying to do the same stuff as me and are running into the same errors.

This seems suspicious.
If you’re using flakes, you’d use a flake input, not fetchgit.
If you’re not using flakes, then I have a feeling you didn’t pass inputs into the module system.
So, are you using flakes?

That’s a decision you have to make based on your threat model, but of course, the less you share, the less concrete help we can provide, and suggestions will become more abstract.
Of course sharing secrets (passwords, keys, etc.) is unnecessary, we’re just looking at nix code here.

Yes, I’m using Home Manager which doesn’t work without flakes enabled for whatever reason. I don’t have any flakes imported in this config or any other config, though. Are you saying I need to switch to using flakes to import Nixvim?

That’s untrue, HM works without flakes. (If anything, HM without flakes probably works better, flakes were tacked onto that project and IMO done badly.) See Home Manager Manual.

I’m not telling you to switch anything. I’m asking, is your config a flake or not?
In other words, I’m asking, do you have a flake.nix in the root directory of your configuration or not?

I do have a flake.nix. I don’t have much in it, but apparently my rebuild command uses it and it links to my configuration.nix which links to the config in my home directory.

What are the contents of the flake.nix?

{
  description = "Nixos config flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, ... }@inputs: {
    nixosConfigurations.default = nixpkgs.lib.nixosSystem {
      specialArgs = {inherit inputs;};
      modules = [
        ./configuration.nix
        inputs.home-manager.nixosModules.default
      ];
    };
  };
}

It also seems to be installing home manager, which I think might be causing errors when I try to use home-manager switch without flakes enabled.

Well you seem to be passing inputs in, so the infrec in the NixOS config can’t be coming from that. I can’t tell the source of the error without seeing the full config.

At the very least, you can anonymise it and put it up in a git repo somewhere.

Well you have HM installed two ways, both as a module and standalone; you need to pick one and stick with that. Hence the manual I linked above.

Done. I got rid of the home-manager bits in the flakes.nix and in the configuration.nix. Trying to add Nixvim still causes an infinite recursion error, though.

​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

Sorry, I didn’t get what you were asking there. I made a git repo with my config files, anonymized and without lockfiles. I’ll add those if you need them, but other than that almost all of my config files are there.