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:
parent
0e465f6c84
commit
37c4eeaca6
7 changed files with 77 additions and 125 deletions
5
lib/default.nix
Normal file
5
lib/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
inputs: self: super:
|
||||
let
|
||||
system = import ./system.nix inputs self super;
|
||||
in
|
||||
system
|
||||
66
lib/system.nix
Normal file
66
lib/system.nix
Normal 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
|
||||
);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue