Nix repl # error: anonymous function at /home/a/configuration.nix:29:1 called without required argument 'config'

standard nix - not experimental flakes
nix repl '<nixpkgs/nixos>'
:l ./configuration.nix

error: anonymous function at /home/a/configuration.nix:29:1 called without required argument 'config'

       at «none»:0: (source not available)

How to load a non flakes configuration into the repl ?

I think you would need to use evalConfig or some other module config to start the evaluation.

Or you just use a most basic flake.

1 Like

nix repl --file '<nixpkgs/nixos>' -I nixos-config=./configuration.nix

1 Like

ps: “did” you find this anywhere in a nix docu?

:l does essentially the following three things:

  1. Import the path given to it (parse and evaluate the contents of the file as a Nix expression)
  2. (If the value of the expression is a function taking an attribute set, try to create an attribute set from values of --arg or --argstr flags, and call the function.)
  3. If the value is an attribute set, it will import the attributes into the REPL scope.

Since your configuration.nix is a function and you are not providing those arguments, loading will fail in the second step as you have noticed.

However, even if you were to provide config, pkgs, etc. through --arg flags, you would just get the contents of the configuration as written in the configuration.nix. It is a NixOS module, and if you want to introspect evaluated system configuration, you will need to evaluate the module in the context of NixOS module system as Sandro suggests (see also Nix repl / system configuration - manipulate config - #7 by jtojnar).


It is listed in Modularity section of the NixOS manual, although using implicit nixos-config path (/etc/nixos/configuration.nix on most NixOS systems).

Overriding the nixos-config does not appear to be documented in the manual except for few unexplained mentions but you can see it used on the first line of the <nixpkgs/nixos> source code.

1 Like