diff options
Diffstat (limited to '')
-rw-r--r-- | nix/readTree/default.nix | 17 | ||||
-rw-r--r-- | nix/utils/default.nix | 17 | ||||
-rw-r--r-- | nix/writers/tests/rust.nix | 2 |
3 files changed, 18 insertions, 18 deletions
diff --git a/nix/readTree/default.nix b/nix/readTree/default.nix index 5e805b5f4a97..2ad8e40f6c28 100644 --- a/nix/readTree/default.nix +++ b/nix/readTree/default.nix @@ -157,6 +157,10 @@ let }) (node.meta.targets or [])) else []; + + # Determine whether a given value is a derivation. + # Copied from nixpkgs/lib for cases where lib is not available yet. + isDerivation = x: isAttrs x && x ? type && x.type == "derivation"; in { inherit gather; @@ -210,4 +214,17 @@ in { # # It is often required to create the args attribute set. fix = f: let x = f x; in x; + + # 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: isDerivation attrs."${x}") + (builtins.attrNames attrs); + } // (attrs.meta or {}); + }; } diff --git a/nix/utils/default.nix b/nix/utils/default.nix index d90dee24af01..f65d4712a03d 100644 --- a/nix/utils/default.nix +++ b/nix/utils/default.nix @@ -1,22 +1,6 @@ { 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 {}); - }; - /* Get the basename of a store path without the leading hash. @@ -186,7 +170,6 @@ let in { inherit - drvTargets storePathName pathType isDirectory diff --git a/nix/writers/tests/rust.nix b/nix/writers/tests/rust.nix index 4b87676118f5..8a12c95ec7da 100644 --- a/nix/writers/tests/rust.nix +++ b/nix/writers/tests/rust.nix @@ -60,7 +60,7 @@ let ''); -in depot.nix.utils.drvTargets { +in depot.nix.readTree.drvTargets { inherit rustTransitiveLib rustWithLib |