`nixos/lib/eval-config.nix`: Why is there 2 `let ... in` block after the function head?

Snippet from eval-config.nix:

let extraArgs_ = extraArgs; pkgs_ = pkgs;
    extraModules = let e = builtins.getEnv "NIXOS_EXTRA_MODULE_PATH";
                   in if e == "" then [] else [(import e)];
in

let
  pkgsModule = rec {
    _file = ./eval-config.nix;
    key = _file;
    config = {
      # Explicit `nixpkgs.system` or `nixpkgs.localSystem` should override
      # this.  Since the latter defaults to the former, the former should
      # default to the argument. That way this new default could propagate all
      # they way through, but has the last priority behind everything else.
      nixpkgs.system = lib.mkDefault system;

      # Stash the value of the `system` argument. When using `nesting.children`
      # we want to have the same default value behavior (immediately above)
      # without any interference from the user's configuration.
      nixpkgs.initialSystem = system;

      _module.args.pkgs = lib.mkIf (pkgs_ != null) (lib.mkForce pkgs_);
    };
  };

in rec {

Isn’t the above snippet basically

nix-repl>    let a = 1; b = 2;
          in let c = 3; d = b; 
          in { inherit a b c d; }

{ a = 1; b = 2; c = 3; d = 2; }

which can be re-written as

nix-repl> let a = 1; b = 2; c = 3; d = b; 
          in { inherit a b c d; }

{ a = 1; b = 2; c = 3; d = 2; }

?

1 Like

Most likely no real reason. Probably someone just wanted to throw some new bindings in without having to worry about how it affected the syntax of the surrounding code, so they just threw in a let ... in because it always works.

1 Like