Refactor flake structure with flake-parts

This commit is contained in:
ulic-youthlic 2025-06-09 16:14:57 +08:00
parent 8ca6499da1
commit cf83a45191
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
10 changed files with 203 additions and 176 deletions

View file

@ -1,17 +1,13 @@
{
outputs,
rootPath,
}: {
lib,
inputs,
self,
...
}: let
rootPath = ./..;
inherit (self) outputs;
homeModules =
{
default = import "${toString rootPath}/home/modules";
extra = import "${toString rootPath}/home/extra";
}
// (
(
(rootPath + "/home")
|> builtins.readDir
|> lib.filterAttrs (key: value: value == "directory")
@ -23,13 +19,13 @@
]
)
|> builtins.attrNames
|> map (name: {
name = name;
value = import "${toString rootPath}/home/${name}/modules";
})
|> builtins.listToAttrs
);
mkHomeConfig = {
|> (with lib; flip genAttrs (name: import (rootPath + "/home/${name}/modules")))
)
// {
default = import "${toString rootPath}/home/modules";
extra = import "${toString rootPath}/home/extra";
};
makeHomeConfiguration = {
hostName,
unixName ? "david",
system ? "x86_64-linux",
@ -37,10 +33,12 @@
home-manager ? inputs.home-manager,
}: {
"${unixName}@${hostName}" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages."${system}";
pkgs = import nixpkgs {
inherit system;
};
modules =
[
"${toString rootPath}/home/${unixName}/configurations/${hostName}"
(rootPath + "/home/${unixName}/configurations/${hostName}")
]
++ (with homeModules; [
default
@ -67,7 +65,7 @@ in {
[
# Hostname
]
|> map (hostName: mkHomeConfig {inherit hostName;})
|> map (hostName: makeHomeConfiguration {inherit hostName;})
);
inherit homeModules;
};