!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

82 Members
21 Servers

Load older messages


SenderMessageTime
22 Apr 2024
@nbp:mozilla.orgnbp mkDefault should be delayed, like mkIf, so mapAttrs (name: mkDefault) should be replaceable by mkDefault.
https://github.com/NixOS/nixpkgs/blob/master/lib/modules.nix#L882
12:24:56
@infinisil:matrix.orginfinisil nbp Nah that's not the same. The former will merge attrs with the default priority, while the latter will override it completely 12:27:38
@djacu:matrix.org@djacu:matrix.org

nbp: The reason for using submodules is because html attributes can be used in different html elements. So I want a reusable piece of code. The other reason is that I can define how html attributes are called in a standard way using the _out option I defined so everything rolls up nicely using the same logic. No custom logical needed for each html element.

I think I got something working using nullOr with the options inside the html attribute modules. So thanks everyone for your ideas.

15:45:13
@djacu:matrix.org@djacu:matrix.org

Related but different question. I had trouble accessing the isDefined attribute of a submodule option.

For example, I define an option foo whos type is submodule, and with that I define options bar and baz.

At the top level, I can access options.foo.isDefined, but I cannot access options.foo.bar.isDefined. I tried digging around in the options attrset but I couldn't find it. Are the options of a "child" submodule option available to the "parent"?

15:49:55
@nbp:mozilla.orgnbp isDefined should not be used most of the time, as this is kind of an internal aspect, and it can only be used within the module itself.
Adding an options argument attribute to the submodule would let you query the option tree of the submodule.
16:06:40
@djacu:matrix.org@djacu:matrix.org
In reply to @nbp:mozilla.org
isDefined should not be used most of the time, as this is kind of an internal aspect, and it can only be used within the module itself.
Adding an options argument attribute to the submodule would let you query the option tree of the submodule.
Yeah that's how I was doing it; defining the option argument in the submodule.
16:07:56
@nbp:mozilla.orgnbpThere is no way to get the option declaration out of a submodule, at least not without changing the submodule type.16:09:35
23 Apr 2024
@djacu:matrix.org@djacu:matrix.org

Alright I've done something extremely silly and cursed.

https://github.com/djacu/nix2html
nix2html using nixos modules

also featuring the new attrTag type
:D
https://github.com/djacu/nix2html/blob/main/modules/elementChildren.nix

It's barely got any html elements or attributes so far so don't expect the world.

05:15:23
@infinidoge:matrix.org@infinidoge:matrix.orgFinally, we can subsume the entire internet into pure Nix05:16:01
@nbp:mozilla.orgnbp djacu: Ok, I am going to be pedantic :P
listOf is not modular, thus someone who might want to extend an existing "page" would have to completely replace the template describe in one of the imported modules.
At first I will suggest using the DOM names such as firstChild, nextSibling to describe to tree of DOM elements.
09:47:16
@nbp:mozilla.orgnbp Also, one might want to use shortcuts, such as in JS with getElementById("id"), we could imagine an types.attrsOf types.submodule dom.element; where the attribute name corresponds to the id, and where the definitions are forwarded to every submodule as long as the id attribtue is equal. 09:49:30
@nbp:mozilla.orgnbp This would add tons of mkIf … but only the one with the matching identifier would be extended with the module system. 09:50:34
@nbp:mozilla.orgnbp * djacu: Ok, I am going to be pedantic :P
listOf is not modular, thus someone who might want to extend an existing "page" would have to completely replace the template describe in one of the imported modules.
At first I will suggest using the DOM names such as firstChild, nextSibling to describe the tree of DOM elements.
10:48:37
@djacu:matrix.org@djacu:matrix.org nice try nbp
you almost got me thinking seriously about about my meme project ;P
13:38:06
24 Apr 2024
@shalokshalom:kde.org@shalokshalom:kde.org joined the room.14:38:14
@redblueflame:matrix.orgredblueflame joined the room.14:40:57
@ktemkin:katesiria.org@ktemkin:katesiria.org joined the room.15:13:08
@ckie:ckie.devmei 🌒& joined the room.16:07:44
@ckie:ckie.devmei 🌒& djacu: your nix2html reminds me of my html.nix which takes a different approach 16:09:46
@ckie:ckie.devmei 🌒&it oculd be changed to output config values!16:10:04
@djacu:matrix.org@djacu:matrix.orgwoah this is neat!16:13:41
@nbp:mozilla.orgnbpThe functor idea is indeed really neat, and someday someone would figure a way to make an HTML template tool based on Nix.16:35:04
@nbp:mozilla.orgnbpI myself tried it without being convinced by my own monster :P16:35:05
@infinidoge:matrix.org@infinidoge:matrix.orgThe functor idea is a really neat use of them16:38:39
@infinidoge:matrix.org@infinidoge:matrix.orgI wish they were better documented because they are a really cool and interesting feature of the language16:38:55
@shalokshalom:kde.org@shalokshalom:kde.org We have functors :O 20:17:47
@2clayzx:matrix.org2clayzx joined the room.20:21:56
@nuko:shimeji.cafe@nuko:shimeji.cafe joined the room.21:01:45
@pxc:matrix.orgpxc

are there any libraries for writing modules designed to work across module systems? Is there any kind of way to introspect what kind of module system is consuming a module?

i.e., I'd like to be able to do like mkIf <this is being used in Nix-Darwin> ... and mkIf <this is being used in Home Manager ..., etc.

21:38:48
@pxc:matrix.orgpxc

(obviously, where interfaces are compatible, you can have some modules imported in various different module systems and just werk; I do this with nix.settings stuff in my personal Nix configs for HM, NixOS, and Nix-Darwin)

I'm wondering what projects have explored/attempted this the most

21:39:54

Show newer messages


Back to Room ListRoom Version: 10