!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

187 Members
41 Servers

You have reached the beginning of time (for this room).


SenderMessageTime
16 May 2025
@ss:someonex.netSomeoneSerge (UTC+3)

Here's what I meant by freeformType is an option:

Was my second guess. Thanks for walking me through these!

22:19:58
@ss:someonex.netSomeoneSerge (UTC+3) Does work with mkOption indeed: https://gist.github.com/SomeoneSerge/b278317b83e5090fbfa9472c78701703 22:51:20
@mattsturg:matrix.orgMatt Sturgeon

Awesome!

I'd highly recommend checking the marker_a.isDefined && marker_b.isDefined case too, which I assume should be an error?

The else case where neither are defined may need some special handling too: is it an error? Is it still an error if cfg is empty?

22:56:09
@ss:someonex.netSomeoneSerge (UTC+3) Yes, an error. Still struggling a bit conceptually though, seems like there are three different kinds of entities in evalModules: "types" are things that have checks, "modules" are things that produce options and configs, but options are confusing 23:17:40
@ss:someonex.netSomeoneSerge (UTC+3) It's not possible to extend options._module.freeformType with an apply from outside? 23:18:12
@ss:someonex.netSomeoneSerge (UTC+3) * It's not possible to extend options._module.freeformType with an apply from outside is it? 23:18:15
@ss:someonex.netSomeoneSerge (UTC+3) * Yes, an error. Still struggling a bit conceptually though, seems like there are three different kinds of entities in evalModules: "types" are things that have checks, "modules" are things that produce options and configs, but "options" are confusing 23:18:43
@mattsturg:matrix.orgMatt Sturgeon

Yes, there's a few "types" of thing in the module system:

  1. configuration is the final evaluated module eval, returned by evalModules. It contains _type, options, config, type` (a submodule option-type), etc
  2. module these are the "modules" the module system evaluates. Can be a long-form or short-hand attrset, a function returning one, or a file containing one.
  3. options these describe the attrs that can be defined in the configuration. Declared using options.foo = mkOption {}, defined using config.foo = "value" (or the short-hand syntax foo = "value").
  4. option-types these are types that options can declare they have. This is where type checking and definition merging is done.

Submodules are an option-type representing another configuration. The submodule type expects the option definitions to be modules, and it merges those modules using evalModules and uses the configuration's config as its final value.

23:24:13
@mattsturg:matrix.orgMatt Sturgeon

I'm not sure. Usually merging things relates to having multiple definitions for an option, but the module system does also support merging multiple declarations for an option too, in some scenarios.

You may be able to declare options._module.freeformType = mkOption { apply = x: x; }, but IDK why you would want to do that... ?

23:26:47

Show newer messages


Back to Room ListRoom Version: 10