refactor(home): consolidate host home modules under home/hosts

This commit is contained in:
Ryan Yin
2026-03-23 12:32:17 +08:00
parent cf7b5a5be7
commit 8207ccbdff
22 changed files with 59 additions and 47 deletions
+8
View File
@@ -26,6 +26,9 @@ home/
│ │ └── ... │ │ └── ...
│ ├── editors/ # Linux-specific editors │ ├── editors/ # Linux-specific editors
│ └── ... │ └── ...
├── hosts/ # Host-specific home manager entry modules
│ ├── linux/ # Linux host home modules (ai, shoukei, k3s-*, etc.)
│ └── darwin/ # macOS host home modules (fern, frieren)
└── darwin/ # macOS-specific home manager configurations └── darwin/ # macOS-specific home manager configurations
├── aerospace/ # macOS window manager ├── aerospace/ # macOS window manager
├── proxy/ # Proxy configurations ├── proxy/ # Proxy configurations
@@ -46,3 +49,8 @@ home/
3. **darwin**: macOS-specific configuration 3. **darwin**: macOS-specific configuration
- macOS applications and services - macOS applications and services
- Platform-specific integrations (Aerospace, Squirrel, etc.) - Platform-specific integrations (Aerospace, Squirrel, etc.)
4. **hosts**: Host entry modules for Home Manager
- Each output should reference only one host home module file
- Host modules are responsible for importing shared stacks (`home/linux/*` or `home/darwin`) and
applying host overrides
-4
View File
@@ -1,4 +0,0 @@
{ mylib, ... }:
{
imports = mylib.scanPaths ./.;
}
+17
View File
@@ -0,0 +1,17 @@
# Host Home Modules
This directory contains host-specific Home Manager entry modules.
## Layout
- `home/hosts/linux/*.nix`: Linux host home modules
- `home/hosts/darwin/*.nix`: macOS host home modules
## Conventions
1. Each host output should reference only one file under `home/hosts/...`.
2. Shared home module imports should be handled in the host file itself.
- Linux hosts usually import `../../linux/core.nix` or `../../linux/gui.nix`.
- Darwin hosts import `../../darwin`.
3. Host-specific overrides (SSH keys, desktop toggles, host-local config links) live in the same
host file.
@@ -3,6 +3,8 @@ let
hostName = "fern"; hostName = "fern";
in in
{ {
imports = [ ../../darwin ];
programs.ssh.matchBlocks."github.com".identityFile = programs.ssh.matchBlocks."github.com".identityFile =
"${config.home.homeDirectory}/.ssh/${hostName}"; "${config.home.homeDirectory}/.ssh/${hostName}";
} }
@@ -3,6 +3,8 @@ let
hostName = "frieren"; hostName = "frieren";
in in
{ {
imports = [ ../../darwin ];
programs.ssh.matchBlocks."github.com".identityFile = programs.ssh.matchBlocks."github.com".identityFile =
"${config.home.homeDirectory}/.ssh/${hostName}"; "${config.home.homeDirectory}/.ssh/${hostName}";
} }
@@ -4,9 +4,13 @@ let
mkSymlink = config.lib.file.mkOutOfStoreSymlink; mkSymlink = config.lib.file.mkOutOfStoreSymlink;
in in
{ {
imports = [ ../../linux/gui.nix ];
programs.ssh.matchBlocks."github.com".identityFile = programs.ssh.matchBlocks."github.com".identityFile =
"${config.home.homeDirectory}/.ssh/${hostName}"; "${config.home.homeDirectory}/.ssh/${hostName}";
modules.desktop.gaming.enable = false;
modules.desktop.niri.enable = true;
modules.desktop.nvidia.enable = false; modules.desktop.nvidia.enable = false;
xdg.configFile."niri/niri-hardware.kdl".source = xdg.configFile."niri/niri-hardware.kdl".source =
@@ -3,8 +3,12 @@ let
mkSymlink = config.lib.file.mkOutOfStoreSymlink; mkSymlink = config.lib.file.mkOutOfStoreSymlink;
in in
{ {
imports = [ ../../linux/gui.nix ];
programs.ssh.matchBlocks."github.com".identityFile = "${config.home.homeDirectory}/.ssh/idols-ai"; programs.ssh.matchBlocks."github.com".identityFile = "${config.home.homeDirectory}/.ssh/idols-ai";
modules.desktop.gaming.enable = true;
modules.desktop.niri.enable = true;
modules.desktop.nvidia.enable = true; modules.desktop.nvidia.enable = true;
xdg.configFile."niri/niri-hardware.kdl".source = xdg.configFile."niri/niri-hardware.kdl".source =
+3
View File
@@ -0,0 +1,3 @@
{
imports = [ ../../linux/core.nix ];
}
+3
View File
@@ -0,0 +1,3 @@
{
imports = [ ../../linux/core.nix ];
}
+1 -1
View File
@@ -80,7 +80,7 @@ configurations follow similar patterns but are customized for specific hardware
2. Create & add the new host's `hardware-configuration.nix` to the new folder, and add the new 2. Create & add the new host's `hardware-configuration.nix` to the new folder, and add the new
host's `configuration.nix` to `hosts/<name>/default.nix`. host's `configuration.nix` to `hosts/<name>/default.nix`.
3. If the new host need to use home-manager, add its custom config into 3. If the new host need to use home-manager, add its custom config into
`home/linux/hosts/<name>.nix` or `home/darwin/hosts/<name>.nix`. `home/hosts/linux/<name>.nix` or `home/hosts/darwin/<name>.nix`.
1. Under `outputs/` 1. Under `outputs/`
1. Add a new nix file named `outputs/<system-architecture>/src/<name>.nix`. 1. Add a new nix file named `outputs/<system-architecture>/src/<name>.nix`.
2. Copy the content from one of the existing similar host, and modify it to fit the new host. 2. Copy the content from one of the existing similar host, and modify it to fit the new host.
+1 -2
View File
@@ -29,8 +29,7 @@ let
]; ];
home-modules = map mylib.relativeToRoot [ home-modules = map mylib.relativeToRoot [
"home/darwin/hosts/darwin-${name}.nix" "home/hosts/darwin/darwin-${name}.nix"
"home/darwin"
]; ];
}; };
+1 -2
View File
@@ -28,8 +28,7 @@ let
} }
]; ];
home-modules = map mylib.relativeToRoot [ home-modules = map mylib.relativeToRoot [
"home/darwin/hosts/darwin-${name}.nix" "home/hosts/darwin/darwin-${name}.nix"
"home/darwin"
]; ];
}; };
@@ -36,19 +36,9 @@ let
modules.desktop.gaming.enable = false; modules.desktop.gaming.enable = false;
} }
]; ];
home-modules = home-modules = map mylib.relativeToRoot [
(map mylib.relativeToRoot [ "home/hosts/linux/12kingdoms-${name}.nix"
# common ];
"home/linux/gui.nix"
# host specific
"home/linux/hosts/12kingdoms-${name}.nix"
])
++ [
{
# not supported yet
modules.desktop.gaming.enable = false;
}
];
}; };
modules-niri = { modules-niri = {
@@ -56,10 +46,7 @@ let
{ programs.niri.enable = true; } { programs.niri.enable = true; }
] ]
++ base-modules.nixos-modules; ++ base-modules.nixos-modules;
home-modules = [ home-modules = base-modules.home-modules;
{ modules.desktop.niri.enable = true; }
]
++ base-modules.home-modules;
}; };
in in
{ {
+4 -16
View File
@@ -36,18 +36,9 @@ let
modules.desktop.gaming.enable = true; modules.desktop.gaming.enable = true;
} }
]; ];
home-modules = home-modules = map mylib.relativeToRoot [
(map mylib.relativeToRoot [ "home/hosts/linux/idols-${name}.nix"
# common ];
"home/linux/gui.nix"
# host specific
"home/linux/hosts/idols-${name}.nix"
])
++ [
{
modules.desktop.gaming.enable = true;
}
];
}; };
modules-niri = { modules-niri = {
@@ -55,10 +46,7 @@ let
{ programs.niri.enable = true; } { programs.niri.enable = true; }
] ]
++ base-modules.nixos-modules; ++ base-modules.nixos-modules;
home-modules = [ home-modules = base-modules.home-modules;
{ modules.desktop.niri.enable = true; }
]
++ base-modules.home-modules;
}; };
in in
{ {
@@ -36,7 +36,7 @@ let
{ modules.secrets.server.storage.enable = true; } { modules.secrets.server.storage.enable = true; }
]; ];
home-modules = map mylib.relativeToRoot [ home-modules = map mylib.relativeToRoot [
"home/linux/hosts/idols-${name}.nix" "home/hosts/linux/idols-${name}.nix"
]; ];
}; };
+1 -1
View File
@@ -33,7 +33,7 @@ let
]; ];
home-modules = map mylib.relativeToRoot [ home-modules = map mylib.relativeToRoot [
# host specific # host specific
"home/linux/hosts/idols-${name}.nix" "home/hosts/linux/idols-${name}.nix"
]; ];
}; };
+1 -1
View File
@@ -33,7 +33,7 @@ let
]; ];
home-modules = map mylib.relativeToRoot [ home-modules = map mylib.relativeToRoot [
# host specific # host specific
"home/linux/hosts/idols-${name}.nix" "home/hosts/linux/idols-${name}.nix"
]; ];
}; };
@@ -29,7 +29,7 @@ let
{ modules.secrets.server.kubernetes.enable = true; } { modules.secrets.server.kubernetes.enable = true; }
]; ];
home-modules = map mylib.relativeToRoot [ home-modules = map mylib.relativeToRoot [
"home/linux/core.nix" "home/hosts/linux/${name}.nix"
]; ];
}; };
@@ -29,7 +29,7 @@ let
{ modules.secrets.server.kubernetes.enable = true; } { modules.secrets.server.kubernetes.enable = true; }
]; ];
home-modules = map mylib.relativeToRoot [ home-modules = map mylib.relativeToRoot [
"home/linux/core.nix" "home/hosts/linux/${name}.nix"
]; ];
}; };