flake: home-manager: use a more modular design

This means I can easily add new hosts now.
This commit is contained in:
Bruno BELANYI 2023-03-09 09:00:30 +00:00
parent 2fb3d0f9cf
commit a046569743
2 changed files with 48 additions and 33 deletions

View file

@ -1,40 +1,50 @@
{ self, inputs, ... }:
{ self, inputs, lib, ... }:
let
defaultModules = [
# Include generic settings
"${self}/home"
{
# Basic user information defaults
home.username = lib.mkDefault "ambroisie";
home.homeDirectory = lib.mkDefault "/home/ambroisie";
# Make it a Linux installation by default
targets.genericLinux.enable = lib.mkDefault true;
# Enable home-manager
programs.home-manager.enable = true;
}
];
mkHome = name: system: inputs.home-manager.lib.homeManagerConfiguration {
# Work-around for home-manager
# * not letting me set `lib` as an extraSpecialArgs
# * not respecting `nixpkgs.overlays` [1]
# [1]: https://github.com/nix-community/home-manager/issues/2954
pkgs = import inputs.nixpkgs {
inherit system;
overlays = (lib.attrValues self.overlays) ++ [
inputs.nur.overlay
];
};
modules = defaultModules ++ [
"${self}/hosts/homes/${name}"
];
extraSpecialArgs = {
# Inject inputs to use them in global registry
inherit inputs;
};
};
in
{
perSystem = { system, ... }: {
# Work-around for https://github.com/nix-community/home-manager/issues/3075
legacyPackages = {
homeConfigurations = {
ambroisie = inputs.home-manager.lib.homeManagerConfiguration {
# Work-around for home-manager
# * not letting me set `lib` as an extraSpecialArgs
# * not respecting `nixpkgs.overlays` [1]
# [1]: https://github.com/nix-community/home-manager/issues/2954
pkgs = import inputs.nixpkgs {
inherit system;
overlays = (lib.attrValues self.overlays) ++ [
inputs.nur.overlay
];
};
modules = [
"${self}/home"
{
# The basics
home.username = "ambroisie";
home.homeDirectory = "/home/ambroisie";
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
# This is a generic linux install
targets.genericLinux.enable = true;
}
];
extraSpecialArgs = {
# Inject inputs to use them in global registry
inherit inputs;
};
};
homeConfigurations = lib.mapAttrs mkHome {
ambroisie = system;
};
};
};

View file

@ -0,0 +1,5 @@
# Default home-manager configuration
{ ... }:
{
# Default configuration, nothing to do
}