Home-manager submodule syntax?

Hi,

I’m not sure if the term is correct but I have the following configuration and I would like to group all related packages for ruby.

Hence I wonder if there is a syntax that could help me summarize all gems.

packages = with pkgs; [
  ...
  ruby
  ruby.gems.a
  ruby.gems.b
];

It’s conventional for programming language packages to have a withPackages function, so I’d recommend something like this:

let
  ruby = pkgs.ruby.withPackages (ps: with ps; [
    a
    b
  ]);
in
{
  home.packages = [ ruby ];
}

https://nixos.org/manual/nixpkgs/stable/#load-ruby-environment-from-.nix-expression

1 Like

At last, I found this way that I tend to prefer.

Please tell me if this is not recommended

#home.nix

packages = let

aspellDicts = with pkgs.aspellDicts; [fr en es];
gnome = with pkgs.gnome; [eog nautilus];

in with pkgs; [
  aspell
]
++ aspellDicts
++ gnome;

EDIT: there is this also this one, that I like better

#home.nix

packages = with pkgs; [
  aspell
]
++ (with pkgs.aspellDicts; [fr en es])
++ (with pkgs.gnome; [eog nautilus]);