nix-config/lib/default.nix

31 lines
1.1 KiB
Nix
Raw Normal View History

2024-08-07 20:21:02 +00:00
{ lib, ... }:
{
# use path relative to the root of the project
relativeToRoot = lib.path.append ../.;
scanPaths = path:
builtins.map
(f: (path + "/${f}"))
(builtins.attrNames
(lib.attrsets.filterAttrs
(
path: _type:
(_type == "directory") # include directories
|| (
# FIXME this barfs when child directories don't contain a default.nix
# example:
# error: getting status of '/nix/store/mx31x8530b758ap48vbg20qzcakrbc8 (see hosts/common/core/services/default.nix)a-source/hosts/common/core/services/default.nix': No such file or directory
# I created a blank default.nix in hosts/common/core/services to work around
(path != "default.nix") # ignore default.nix
&& (lib.strings.hasSuffix ".nix" path) # include .nix files
)
)
(builtins.readDir path)
)
);
mapPathsToPrefix = { prefix, list }:
# Filter... sth like builtins.filter (path: builtins.pathExists path)
builtins.map (path: prefix + path) list;
2024-08-07 20:21:02 +00:00
}