refactor to lib

This commit is contained in:
Daylin Morgan 2024-06-26 10:19:26 -05:00
parent 02d34a6aae
commit c40f5c7f0d
Signed by: daylin
GPG key ID: 950D13E9719334AD
2 changed files with 12 additions and 10 deletions

View file

@ -1,6 +1,6 @@
final: prev: final: prev:
let let
inherit (builtins) listToAttrs substring; inherit (builtins) listToAttrs substring filter;
inherit (final) inherit (final)
concatStringsSep concatStringsSep
hasSuffix hasSuffix
@ -9,6 +9,7 @@ let
mkOption mkOption
types types
; ;
inherit (final.filesystem) listFilesRecursive;
in in
let let
enabled = { enabled = {
@ -61,7 +62,11 @@ let
(substring 4 2 longDate) (substring 4 2 longDate)
(substring 6 2 longDate) (substring 6 2 longDate)
]); ]);
isNixFile = path: hasSuffix ".nix" path;
isNixFile = p: hasSuffix ".nix" p;
isDefaultNixFile = p: hasSuffix "default.nix" p;
filterNotDefaultNixFile = paths: filter (p: !(isDefaultNixFile p) && (isNixFile p)) paths;
listNixFilesRecursive = dir: filterNotDefaultNixFile (listFilesRecursive dir);
in in
{ {
@ -73,7 +78,8 @@ in
mkOizysModule mkOizysModule
mkDefaultOizysModule mkDefaultOizysModule
mkDate mkDate
isNixFile
mkIfIn mkIfIn
isNixFile
listNixFilesRecursive
; ;
} }

View file

@ -3,15 +3,11 @@ let
inherit (lib) inherit (lib)
mkOption mkOption
types types
isNixFile
literalExpression literalExpression
mdDoc
;
inherit (lib.filesystem) listFilesRecursive;
inherit (builtins) filter;
listNixFilesRecursive = mdDoc
dir: filter (f: (f != ./default.nix) && (isNixFile f)) (listFilesRecursive dir); listNixFilesRecursive
;
in in
{ {
imports = listNixFilesRecursive ./.; imports = listNixFilesRecursive ./.;