Sender | Message | Time |
---|---|---|
29 Jan 2024 | ||
@djacu:matrix.org | * Hey all I am creating some new modules and want to generate documentation for them but I get errors like this. This is because I create the option | 02:01:09 |
@djacu:matrix.org | * Hey all I am creating some new modules and want to generate documentation for them but I get errors like this. This is because I create the option | 02:01:14 |
Sam Lehman joined the room. | 11:08:22 | |
infinisil | djacu That means you're evaluating the option somehow, but generating docs shouldn't require that | 12:11:50 |
@djacu:matrix.org | In reply to @infinisil:matrix.orgNot sure what I changed but it's working now... Maybe I was passing the whole output of evalModules to optionAttrSetToDocList instead of just the options value. | 20:04:11 |
31 Jan 2024 | ||
@djacu:matrix.org | Is it possible to override the parameters of an option after creation? If that isn't clear let me explain my situation. I have a module that defines several options that are generic definitions and is imported by several other modules. E.g. I have a format.nix that defines content and order that are both visible to the user. Now in some cases, I want to hide order . So my thought was that I could override the visibility in the modules that import format.nix. But I can't seem to figure out how to do that. Possible? | 05:38:47 |
@djacu:matrix.org | * Is it possible to override the parameters of an option after creation? If that isn't clear let me explain my situation. I have a module that defines several options that are generic definitions and is imported by several other modules. E.g. I have a format.nix that defines content and order that are both visible to the user. In certain cases where I import format.nix into another module, I want to hide order . So my thought was that I could override the visibility in those modules. But I can't seem to figure out how to do that. Possible? | 05:42:19 |
infinisil | djacu: Yeah that's not possible, probably best to have a function with that parameter that returns a new option, like lib.mkPackageOption | 16:03:53 |
@djacu:matrix.org | In reply to @infinisil:matrix.orgYeah I figured. Thank infinisil ! | 17:37:10 |
1 Feb 2024 | ||
@djacu:matrix.org | Hi all. I have a question about merging user defined options with default options. I am trying to design a module with the following attributes.
I have a working example below. Have I missed something or is this not possible? Thanks
| 19:45:53 |
guangtao | is it possible to solve your problem through the apply option? I mean you can set the defualt to be {}, use
| 20:12:04 |
guangtao | * is it possible to solve your problem through the apply option? I mean you can set the defualt to be {}, use
| 20:12:13 |
guangtao | * is it possible to solve your problem through the apply option? I mean you can set the defualt to be {}, use
| 20:12:42 |
guangtao | Yeah, if I understand your problem correctly. | 20:13:50 |
infinisil | Oh don't use apply , that's generally an anti-pattern | 20:14:12 |
infinisil | I'll take a closer look at the code | 20:14:22 |
@djacu:matrix.org | apply also generally wouldn't work because this module wouldn't necessarily be at the top level. I mean it could work but would be messy. Also, it breaks out of the module ecosystem and isn't very user friendly. | 20:16:08 |
infinisil | Oh so it doesn't work because to the module system, all definitions have the same priority | 20:16:57 |
infinisil | You set them both with out = <attrset> , no mkDefault or so | 20:17:16 |
infinisil | But out = mkDefault config.default wouldn't work because then the entire attribute set gets overridden by the users one, therefore not using any defaults | 20:18:00 |
infinisil | What you need is out = mapAttrs (name: mkDefault) config.default | 20:18:26 |
@djacu:matrix.org | I'm a little lost. Which line would I inject this:
Also doesn't | 20:21:09 |
infinisil | The line out = config.default; | 20:21:48 |
@djacu:matrix.org | * I'm a little lost. Which line would I inject this:
Also isn't | 20:22:09 |
infinisil | Currying function arguments :) | 20:22:12 |
guangtao | that makes sense; set all attrts of default to having order. | 20:23:54 |
@djacu:matrix.org | What is this deep magic!? It works | 20:26:24 |
@djacu:matrix.org | Oh did you just apply mkDefault to all the values set in default ?? | 20:27:02 |
infinisil | Indeed :) | 20:27:18 |
@djacu:matrix.org | Cool man. Thanks! What is really nice is that I can use So this partially makes sense. But why didn't having a user config with Without your fix, does the config.default have... no priority? What was the failure mechanism before the fix? | 20:31:17 |