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

Create new attributes inside lambda #6

Open
tomberek opened this issue May 26, 2022 · 5 comments
Open

Create new attributes inside lambda #6

tomberek opened this issue May 26, 2022 · 5 comments
Assignees

Comments

@tomberek
Copy link

Situation:

{
  outputs = {...}: {
     a = {};
  };
}

Running nix-editor test.nix outputs.a -v 1 produces:

{
  outputs = {...}: {
     a = 1;
  };
}

as expected. But nix-editor test.nix outputs.a.b -v 1 produces:

{
  outputs = {...}: {
     a = {};
  };
  outputs.a.b = 1;
}

where the attrset was not placed into the function call, but on the outside.

@vlinkz vlinkz self-assigned this May 31, 2022
@vlinkz
Copy link
Collaborator

vlinkz commented Jun 4, 2022

Should be fixed in 6f33bad and 7b0af65, although indentation is still hackish

@vlinkz vlinkz closed this as completed Jun 4, 2022
@tomberek
Copy link
Author

tomberek commented Mar 4, 2023

This still seems to be an issue. Querying for values inside the lambda works as expected, but the traversal for writing doesn't seem to use the same logic.

$ cat test.nix
{
  outputs = inputs: inputs.d {
    a.b = {};
  };
}
$ nix-editor test.nix outputs.a
{ b = { }; }

$ nix-editor test.nix outputs.a.b -v 1
{
  outputs = inputs: inputs.d {
    a.b = {};
  };
  outputs.a.b = 1;
}

$ nix-editor test.nix outputs.a.c -v 1
{
  outputs = inputs: inputs.d {
    a.b = {};
  };
  outputs.a.c = 1;
}

@vlinkz vlinkz reopened this Apr 10, 2023
@tomberek
Copy link
Author

Latest changes (ab2a7e9):

nix-editor test.nix outputs.a.b -v '{v=1;}'
{
  outputs = inputs: inputs.d {
    a.b = {};
  };
  outputs.a.b = {v=1;};
}

and

nix-editor test.nix outputs.a.b -v 'true'
{
  outputs = inputs: inputs.d {
    a.b = {};
    a.b = true;
  };
}

@vlinkz
Copy link
Collaborator

vlinkz commented Apr 10, 2023

Hm yeah, that seems to have to do with the way attribute sets are handled differently than values

@tomberek
Copy link
Author

work-around with an empty flake

nix-editor test.nix outputs.a.b -v 'rec {c=1;}'
{
  outputs = inputs: inputs.d {
    a.b = rec {c=1;};
  };
}

This seems to bypass the "{" detection logic.

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

No branches or pull requests

2 participants