Initial Commit
This commit is contained in:
commit
d07ba813bf
14 changed files with 360 additions and 0 deletions
26
nixos/lib/utils.nix
Normal file
26
nixos/lib/utils.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
rec {
|
||||
findNixFiles = dir: let
|
||||
inherit (builtins) attrNames readDir pathExists concatMap hasSuffix;
|
||||
|
||||
# Helper function to build full paths
|
||||
fullPath = name: dir + "/${name}";
|
||||
|
||||
# Get directory contents
|
||||
contents = readDir dir;
|
||||
|
||||
# Convert contents attrset to list of names
|
||||
names = attrNames contents;
|
||||
|
||||
# Filter and process each item
|
||||
processItem = name: let
|
||||
path = fullPath name;
|
||||
type = contents.${name};
|
||||
in
|
||||
if type == "regular" && hasSuffix ".nix" name
|
||||
then [path]
|
||||
else if type == "directory" && pathExists path
|
||||
then findNixFiles path
|
||||
else [];
|
||||
in
|
||||
concatMap processItem names;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue