Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Extraction #98

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

Conversation

adrianparvino
Copy link
Collaborator

No description provided.

@lapp0
Copy link
Collaborator

lapp0 commented Sep 9, 2021

What work remains here?

@lapp0
Copy link
Collaborator

lapp0 commented Sep 10, 2021

I think this error may be filed under this PR. The error is due to a module being imported by configuration.nix, but not all necessary arguments are passed to it. Let me know if you think this should be handled in a separate PR though.

Traceback (most recent call last):
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/bin/.nix-gui-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/lib/python3.9/site-packages/nixui/main.py", line 68, in main
    run_program()
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/lib/python3.9/site-packages/nixui/main.py", line 46, in run_program
    statemodel = state_model.StateModel()
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/lib/python3.9/site-packages/nixui/state_model.py", line 27, in __init__
    self.option_tree = api.get_option_tree()
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/lib/python3.9/site-packages/nixui/options/api.py", line 19, in get_option_tree
    parser.get_all_option_values(os.environ['CONFIGURATION_PATH'])
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/lib/python3.9/site-packages/nixui/options/parser.py", line 85, in get_all_option_values
    result = get_all_option_values(import_path.eval_path())
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/lib/python3.9/site-packages/nixui/options/parser.py", line 64, in get_all_option_values
    for attr_loc, (key_node, value_node) in get_key_value_nodes(module_path, tree).items():
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/lib/python3.9/site-packages/nixui/options/parser.py", line 111, in get_key_value_nodes
    for attribute, attr_data in nix_eval.get_modules_defined_attrs(module_path).items():
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/lib/python3.9/site-packages/nixui/utils/cache.py", line 74, in wrapper
    res = function(*args, **kwargs)
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/lib/python3.9/site-packages/nixui/options/nix_eval.py", line 126, in get_modules_defined_attrs
    leaves = nix_instantiate_eval(
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/lib/python3.9/site-packages/nixui/options/nix_eval.py", line 50, in nix_instantiate_eval
    return nix_instantiate_eval(expr, strict, show_trace=True)
  File "/nix/store/xx3gpjairbyhqf3i0g76jyrf722r30pr-python3.9-nix-gui-0.1.0/lib/python3.9/site-packages/nixui/options/nix_eval.py", line 56, in nix_instantiate_eval
    raise NixEvalError(err_str)
nixui.options.nix_eval.NixEvalError: NixEvalError("""
error: anonymous function at /etc/nixos/system-specific.nix:1:1 called without required argument 'hardware'

       at «string»:3:12:

            2| let
            3|   config = import /etc/nixos/./system-specific.nix {config = {}; pkgs = import <nixpkgs> {}; lib = import <nixpkgs/lib>; modulesPath = /etc/nixos/.;};
             |            ^
            4|   closure = builtins.tail (builtins.genericClosure {

       … while evaluating the attribute 'value'

       at «string»:5:54:

            4|   closure = builtins.tail (builtins.genericClosure {
            5|     startSet = [{ key = builtins.toJSON []; value = {value = config;}; }];
             |                                                      ^
            6|     operator = {key, value}: builtins.filter (x: x != null) (

       … while evaluating 'operator'

       at «string»:6:16:

            5|     startSet = [{ key = builtins.toJSON []; value = {value = config;}; }];
            6|     operator = {key, value}: builtins.filter (x: x != null) (
             |                ^
            7|       if

       … from call site

""")

@lapp0
Copy link
Collaborator

lapp0 commented Sep 24, 2021

Reporting here that #99 doesn't retrieve the position of submodule attributes.

For example, in the sample configuration.nix, fileSystems."/".options is defined on line 159, however only the position of fileSystems returned by get_modules_defined_attrs.

Similarly, the position of users.extraUsers is included (and I think it's fine to include the position of the submodules themselves), however the position of users.extraUsers.isNormalUser isn't.

Perhaps this should be resolved in this PR as well? I've written a test case that can easily be turned on to validate recursion into submodules: https://github.com/nix-gui/nix-gui/pull/107/files#diff-f42c1d3da4448ee60fd93e423d7730962edbdba0e529432f7f99cdb960972a34R77-R104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants