!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1943 Members
Nix programming language359 Servers

Load older messages


SenderMessageTime
17 Jun 2021
@aaronjanse:matrix.orgaaronjanseAh got it21:33:15
@infinisil:matrix.orginfinisilMaybe Nix needs a separate call stack for user errors21:34:18
@infinisil:matrix.orginfinisil Something like builtins.addErrorContext, but which is shown by default in case of throws and which isn't used by the language internals 21:34:45
@aaronjanse:matrix.orgaaronjanseOr perhaps Nix could default to showing explicitly-added context when there is a error21:38:54
@infinisil:matrix.orginfinisilHmm that sounds interesting21:40:29
@infinisil:matrix.orginfinisilI wonder how the default errors would look then21:40:37
@aaronjanse:matrix.orgaaronjanseI assume it would be similar to how they are now, except for a few added lines when an explicit addErrorContext is used22:46:38
@aaronjanse:matrix.orgaaronjanseIt seems helpful, since iirc nixpkgs uses it for some user-facing errors yet it's only visible in --show-trace, which has a lot more information than the user needs22:47:45
18 Jun 2021
@jtojnar:matrix.orgJan Tojnar How does literalExample even work? 09:30:59
@jtojnar:matrix.orgJan Tojnar I mean how is ${pkgs.foo} kept literally instead of being interpolated? 09:31:55
@sternenseemann:systemli.orgsterni Jan Tojnar: it doesn't, you still need to escape stuff 09:36:11
@jtojnar:matrix.orgJan TojnarWell, it seems to not be interpolated in the manual09:36:30
@sternenseemann:systemli.orgsterniI think it just causes the documentation generator to wrap it as code instead of trying to render the value09:36:36
@jtojnar:matrix.orgJan Tojnarso something must be reversing the interpolation09:36:43
@jtojnar:matrix.orgJan Tojnarbut I have been so far unable to find the code resoponsible09:37:02
@sternenseemann:systemli.orgsterni Jan Tojnar: what are you referring to? I've never seen that 09:37:33
@jtojnar:matrix.orgJan Tojnar sterni (he/him): https://github.com/NixOS/nixpkgs/pull/127085/files#r652869810 09:38:21
@jtojnar:matrix.orgJan TojnarI have seen that few times09:38:28
@jtojnar:matrix.orgJan Tojnar It definitely is interpolated when I view the value in the repl: (nixos {}).options.xdg.portal.wlr.settings.example 09:38:55
@jtojnar:matrix.orgJan Tojnarbut in the manual, it is shown verbatim09:39:43
@jtojnar:matrix.orgJan Tojnarthe optionsXML here is already uniterpolated https://github.com/NixOS/nixpkgs/blob/dc24c0f7148db1fe36afd1df81fbb4bbc4e9941e/nixos/lib/make-options-doc/default.nix#L17909:41:37
@jtojnar:matrix.orgJan Tojnar

Trying the following, it looks like the value is already passed uninterpolated to nixosOptionsDoc

--- a/lib/options.nix
+++ b/lib/options.nix
@@ -175,7 +175,10 @@ rec {
       let
         docOption = rec {
           loc = opt.loc;
-          name = showOption opt.loc;
+          name =
+            let
+              name = showOption opt.loc;
+            in if name == "xdg.portal.wlr.settings" then builtins.trace (opt.example).text name else name;
           description = opt.description or (lib.warn "Option `${name}' has no description." "This option has no description.");
           declarations = filter (x: x != unknownModule) opt.declarations;
           internal = opt.internal or false;
09:56:35
@jtojnar:matrix.orgJan TojnarOh, here it is https://github.com/NixOS/nixpkgs/blob/17bcbee9fa5aabb3e0b4015b71eb6578da2d6fe3/nixos/modules/misc/documentation.nix#L21-L4010:20:11
@sternenseemann:systemli.orgsterniohhhhhh10:20:52
@sternenseemann:systemli.orgsterni that is wild 10:20:59
@sternenseemann:systemli.orgsterniI wonder how hard that is on evaluation time of the manual?10:22:45
@lunik1:lunik.onelunik1
In reply to @buckley310:matrix.org

a module can be

{ lib, ... }:{ config = lib.mkMerge [ ]; }
I did this but I'm not sure how to access the resulting merged config as an attribute set?
15:34:45
@aaronjanse:matrix.orgaaronjanse
In reply to @jtojnar:matrix.org
I mean how is ${pkgs.foo} kept literally instead of being interpolated?
Maybe it uses unsafeGetAttrPos?
16:01:02
@sternenseemann:systemli.orgsterni aaronjanse: no, it passes a package set of fake derivations to the modules where outPath = "${attr.path}", it seems 16:19:51
@sternenseemann:systemli.orgsternisee the snippet Jan linked16:19:55

Show newer messages


Back to Room ListRoom Version: 6