Attribute set @ binding resolution inside nixos configuration does not pass whole attrset

An attribute set in a function definition can be bound to a variable via the @ syntax.
To my knowledge this should include all attributes (including omitted ones).

In nix repl this works fine:

test = { d, ... }: d
({ ... }@input: test input) { a = 1; d = 5; }
=> 5

Inside my NixOS configuration I’m trying to pass the input arguments on to a normal import statement:

{
  lib,
  config,
  fn,
  nvim-lazy,
  pkgs,
  ...
}@inputs:

with lib;
{
  imports = [
    nvim-lazy.nixosModules.nvim-lazy
  ];

  programs.nvim-lazy = mkIf (elem "nvim" config.machine.pkgs) {
    enable = true;
    lazyPlugins = flatten (
      map (pluginPath: import pluginPath inputs) (
        # this is just a helper function to list all files in a directory with absolute path
        fn.lst {
          path = (toString ./nvim);
          fullPath = true;
        }
      )
    );
  };
}

This works only if I do not delete the “pkgs” line as it is otherwise not passed on to the files I’m importing, otherwise I’m getting the following error:

error: function 'anonymous lambda' called without required argument 'pkgs'
at /nix/store/k3wq6m7nr84ig2a82h09sf3sllxln8ys-source/pkgsets/nvim/fugitive.nix:1:1:
     1| { pkgs, ... }:
      | ^
     2|

My best guess is that the ?module resolution? via imports = [ ] does some magic I’m not aware of so pkgs is never passed to the parent file unless it is explicitly requested.

Of course, I can always just manually map the required import arguments but it would be nice to just be able to pass everything down.

Am I doing something wrong/is this intended?

Yes

If you don’t provide any arguments, it will only pass config, options, lib and specialArgs.

Read the source code

and the closeModules function and the value closed

1 Like

Thanks so much for the references.
You’re right, I should’ve just checked the source myself.