Path

Identify attributes, expressions, and blocks in an Alloy configuration file.

Estimated time: 1 min

Understand configuration file anatomy

An Alloy configuration file is made of attributes, expressions, and blocks. These elements describe the settings and behavior that Alloy should load.

Attributes are key = value pairs that configure individual settings:

Alloy
url = "http://localhost:9090"

Here, url is the attribute name. The expression on the right side of = provides its value.

Expressions compute values that attributes use. An expression can be:

  • A constant, such as "localhost:9090"
  • A calculation, such as (1 + 2) * 3
  • A standard library call, such as sys.env("HOME")

Alloy evaluates an expression before assigning its result to an attribute. Later milestones show a fourth kind of expression: a reference to another component’s export.

Blocks group related attributes and nested blocks between { and }.

The special logging block configures Alloy’s own log output:

Alloy
logging {
  level  = "debug"
  format = "json"
}

Other blocks define components—the building blocks you’ll learn about next.

You can now identify the three basic parts of an Alloy configuration: attributes hold settings, expressions produce values, and blocks group configuration.


More to explore (optional)

Were you successful?