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

hdn does not handle builtins.attrValues home.packages expressions #20

Open
Bujiraso opened this issue Jun 20, 2023 · 2 comments
Open

hdn does not handle builtins.attrValues home.packages expressions #20

Bujiraso opened this issue Jun 20, 2023 · 2 comments

Comments

@Bujiraso
Copy link

Bug

If I have the following valid Nix config:

  home.packages =   builtins.attrValues {
      inherit (pkgs)
         gnome-2048
         ;
      };

hdn can't figure out how to read the package list.

$ hdn remove gnome-2048
error: could not update home.packages attribute in home.nix
caused by: could not read values of home.packages attribute in home.nix
caused by: Error with array

Suggested Fixes

Either or both of:

  1. Ensure these sorts of expressions can be read
  2. Handle a # hdn anchor override that I can put into my file to denote where hdn can pretend a [ list ] begins, ignoring surrounding syntax

Context

The impl might be a bit involved on this one, but I'm doing it for a reason (it's not academic).
I do the following, basically:

  home.packages = [
        pkgs.python310Packages.autopep8
      ] ++ builtins.attrValues {
      inherit (pkgs)
          # many
          # Many
          # MANY
          # pkgs.packages ;-) 
          ;
      };

That allows me to not have to put pkgs on everything, yet still also use the python310Packages.autopep8 which does not work if I just bake it in the list.

error: syntax error, unexpected '.'

       at /home/bujiraso/.config/home-manager/home.nix:181:28:

          181|           python310Packages.autopep8
             |                            ^
(use '--show-trace' to show detailed location information)

Perhaps a bug is required for home-manager, too, on that one, but I haven't gotten around to it.

@seasonedfish
Copy link
Owner

seasonedfish commented Jun 20, 2023

Please help me understand the purpose of using builtins.attrValues; I'm not sure I understand the context section.

Why not use:

home.packages = with pkgs; [
    python310Packages.autopep8
    # other packages, `pkgs` prefix is not necessary
];

This works on my installation, with editing the file manually and with hdn.

@Bujiraso
Copy link
Author

Sure.
Check the tip at the bottom of https://nix.dev/recipes/best-practices#with-scopes

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