!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

82 Members
21 Servers

Load older messages


SenderMessageTime
17 Apr 2024
@ibizaman:matrix.orgibizaman
In reply to @infinidoge:matrix.org
I more so mean ad-hoc testing of random module things, as opposed to proper module tests, however that is something I should also do
Ah I see. The only other example I can offer is related to testing functions like here. That being said, it’s also written tests. I can’t think of an intermediate way between this and load in the repl, even outside of nix modules.
14:20:17
@infinidoge:matrix.org@infinidoge:matrix.orgI think me using the word 'testing' is too loaded of a term lol14:23:04
@infinidoge:matrix.org@infinidoge:matrix.orgI just mean messing around like you would with a repl :)14:23:28
@infinidoge:matrix.org@infinidoge:matrix.orgIt's just that defining and working with modules in the repl gets a bit annoying so I usually shove it in my NixOS configuration and let that eval the module14:24:04
@ibizaman:matrix.orgibizaman Aaah yes. Got it. I agree I missed something to do that a few times. My only way is like you said, to use the module somewhere else and run nix build on it or something 14:34:04
@ibizaman:matrix.orgibizaman * Aaah yes. Got it. I agree. I missed something to do that a few times. My only way is like you said, to use the module somewhere else and run nix build on it or something 14:34:28
@JoelMcCracken:matrix.orgJoelMcCracken joined the room.16:28:10
@djacu:matrix.org@djacu:matrix.org
In reply to @nbp:mozilla.org
djacu: That might be one of the most in-depth module presentation I've seen which does not present mkIf.
hah thanks! If I had more time, mkIf would have probably been the next topic.
Also link to all the lessons if you want to share -> https://nixos-modules.nix.みんな/
19:40:02
18 Apr 2024
@nbp:mozilla.orgnbp I guess, I might be completely biais into introducing mkIf early, as it feels like a must have for implementing modules in NixOS, but I think your plan might actually make more sense from a user point of view and might be better to target non-developer, who might appreciate the lack of conditional. 00:44:32
@nbp:mozilla.orgnbp * I guess, I might be completely biais into introducing mkIf early, as it feels like a must have for implementing modules in NixOS. On the other hand I think your plan might actually make more sense from a user point of view and might be better to target non-developer, who might appreciate the lack of conditional. 00:45:09
@djacu:matrix.org@djacu:matrix.org
In reply to @nbp:mozilla.org
I guess, I might be completely biais into introducing mkIf early, as it feels like a must have for implementing modules in NixOS. On the other hand I think your plan might actually make more sense from a user point of view and might be better to target non-developer, who might appreciate the lack of conditional.

I'd say everything I have in the "Getting Started" section must come first as it lays the foundation for how a module can be created. Anything after that is fair game.

Does documentation need to come so early? Nah but it's a quick one and a good thing to reinforce that people should document their modules well.

I had the types section in there because I wanted to get to submodules as it is the most ubiquitous and a very powerful type.

mkIf could probably go next; it was in the Future section. I was putting lessons there that I wanted to talk about soon.

02:05:29
@djacu:matrix.org@djacu:matrix.org The only issue I see with introducing mkIf early is that there needs to be a sufficient foundation so that you don't introduce anything extra. All the lessons are in an order such that only 1 or 2 new things are introduced. My hope is that this keeps the reader focused on what is currently trying to be taught and they don't have to juggle any extra information in their head. 02:07:23
19 Apr 2024
@hexa:lossy.networkhexa infinisil: https://github.com/NixOS/nixpkgs/pull/305334#issuecomment-2067069655 can you answer this? 18:44:37
@infinisil:matrix.orginfinisil
In reply to @hexa:lossy.network
infinisil: https://github.com/NixOS/nixpkgs/pull/305334#issuecomment-2067069655 can you answer this?
☑️
18:50:31
@hexa:lossy.networkhexathansk!18:50:36
@hexa:lossy.networkhexa * thanks!18:50:41
22 Apr 2024
@djacu:matrix.org@djacu:matrix.org

Is there a way I can circumvent the The option <option> is used but not defined error? I am playing around with a silly idea of nix modules to html. You can see the code for the <a> tag module here: https://github.com/djacu/nix2html/blob/main/a.nix

Two attributes I've implemented so far are download and href. If you run the run.sh script, you get an output that should look like this "<a download=new-filename href=#top></a>". But I don't want a user to have to set the download or href attributes every time.

Trying to think of a good solution but coming up empty. Any ideas?

06:19:34
@infinidoge:matrix.org@infinidoge:matrix.orgYou probably want either the anything option type, or to define your own types08:29:40
@nbp:mozilla.orgnbpWhy using submodules if you have only a single instance of each attribute?10:28:26
@nbp:mozilla.orgnbpYou can declare options to be unused: https://github.com/NixOS/nixpkgs/blob/8e54038847aa80ee2b1ffa9e313b0ab918f1903c/lib/options.nix#L228-L244 But I do not think this answer your problem. One example of usage of it is from this PR: https://github.com/NixOS/nixpkgs/pull/152785/files10:36:38
@nbp:mozilla.orgnbp Maybe you can use the type nullOr and have a default value of null. 10:37:54
@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

Show newer messages


Back to Room ListRoom Version: 10