about summary refs log tree commit diff
path: root/nix/utils
diff options
context:
space:
mode:
Diffstat (limited to 'nix/utils')
-rw-r--r--nix/utils/OWNERS3
-rw-r--r--nix/utils/default.nix24
2 files changed, 27 insertions, 0 deletions
diff --git a/nix/utils/OWNERS b/nix/utils/OWNERS
new file mode 100644
index 0000000000..f16dd105d7
--- /dev/null
+++ b/nix/utils/OWNERS
@@ -0,0 +1,3 @@
+inherited: true
+owners:
+  - sterni
diff --git a/nix/utils/default.nix b/nix/utils/default.nix
new file mode 100644
index 0000000000..33f72e3903
--- /dev/null
+++ b/nix/utils/default.nix
@@ -0,0 +1,24 @@
+{ depot, lib, ... }:
+
+let
+
+  /* Takes an attribute set and adds a meta.targets
+     attribute to it which contains all direct children
+     of the attribute set which are derivations.
+
+     Type: attrs -> attrs
+  */
+  drvTargets = attrs:
+    attrs // {
+      meta = {
+        targets = builtins.filter
+          (x: lib.isDerivation attrs."${x}")
+          (builtins.attrNames attrs);
+      } // (attrs.meta or {});
+    };
+
+in {
+  inherit
+    drvTargets
+    ;
+}