mirror of
https://github.com/mjallen18/snowfall-lib.git
synced 2026-04-18 09:05: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
|
in
|
||||||
mapAttrsToList (name: kind: "${path}/${name}") filtered-entries;
|
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.
|
## Get files at a given path.
|
||||||
## Example Usage:
|
## Example Usage:
|
||||||
## ```nix
|
## ```nix
|
||||||
|
|||||||
@@ -179,8 +179,7 @@ in
|
|||||||
get-target-homes-metadata =
|
get-target-homes-metadata =
|
||||||
target:
|
target:
|
||||||
let
|
let
|
||||||
homes = snowfall-lib.fs.get-directories target;
|
existing-homes = snowfall-lib.fs.get-directories-with-default target;
|
||||||
existing-homes = builtins.filter (home: builtins.pathExists "${home}/default.nix") homes;
|
|
||||||
create-home-metadata =
|
create-home-metadata =
|
||||||
path:
|
path:
|
||||||
let
|
let
|
||||||
|
|||||||
@@ -106,8 +106,7 @@ in
|
|||||||
get-target-systems-metadata =
|
get-target-systems-metadata =
|
||||||
target:
|
target:
|
||||||
let
|
let
|
||||||
systems = snowfall-lib.fs.get-directories target;
|
existing-systems = snowfall-lib.fs.get-directories-with-default target;
|
||||||
existing-systems = builtins.filter (system: builtins.pathExists "${system}/default.nix") systems;
|
|
||||||
create-system-metadata = path: {
|
create-system-metadata = path: {
|
||||||
path = "${path}/default.nix";
|
path = "${path}/default.nix";
|
||||||
# We are building flake outputs based on file contents. Nix doesn't like this
|
# We are building flake outputs based on file contents. Nix doesn't like this
|
||||||
|
|||||||
Reference in New Issue
Block a user