Looking for feedback on splitting home-manager configuration

Hi,

I wanted to get feedback on how people factor package configurations out of home-manager home.nix. After lots of reading and trial-and-error, I got something working that feels reasonably maintainable, but as someone new to nix I suspect I’m missing some library or convention that would make it even simpler. I’d love to get feedback and suggestions for making it more idiomatic and using “best practices”.

Goals (basically: encapsulation and DRY)

  • package definitions together: source, aliases, configuration, etc.
  • be able to re-use them in different configurations and shells,
    parameterizing if necessary
# config/git.nix
{ pkgs, gituser, gitemail, ... }: {
  packages = [pkgs.git];
  programs = {
    git = {
      enable = true;
      delta = {
        enable = true;
        options = {line-numbers = true;};
      };
      userName = gituser;
      userEmail = gitemail;
    };
  };
  env = {};
  aliases = {
    gba = "git branch --all";
  };
}
# config/bat.nix
{pkgs, ...}: {
  packages = [pkgs.bat];
  programs = {
    bat = {
      enable = true;
      config = {
        pager = "less -FR";
      };
    };
  };
  env = {};
  aliases = {};
}
# home-manager/home.nix  (abbreviated)

{ config, pkgs, inputs, ... }
let 
  username = "me";
  gituser = "me";
  gitemail = "me@example.com";
in let
  mypackages = [
    (import ../config/bat.nix { inherit pkgs; })
    (import ../config/git.nix { inherit pkgs gituser gitemail; })
    # ... snip
  ];
in {
  home.user = username;
  home.packages = builtins.concatLists ( map (s: s.packages) mypackages );
  home.sessionVariables =  pkgs.lib.attrsets.mergeAttrsList (map (s: s.env) mypackages );
  home.shellAliases = pkgs.lib.attrsets.mergeAttrsList (map (s: s.aliases) mypackages );
  programs = pkgs.lib.attrsets.mergeAttrsList (map (s: s.programs) mypackages);
  # snip
}

Thanks for your help!
Please nit-pick - I want to learn!