aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-11-23 10:25:54 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-11-23 10:25:54 +0100
commit7cbeaa437565e2154ae68835e244b9164de660f6 (patch)
tree9f53624f456e144a2e644c5df72ad6308ad4724f /lib
parenttests(tests): Initialize infrastructure and documentation for it (diff)
downloadnixos-config-7cbeaa437565e2154ae68835e244b9164de660f6.zip
tests({tests,modules}): Couple via a co-import
Diffstat (limited to 'lib')
-rw-r--r--lib/by-name-overlay.nix13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/by-name-overlay.nix b/lib/by-name-overlay.nix
index cc8bcb67..4d700a8f 100644
--- a/lib/by-name-overlay.nix
+++ b/lib/by-name-overlay.nix
@@ -5,6 +5,8 @@
baseDirectory,
fileName,
finalizeFunction,
+ coImportsNameFunction ? null,
+ coImportsWarnMessageObject ? null,
}: let
# Takes a list of attrs as input and returns one merged attr set.
flattenAttrs = list:
@@ -44,9 +46,18 @@
else let
mkPath = name: _type: let
path = baseDirectory + "/${shard}/${name}" + "/${fileName}";
+ coImportPath =
+ if coImportsNameFunction != null
+ then
+ coImportsNameFunction
+ {inherit shard name;}
+ else path;
in
if builtins.pathExists path
- then path
+ then
+ if builtins.pathExists coImportPath
+ then path
+ else warn "'${builtins.toString coImportPath}' does not exist. Should include ${coImportsWarnMessageObject} for '${shard}/${name}'" path
else warn "'${builtins.toString path}' does not exist. Skipped" null;
in
filterAttrs (name: value: value != null)