[Nix-dev] trace an option(s) definition to the `filename` + `loc`

Joachim Schiele js at lastlog.de
Fri Mar 24 13:13:12 CET 2017


hello,

i would like to print the filename + loc of configuration.nix port
assignment in port-module.nix 'throw' line. how to get this information
from nix?

* in nixpkgs/lib/types.nix i see `loc` information for the various merge
functions.
* lib nixpkgs/lib/debug.nix i found traceCall/traceCall2/traceCall3 but
no examples of those in usage

IIRC there was a function which traces back the value to the filename +
loc but i can't find it anymore.

anyone knows how to get these values?






# configuration.nix
  services.portBB = {
    "lastlog.de" = {
      "/status" = {
        port = 8000;
        path = "/status";
      };
    };
  };

# port-module.nix:

    services.portBB = mkOption {
      type = types.attrsOf (types.attrsOf (types.submodule {
        options.port = mkOption {
          type = types.int;
          apply = p: if p == 8000 then throw "Port ${toString p} may not
be used!" else p;
        };

        options.path = mkOption {
          type = types.path;
        };
      }));
    };



More information about the nix-dev mailing list