standard nix - not experimental flakes
nix repl '<nixpkgs/nixos>'
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.
nix repl --file '<nixpkgs/nixos>' -I nixos-config=./configuration.nix
ps: “did” you find this anywhere in a nix docu?
:l does essentially the following three things:
- Import the path given to it (parse and evaluate the contents of the file as a Nix expression)
- (If the value of the expression is a function taking an attribute set, try to create an attribute set from values of
--argstr flags, and call the function.)
- If the value is an attribute set, it will import the attributes into the REPL scope.
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
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).
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.