1
Fork 0
mirror of https://github.com/thegeneralist01/config.git synced 2026-03-07 10:59:55 +01:00

refactor: hosts' systems & modules

This commit is contained in:
TheGeneralist 2025-08-02 17:07:19 +02:00
parent 0e465f6c84
commit 37c4eeaca6
Signed by: thegeneralist01
SSH key fingerprint: SHA256:pp9qddbCNmVNoSjevdvQvM5z0DHN7LTa8qBMbcMq/R4
7 changed files with 77 additions and 125 deletions

5
lib/default.nix Normal file
View file

@ -0,0 +1,5 @@
inputs: self: super:
let
system = import ./system.nix inputs self super;
in
system

66
lib/system.nix Normal file
View file

@ -0,0 +1,66 @@
inputs: self: super:
let
inherit (self)
hasSuffix
filesystem
attrValues
filter
getAttrFromPath
hasAttrByPath
;
collectModules = path: filesystem.listFilesRecursive path |> filter (hasSuffix ".nix");
collectInputModules =
packagePath:
(attrValues inputs) |> filter (hasAttrByPath packagePath) |> map (getAttrFromPath packagePath);
specialArgs = inputs // {
inherit inputs;
inherit self;
};
# All modules
modulesCommon = collectModules ../modules/common;
modulesLinux = collectModules ../modules/linux;
modulesDarwin = collectModules ../modules/darwin;
inputModulesNixos = collectInputModules [
"nixosModules"
"default"
];
inputModulesDarwin = collectInputModules [
"darwinModules"
"default"
];
# Overlays
overlays = collectInputModules [
"overlays"
"default"
];
overlayModules = {
nixpkgs.overlays = overlays;
};
in
{
system =
os: configFile:
if os == "darwin" then
super.darwinSystem
else
super.nixosSystem {
inherit specialArgs;
modules =
[
overlayModules
configFile
]
++ modulesCommon
++ (
if os == "darwin" then modulesDarwin ++ inputModulesDarwin else modulesLinux ++ inputModulesNixos
);
};
}