Configuration.nix config

a configuration.nix is a module

modules have this structure
Example: Structure of NixOS Modules

{ config, pkgs, ... }:

{
  imports =
    [ paths of other modules
    ];

  options = {
    option declarations
  };

  config = {
    option definitions
  };
}

but why do we usually write

{ config, pkgs, ... }: {
  users.users.alice.isNormalUser = true;
}

instead of

{ config, pkgs, ... }: {
  config = { users.users.alice.isNormalUser = true; };
}

Is this syntactic sugar, backwards compatibility, both, neither or something :ghost: completely different?

syntactic sugar to avoid redundancy when one is simply wishing to set existing options instead of defining new ones.

2 Likes

@nrdxp do you know where it is implemented?

Not exactly, but likely somewhere in this beast:

1 Like

More specifically,

2 Likes

It’s documented right above the example you gave:

This is actually an abbreviated form of module that only defines options, but does not declare any. The structure of full NixOS modules is shown in Example: Structure of NixOS Modules.

1 Like