Help with imports in home-manager module

I am making some change to the eza home-manager module, and need to add a mkRemovedOptionModule to the imports.

Right now it looks like this

  imports = let
    msg =
      "'programs.eza.enableAliases' has been deprecated and replaced with integrations options per shell, ex. 'programs.eza.enableBashIntegration'";
    mkRenamed = opt:
      mkRenamedOptionModule [ "programs" "exa" opt ] [ "programs" "eza" opt ];
  in [
    (map mkRenamed [ "enable" "extraOptions" "icons" "git" ])
    (mkRemovedOptionModule [ "programs" "eza" "enableAliases" ] msg)
  ];

which throws this error:

       error: Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions:
       - In `/nix/store/yzhid8l18qwkvw1msnasr114ws0afkyf-source/modules/programs/eza.nix':
           [
             <function, args: {config, options}>
             <function, args: {config, options}>
             <function, args: {config, options}>
             <function, args: {config, options}>
           ...

I’m not sure what the right syntax is to fix this. I’d appreciate any help.

For context, it was originally this:

  imports = let
    mkRenamed = opt:
      mkRenamedOptionModule [ "programs" "exa" opt ] [ "programs" "eza" opt ];
  in map mkRenamed [ "enable" "enableAliases" "extraOptions" "icons" "git" ];

I don’t think you need to declare the alias at all anymore because the eza package provides its own link for exa.

❯ find /nix/store -path "*bin/exa"
/nix/store/ldc1sk8m7h4cy0jd4yfdwx1f3j2415aw-eza-0.18.5/bin/exa
/nix/store/ksmafivbw3fss7j01cbbg6bmwnbcrhrp-eza-0.18.2/bin/exa
/nix/store/jrsbcax6mphw3v2am3kbkmcak8sb8k98-system-path/bin/exa
/nix/store/g0p9qfjl5xkjgp01kh2r271vnakqk1ng-system-path/bin/exa
/nix/store/zy0p1v8x6fm4yvak20zpisl912h1gb9m-system-path/bin/exa
/nix/store/6x3nccddfw10mwiifjkin0c2fkx7p1dx-system-path/bin/exa

❯ exa -l /nix/store/ldc1sk8m7h4cy0jd4yfdwx1f3j2415aw-eza-0.18.5/bin/exa
lrwxrwxrwx - root 31 Dec  1969 /nix/store/ldc1sk8m7h4cy0jd4yfdwx1f3j2415aw-eza-0.18.5/bin/exa -> eza

❯ exa -l /nix/store/ksmafivbw3fss7j01cbbg6bmwnbcrhrp-eza-0.18.2/bin/exa
lrwxrwxrwx - root 31 Dec  1969 /nix/store/ksmafivbw3fss7j01cbbg6bmwnbcrhrp-eza-0.18.2/bin/exa -> eza

You can run either exa or eza according to your preference, and it will use eza automatically without needing to announce an alias in your config.

This code is actually referring to these aliases:

    aliases = {
      ls = "eza";
      ll = "eza -l";
      la = "eza -a";
      lt = "eza --tree";
      lla = "eza -la";
    };

Not the alias between eza and exa. The import is to let users who have exa enabled in home-manager know they should switch to eza.

The full code can be found here

Oh gotcha, my mistake–I was misunderstanding the purpose of the code altogether. Sorry I was not able to be more helpful, that syntax is a bit over my head I’m afraid.

1 Like

All good, I appreciate it still!

1 Like

I think you want:

 imports = let
    msg =
      "'programs.eza.enableAliases' has been deprecated and replaced with integrations options per shell, ex. 'programs.eza.enableBashIntegration'";
    mkRenamed = opt:
      mkRenamedOptionModule [ "programs" "exa" opt ] [ "programs" "eza" opt ];
  in 
    (map mkRenamed [ "enable" "extraOptions" "icons" "git" ])
    ++ [
    (mkRemovedOptionModule [ "programs" "eza" "enableAliases" ] msg)
  ];

this worked, thank you!