[Lib/Derivations] init with isBroken helper

Returns true if the parameter is not a derivation or if trying to
evaluate the derivation would fail.
This commit is contained in:
Antoine Viallon 2024-05-02 16:16:52 +02:00
parent 1387a101e6
commit 8f4c49f955
Signed by: aviallon
GPG key ID: 186FC35EDEB25716
2 changed files with 16 additions and 0 deletions

View file

@ -12,5 +12,6 @@ let
attrsets = callLibs ./attrsets.nix;
types = callLibs ./types.nix;
debug = callLibs ./debug.nix;
derivations = callLibs ./derivations.nix;
});
in myLib

15
lib/derivations.nix Normal file
View file

@ -0,0 +1,15 @@
{lib, myLib, ...}:
with lib;
rec {
isBroken = x:
let
tryX = builtins.tryEval x;
in
if
tryX.success && (isDerivation tryX.value)
then
tryX.value.meta.insecure || tryX.value.meta.broken
else
true
;
}