!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

159 Members
31 Servers

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


SenderMessageTime
18 Nov 2024
@frontear:matrix.orgfrontearthanks for the response thats honestly somewhat embarrassing that i didnt catch that earlier21:39:14
@frontear:matrix.orgfrontear because like you said, the priority being there was a big sign 21:39:26
19 Nov 2024
@ibizaman:matrix.orgibizaman
In reply to @frontear:matrix.org
thanks for the response thats honestly somewhat embarrassing that i didnt catch that earlier
Hey sometimes you’re too much in the weeds, seeing the big picture becomes hard. Definitely happened to me more than once.
12:39:21
20 Nov 2024
@inayet:matrix.orgInayet removed their profile picture.00:59:38
21 Nov 2024
@nerves:bark.lgbtJason Odoom changed their profile picture.02:51:47
@oddlama:matrix.orgoddlama joined the room.13:46:18
25 Nov 2024
@nullcube:matrix.org@nullcube:matrix.org joined the room.10:00:58
27 Nov 2024
@jopejoe1:matrix.orgjopejoe1 (4094@epvpn) changed their display name from jopejoe1 to jopejoe1 [4094].18:19:03
6 Dec 2024
@cafkafk:fem.gg@cafkafk:fem.gg changed their profile picture.03:43:51
11 Dec 2024
@dminca:matrix.org@dminca:matrix.org left the room.14:19:11
12 Dec 2024
@nam3l33ss:matrix.org·☽•Nameless☆•777 · ± changed their profile picture.14:34:25
13 Dec 2024
@getchoo:matrix.orggetchoo joined the room.09:28:33
@getchoo:matrix.orggetchoo

Hi all

I've come across a fun problem recently. I maintain a set of modules, and previously I had an option in a submodule, but now I've made it a regular (top-level) option. Per usual with changes like this, I wanted to use mkRenamedOptionModule to alias that option submodule option into the top-level option, but I got a nasty surprise with a cannot find attribute <old attribute name> error message

After doing some digging, I'm assuming this is because submodules sort of strip out the regular option data of their inner values, and only expose the fully evaluated configuration. Am I right here? Is there a good way around this?

Here's a minimum repro:

# repro.nix
let
  lib = import <nixpkgs/lib>;
in

lib.evalModules {
  modules = [
    {
      options = {
        # Create a submodule option
        aSubmodule = lib.mkOption {
          type = lib.types.submodule {
            options = {
              # With an inner option
              someSubmoduleOption = lib.mkEnableOption "something";
            };
          };

          default = { };
        };

        # And a top-level option
        aRegularOption = lib.mkEnableOption "something";
      };
    }

    # Alias them
    (lib.mkRenamedOptionModule [ "aSubmodule" "someSubmoduleOption" ] [ "aRegularOption" ])

    {
      # Test the alias
      # `nix eval --file repro.nix config.aRegularOption`
      aSubmodule.someSubmoduleOption = true;
      # ...but instead you get
      # error: evaluation aborted with the following error message: 'cannot find attribute `aSubmodule.someSubmoduleOption''
    }
  ];
}
09:33:27
@getchoo:matrix.orggetchoo *

Hi all

I've come across a fun problem recently. I maintain a set of modules, and previously I had an option in a submodule, but now I've made it a regular (top-level) option. Per usual with changes like this, I wanted to use mkRenamedOptionModule to alias that submodule option into the top-level option, but I got a nasty surprise with a cannot find attribute <old attribute name> error message

After doing some digging, I'm assuming this is because submodules sort of strip out the regular option data of their inner values, and only expose the fully evaluated configuration. Am I right here? Is there a good way around this?

Here's a minimum repro:

# repro.nix
let
  lib = import <nixpkgs/lib>;
in

lib.evalModules {
  modules = [
    {
      options = {
        # Create a submodule option
        aSubmodule = lib.mkOption {
          type = lib.types.submodule {
            options = {
              # With an inner option
              someSubmoduleOption = lib.mkEnableOption "something";
            };
          };

          default = { };
        };

        # And a top-level option
        aRegularOption = lib.mkEnableOption "something";
      };
    }

    # Alias them
    (lib.mkRenamedOptionModule [ "aSubmodule" "someSubmoduleOption" ] [ "aRegularOption" ])

    {
      # Test the alias
      # `nix eval --file repro.nix config.aRegularOption`
      aSubmodule.someSubmoduleOption = true;
      # ...but instead you get
      # error: evaluation aborted with the following error message: 'cannot find attribute `aSubmodule.someSubmoduleOption''
    }
  ];
}
09:33:54

Show newer messages


Back to Room ListRoom Version: 10