nixos/flake/home.nix

81 lines
1.7 KiB
Nix
Raw Normal View History

2025-05-03 11:35:18 +08:00
{
lib,
inputs,
self,
rootPath,
2025-05-03 11:35:18 +08:00
...
2025-07-13 06:04:55 +08:00
}:
let
inherit (self) outputs;
2025-05-03 11:35:18 +08:00
homeModules =
(
2025-05-03 11:35:18 +08:00
(rootPath + "/home")
|> builtins.readDir
|> lib.filterAttrs (_key: value: value == "directory")
2025-05-03 11:35:18 +08:00
|> lib.filterAttrs (
key: _value:
2025-07-13 06:04:55 +08:00
!builtins.elem key [
"modules"
"extra"
]
2025-05-03 11:35:18 +08:00
)
|> builtins.attrNames
|> (with lib; flip genAttrs (name: import (rootPath + "/home/${name}/modules")))
)
// {
default = import "${toString rootPath}/home/modules";
extra = import "${toString rootPath}/home/extra";
};
2025-07-13 06:04:55 +08:00
makeHomeConfiguration =
{
hostName,
unixName ? "david",
system ? "x86_64-linux",
nixpkgs ? inputs.nixpkgs,
home-manager ? inputs.home-manager,
}:
{
"${unixName}@${hostName}" = home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs {
inherit system;
};
modules = [
(rootPath + "/home/${unixName}/configurations/${hostName}")
2025-05-03 11:35:18 +08:00
]
++ (with homeModules; [
default
extra
])
++ [
homeModules."${unixName}"
]
++ [
{
2025-07-13 06:04:55 +08:00
lib = { inherit (lib) youthlic; };
}
2025-05-03 11:35:18 +08:00
];
2025-07-13 06:04:55 +08:00
extraSpecialArgs = {
inherit
inputs
outputs
unixName
hostName
system
rootPath
;
};
2025-05-03 11:35:18 +08:00
};
};
2025-07-13 06:04:55 +08:00
in
{
2025-05-03 11:35:18 +08:00
flake = {
2025-07-13 06:04:55 +08:00
homeConfigurations = lib.foldr (a: b: a // b) { } (
[
# Hostname
]
2025-07-13 06:04:55 +08:00
|> map (hostName: makeHomeConfiguration { inherit hostName; })
);
2025-05-03 11:35:18 +08:00
inherit homeModules;
};
}