!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

152 Members
30 Servers

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


SenderMessageTime
8 May 2025
@isabel:isabelroses.comisabel changed their profile picture.08:57:53
@isabel:isabelroses.comisabel changed their profile picture.08:57:59
@nam3l33ss:matrix.org·☽•Nameless☆•777 · ± changed their profile picture.13:26:34
16 May 2025
@ss:someonex.netSomeoneSerge (back on matrix)

I never acquainted with types.nix, is there some fundamental reason that either of two freeform submodules couldn't work when left and right have disjoint explicit options?

with import <nixpkgs/lib>;

evalModules {
  modules = [
    {
      options.foo = mkOption {
        type =
          types.either
            (types.submodule {
              freeformType = types.attrsOf types.str;
              options.marker_a = mkOption {
                type = types.str;
              };
            })
            (
              types.submodule {
                freeformType = types.attrsOf types.str;
                options.marker_b = mkOption {
                  type = types.str;
                };
              }
            );
      };
      config.foo = {
        marker_b = "bar";
      };
    }
  ];
}

{ foo = { marker_a = «error: The option `foo.marker_a' was accessed but has no value defined. Try setting 
the option.»; marker_b = "bar"; }; }
19:49:57
@mattsturg:matrix.orgMatt Sturgeon

I believe the issue is the left and right type's check function.

either will use whichever type fist passes check value, and iirc submodules just use something like check = isAttrs

19:52:25

Show newer messages


Back to Room ListRoom Version: 10