Skip to content

Commit

Permalink
schema-defined / user-defined distinction, use new attribute syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Dec 7, 2021
1 parent 3f39dee commit 5c3d741
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions docs/development/architecture.org
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ Nix-Gui reads information from the configuration path and =<nixos>= in order to
The result of =get_all_option_values(module_path)= is used to set =OptionData.configured_definition= where applicable.

*** Caveat
The =OptionTree= has a node for each option in the option tree, as well as attributes that aren't actually options.
Attributes in the =OptionTree= can either be *schema-defined* (attribute sets and options specified by =mkOption= in =<nixos>=), or *user-defined*.
User-defined attributes exist as elements / keys of attributes with types which specify a collection (e.g. =list of= and =attribute set of=).

This comment has been minimized.

Copy link
@milahu

milahu Dec 7, 2021

Contributor

please make this more explain-like-im-five (ELI5), and less technical

Attributes in the =OptionTree= can either be *schema-defined* or *user-defined*.

schema-defined Attribute

these Attributes are defined in the nixos config schema, so we call them "schema-defined" Attributes.
in the =<nixos>= source code, these schema-defined Attributes are specified by =mkOption=
for example

foo = mkOption {
  ...
  [ add a minimal working example here ]
}

user-defined Attribute

with user-defined Attributes, the user can give names to "things" in nixos,
for example someUserName1234 or someServiceName1234

For example =users.ldap.loginPam= is a valid nix option. However its "parent", =users.ldap= isn't a valid option. Regardless, =users.ldap= has its own node in the =OptionTree=.
For example, =environment.etc."resolv.conf".text= is a user-defined attribute path, it is part of the schema-defined attribute =environment.etc=.

Likewise, =environment.etc."resolv.conf".text= isn't an option, it is an attribute of the option =environment.etc=. It will have a node in the =OptionTree=. This is true of =attribute set of submodules=, as well as =submodule= type options.
Both schema-defined and user-defined attributes have nodes in the =OptionTree=.

=list of= options are part of the option tree despite not having a proper attribute path, e.g. a list of allowed TCP ports in the firewall will have the element
#+begin_src nix
networking.firewall.allowedTCPPorts."[0]"
networking.firewall.allowedTCPPorts[0]
#+end_src

This is **not** the same as
This is *not* the same as
#+begin_src nix
networking.firewall.allowedTCPPorts."[0]" = <expression>;
networking.firewall.allowedTCPPorts[0] = <expression>; # illegal syntax in nix
#+end_src

rather, it is equivalent to
Expand Down

0 comments on commit 5c3d741

Please sign in to comment.