!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1937 Members
Nix programming language362 Servers

Load older messages


SenderMessageTime
8 Jun 2021
@andrew:mtx.rew.laandrewI need to edit "raw" expressions, not evaluated expressions00:16:49
@andrew:mtx.rew.laandrewhmm, I'll look into it, thanks!00:17:04
@aaronjanse:matrix.orgaaronjanseThat'll let you evaluate the current configuration then figure out where each option is set in the code00:17:09
@aaronjanse:matrix.orgaaronjanseThen ofc you could edit those files based on the output of unsafeGetAttrPos00:17:50
@andrew:mtx.rew.laandrew hmm, didn't rnix-lsp already have goodies built in to determine where, for example, pkgs in with pkgs; came from? 00:18:09
@andrew:mtx.rew.laandrew

also I ended up writing a parser for your --dump-ast example... lol

    elems =      elem+
    elem =       token / node

    node =       name ws numrange ws lbracket ws elems rbracket ws
    token =      name lpar quoted rpar ws numrange ws

    name =       ~r"[A-Z]+(?:_[A-Z]+)*"
    numrange =  ~r"[0-9]+\.\.[0-9]+"

    lpar =       "("
    rpar =       ")"
    lbracket =   "{"
    rbracket =   "}"
    ws =         ~r"\s*"

    quoted =     ~r'"[^\"]+"'
00:19:04
@andrew:mtx.rew.laandrewprobably not the best way of going about it00:19:15
@aaronjanse:matrix.orgaaronjanseAhaha00:19:28
@aaronjanse:matrix.orgaaronjanseOh to clarify, I didn't write rnix-parser. Credit goes to @jd91mZM2 for that00:20:00
@andrew:mtx.rew.laandrewah ok00:20:10
@andrew:mtx.rew.laandrew unsafeGetAttrPos seems very useful 00:20:19
@aaronjanse:matrix.orgaaronjanse
In reply to @andrew:mtx.rew.la
hmm, didn't rnix-lsp already have goodies built in to determine where, for example, pkgs in with pkgs; came from?
Are you sure you need to know where it came from?
00:20:23
@aaronjanse:matrix.orgaaronjanseIt might make sense to start off trying to do as much as possible with unsafeGetAttrPos00:20:53
@aaronjanse:matrix.orgaaronjanseHuh or maybe start off by just visualizing the output of pkgs.lib.nixosSystem (which should list the values of all nixos options)00:21:55
@aaronjanse:matrix.orgaaronjanse* Huh or maybe start off by just visualizing the output of pkgs.lib.nixosSystem { ... } (which should list the values of all nixos options for your system)00:22:17
@andrew:mtx.rew.laandrew I'm probably getting ahead of myself, but it would be useful for users to be able to modify things like let-in statements. E.g. observe that python3Packages comes from a let-in statement, then examine the expression defining python3Packages, examine which options depend on it, then understand properly whether python3Packages should be upgraded from 37 to 39 00:22:36
@aaronjanse:matrix.orgaaronjanseHmm, would they do this in an IDE like vscode, or would they use something like the UI you send a screenshot of above?00:25:29
@andrew:mtx.rew.laandrewIdeally this works for noobs, but has the capability for more advanced changes00:25:57
@aaronjanse:matrix.orgaaronjanseIf the latter, maybe you could combine {nix-instantiate with unsafeGetAttrPos} with rnix-lsp00:26:21
@aaronjanse:matrix.orgaaronjanseThat way you know the fully evaluated system then can do insights (using rnix-lsp) on the code that nix-instantiate points you to00:26:58
@andrew:mtx.rew.laandrew what does unsafeGetAttrPos provide which I can't get from rnix-lsp? 00:27:20
@aaronjanse:matrix.orgaaronjanseOh it just lets you do operations on evaluated expressions. And I assume you'll want to evaluate the configuration.nix to figure out what the current nixos option values are and where they're defined?00:28:30
@andrew:mtx.rew.laandrewwell I'm not sure I ever want the evaluated option values. Just a form representation of the "raw" option00:29:09
@aaronjanse:matrix.orgaaronjanseOh got it00:29:32
@andrew:mtx.rew.laandrewalthough seeing the incrementally evaluated form of an option could be useful while editing00:30:01
@aaronjanse:matrix.orgaaronjanseI guess you'd want the value to know whether the "enabled" checkbox should be checked for a given option00:31:29
@aaronjanse:matrix.orgaaronjanseBut you've thought through this more than I have00:31:39
@aaronjanse:matrix.orgaaronjanse* But you've thought this through more than I have00:34:03
@andrew:mtx.rew.laandrew Right now I just record the current system state in json via nix-build /etc/nixos/nixpkgs/nixos/release.nix -A options -o release_out and nixos-option, however because this requires evaluating the expression it works for things like checkboxes which generally are defined with basic expressions (true / false rather than a function). 00:35:17
@andrew:mtx.rew.laandrewmore complicated solutions come in when it's defined by a variable or an attribute within a variable (excuse my likely wrong terminology)00:36:07

Show newer messages


Back to Room ListRoom Version: 6