2023-12-07 22:41:05 +01:00
|
|
|
{ self, config, inputs, lib, ... }:
|
2023-03-09 10:00:30 +01:00
|
|
|
let
|
2023-12-07 22:41:05 +01:00
|
|
|
inherit (config) hosts;
|
|
|
|
|
2023-03-09 10:00:30 +01:00
|
|
|
defaultModules = [
|
|
|
|
# Include generic settings
|
2023-11-09 14:43:55 +01:00
|
|
|
"${self}/modules/home"
|
2023-03-09 10:00:30 +01:00
|
|
|
{
|
|
|
|
# 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;
|
|
|
|
}
|
2024-01-03 17:50:16 +01:00
|
|
|
# Import common modules
|
|
|
|
"${self}/modules/common"
|
2023-03-09 10:00:30 +01:00
|
|
|
];
|
|
|
|
|
2023-12-07 22:44:01 +01:00
|
|
|
mkHomeCommon = mainModules: system: inputs.home-manager.lib.homeManagerConfiguration {
|
2023-03-09 10:00:30 +01:00
|
|
|
# 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
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-12-07 22:44:01 +01:00
|
|
|
modules = defaultModules ++ mainModules;
|
2023-03-09 10:00:30 +01:00
|
|
|
|
|
|
|
extraSpecialArgs = {
|
|
|
|
# Inject inputs to use them in global registry
|
|
|
|
inherit inputs;
|
2024-01-03 17:50:16 +01:00
|
|
|
# For consumption by common modules
|
|
|
|
type = "home";
|
2023-03-09 10:00:30 +01:00
|
|
|
};
|
|
|
|
};
|
2023-03-09 11:21:36 +01:00
|
|
|
|
2023-12-07 22:44:01 +01:00
|
|
|
mkHome = name: mkHomeCommon [ "${self}/hosts/homes/${name}" ];
|
2023-12-07 22:56:25 +01:00
|
|
|
|
|
|
|
mkNixosHome = name: mkHomeCommon [
|
|
|
|
"${self}/hosts/nixos/${name}/home.nix"
|
|
|
|
"${self}/hosts/nixos/${name}/profiles.nix"
|
|
|
|
];
|
2023-12-07 22:41:05 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
hosts.homes = {
|
2023-12-07 15:26:36 +01:00
|
|
|
"ambroisie@bazin" = "x86_64-linux";
|
2023-09-13 15:45:22 +02:00
|
|
|
"ambroisie@mousqueton" = "x86_64-linux";
|
2023-03-09 11:21:36 +01:00
|
|
|
};
|
2023-12-07 22:41:05 +01:00
|
|
|
|
2023-03-08 19:11:59 +01:00
|
|
|
perSystem = { system, ... }: {
|
|
|
|
# Work-around for https://github.com/nix-community/home-manager/issues/3075
|
|
|
|
legacyPackages = {
|
2023-03-09 11:21:36 +01:00
|
|
|
homeConfigurations =
|
|
|
|
let
|
2023-12-07 22:41:05 +01:00
|
|
|
filteredHomes = lib.filterAttrs (_: v: v == system) hosts.homes;
|
2023-12-07 21:30:35 +01:00
|
|
|
allHomes = filteredHomes // {
|
2023-03-09 11:21:36 +01:00
|
|
|
# Default configuration
|
|
|
|
ambroisie = system;
|
|
|
|
};
|
2023-12-07 22:56:25 +01:00
|
|
|
homeManagerHomes = lib.mapAttrs mkHome allHomes;
|
|
|
|
|
|
|
|
filteredNixosHosts = lib.filterAttrs (_: v: v == system) hosts.nixos;
|
|
|
|
nixosHomes' = lib.mapAttrs mkNixosHome filteredNixosHosts;
|
|
|
|
nixosHomeUsername = (host: self.nixosConfigurations.${host}.config.my.user.name);
|
|
|
|
nixosHomes = lib.mapAttrs' (host: lib.nameValuePair "${nixosHomeUsername host}@${host}") nixosHomes';
|
2023-03-09 11:21:36 +01:00
|
|
|
in
|
2023-12-07 22:56:25 +01:00
|
|
|
lib.foldl' lib.mergeAttrs { }
|
|
|
|
[
|
|
|
|
homeManagerHomes
|
|
|
|
nixosHomes
|
|
|
|
];
|
2023-03-08 19:11:59 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|