| 8 Jun 2021 |
andrew | I need to edit "raw" expressions, not evaluated expressions | 00:16:49 |
andrew | hmm, I'll look into it, thanks! | 00:17:04 |
aaronjanse | That'll let you evaluate the current configuration then figure out where each option is set in the code | 00:17:09 |
aaronjanse | Then ofc you could edit those files based on the output of unsafeGetAttrPos | 00:17:50 |
andrew | 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 | 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 | probably not the best way of going about it | 00:19:15 |
aaronjanse | Ahaha | 00:19:28 |
aaronjanse | Oh to clarify, I didn't write rnix-parser. Credit goes to @jd91mZM2 for that | 00:20:00 |
andrew | ah ok | 00:20:10 |
andrew | unsafeGetAttrPos seems very useful | 00:20:19 |
aaronjanse | 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 | It might make sense to start off trying to do as much as possible with unsafeGetAttrPos | 00:20:53 |
aaronjanse | Huh 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 | * 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 | 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 | Hmm, 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 | Ideally this works for noobs, but has the capability for more advanced changes | 00:25:57 |
aaronjanse | If the latter, maybe you could combine {nix-instantiate with unsafeGetAttrPos} with rnix-lsp | 00:26:21 |
aaronjanse | That way you know the fully evaluated system then can do insights (using rnix-lsp) on the code that nix-instantiate points you to | 00:26:58 |
andrew | what does unsafeGetAttrPos provide which I can't get from rnix-lsp? | 00:27:20 |
aaronjanse | Oh 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 | well I'm not sure I ever want the evaluated option values. Just a form representation of the "raw" option | 00:29:09 |
aaronjanse | Oh got it | 00:29:32 |
andrew | although seeing the incrementally evaluated form of an option could be useful while editing | 00:30:01 |
aaronjanse | I guess you'd want the value to know whether the "enabled" checkbox should be checked for a given option | 00:31:29 |
aaronjanse | But you've thought through this more than I have | 00:31:39 |
aaronjanse | * But you've thought this through more than I have | 00:34:03 |
andrew | 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 | more 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 |