mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 14:20:44 -06:00
split find-modules into it's own file
This commit is contained in:
parent
270c946b24
commit
e0a3123035
2 changed files with 27 additions and 23 deletions
|
@ -5,10 +5,11 @@
|
||||||
inherit (inputs) nixpkgs;
|
inherit (inputs) nixpkgs;
|
||||||
lib = nixpkgs.lib.extend (import ./extended.nix);
|
lib = nixpkgs.lib.extend (import ./extended.nix);
|
||||||
|
|
||||||
inherit (builtins) concatLists attrValues mapAttrs elemAt match readDir filter listToAttrs;
|
inherit (builtins) mapAttrs readDir filter listToAttrs;
|
||||||
inherit (lib) nixosSystem genAttrs isNixFile;
|
inherit (lib) nixosSystem genAttrs isNixFile;
|
||||||
inherit (lib.filesystem) listFilesRecursive;
|
inherit (lib.filesystem) listFilesRecursive;
|
||||||
|
|
||||||
|
inherit (import ./find-modules.nix {inherit lib;}) findModulesList;
|
||||||
#supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
|
#supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
|
||||||
supportedSystems = ["x86_64-linux"];
|
supportedSystems = ["x86_64-linux"];
|
||||||
in rec {
|
in rec {
|
||||||
|
@ -39,29 +40,7 @@ in rec {
|
||||||
specialArgs = {inherit inputs lib self;};
|
specialArgs = {inherit inputs lib self;};
|
||||||
};
|
};
|
||||||
mapHosts = dir: mapAttrs (name: _: mkSystem name) (readDir dir);
|
mapHosts = dir: mapAttrs (name: _: mkSystem name) (readDir dir);
|
||||||
|
|
||||||
findModules = _: listToAttrs (findModulesList ../modules);
|
findModules = _: listToAttrs (findModulesList ../modules);
|
||||||
# https://github.com/balsoft/nixos-config/blob/73cc2c3a8bb62a9c3980a16ae70b2e97af6e1abd/flake.nix#L109-L120
|
|
||||||
findModulesList = dir:
|
|
||||||
concatLists (attrValues (mapAttrs
|
|
||||||
(name: type:
|
|
||||||
if type == "regular"
|
|
||||||
then [
|
|
||||||
{
|
|
||||||
name = elemAt (match "(.*)\\.nix" name) 0;
|
|
||||||
value = dir + "/${name}";
|
|
||||||
}
|
|
||||||
]
|
|
||||||
else if
|
|
||||||
(readDir (dir + "/${name}"))
|
|
||||||
? "default.nix"
|
|
||||||
then [
|
|
||||||
{
|
|
||||||
inherit name;
|
|
||||||
value = dir + "/${name}";
|
|
||||||
}
|
|
||||||
]
|
|
||||||
else findModulesList (dir + "/${name}")) (readDir dir)));
|
|
||||||
|
|
||||||
oizysFlake = _: {
|
oizysFlake = _: {
|
||||||
nixosModules = findModules {};
|
nixosModules = findModules {};
|
||||||
|
|
25
lib/find-modules.nix
Normal file
25
lib/find-modules.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{...}: let
|
||||||
|
inherit (builtins) concatLists attrValues mapAttrs elemAt match readDir;
|
||||||
|
in rec {
|
||||||
|
# https://github.com/balsoft/nixos-config/blob/73cc2c3a8bb62a9c3980a16ae70b2e97af6e1abd/flake.nix#L109-L120
|
||||||
|
findModulesList = dir:
|
||||||
|
concatLists (attrValues (mapAttrs
|
||||||
|
(name: type:
|
||||||
|
if type == "regular"
|
||||||
|
then [
|
||||||
|
{
|
||||||
|
name = elemAt (match "(.*)\\.nix" name) 0;
|
||||||
|
value = dir + "/${name}";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
else if
|
||||||
|
(readDir (dir + "/${name}"))
|
||||||
|
? "default.nix"
|
||||||
|
then [
|
||||||
|
{
|
||||||
|
inherit name;
|
||||||
|
value = dir + "/${name}";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
else findModulesList (dir + "/${name}")) (readDir dir)));
|
||||||
|
}
|
Loading…
Reference in a new issue