mirror of
https://github.com/mjallen18/snowfall-lib.git
synced 2026-04-18 00:55:58 -05:00
feat: add fs.get-directories-with-default helper to eliminate duplicate directory filtering
This commit is contained in:
@@ -99,6 +99,20 @@ in
|
||||
in
|
||||
mapAttrsToList (name: kind: "${path}/${name}") filtered-entries;
|
||||
|
||||
## Get directories containing default.nix at a given path.
|
||||
## Example Usage:
|
||||
## ```nix
|
||||
## get-directories-with-default ./systems/x86_64-linux
|
||||
## ```
|
||||
## Result:
|
||||
## ```nix
|
||||
## [ "./systems/x86_64-linux/my-host" ]
|
||||
## ```
|
||||
#@ Path -> [Path]
|
||||
get-directories-with-default =
|
||||
path:
|
||||
builtins.filter (dir: pathExists "${dir}/default.nix") (get-directories path);
|
||||
|
||||
## Get files at a given path.
|
||||
## Example Usage:
|
||||
## ```nix
|
||||
|
||||
@@ -179,8 +179,7 @@ in
|
||||
get-target-homes-metadata =
|
||||
target:
|
||||
let
|
||||
homes = snowfall-lib.fs.get-directories target;
|
||||
existing-homes = builtins.filter (home: builtins.pathExists "${home}/default.nix") homes;
|
||||
existing-homes = snowfall-lib.fs.get-directories-with-default target;
|
||||
create-home-metadata =
|
||||
path:
|
||||
let
|
||||
|
||||
@@ -106,8 +106,7 @@ in
|
||||
get-target-systems-metadata =
|
||||
target:
|
||||
let
|
||||
systems = snowfall-lib.fs.get-directories target;
|
||||
existing-systems = builtins.filter (system: builtins.pathExists "${system}/default.nix") systems;
|
||||
existing-systems = snowfall-lib.fs.get-directories-with-default target;
|
||||
create-system-metadata = path: {
|
||||
path = "${path}/default.nix";
|
||||
# We are building flake outputs based on file contents. Nix doesn't like this
|
||||
|
||||
Reference in New Issue
Block a user