diff --git a/nixpkgs_review/nix/evalAttrs.nix b/nixpkgs_review/nix/evalAttrs.nix index e22b12c0..e28e7afb 100644 --- a/nixpkgs_review/nix/evalAttrs.nix +++ b/nixpkgs_review/nix/evalAttrs.nix @@ -3,18 +3,35 @@ with builtins; let pkgs = import { config = { checkMeta = true; allowUnfree = true; inherit allowAliases; }; }; - lib = pkgs.lib; + inherit (pkgs) lib; attrs = fromJSON (readFile attr-json); - getProperties = name: let - attrPath = lib.splitString "." name; - pkg = lib.attrByPath attrPath null pkgs; - maybePath = builtins.tryEval "${pkg}"; - in rec { - exists = lib.hasAttrByPath attrPath pkgs; - broken = !exists || !maybePath.success; - path = if !broken then maybePath.value else null; - drvPath = if !broken then pkg.drvPath else null; - }; + getProperties = name: + let + attrPath = lib.splitString "." name; + pkg = lib.attrByPath attrPath null pkgs; + debugAttr = attr: lib.concatStringsSep " " (lib.mapAttrsToList + (name: value: "${name}=${value}") + (lib.mapAttrs + (name: value: + if (isAttrs value && lib.hasAttr "outPath" value) then + value.outPath + else + "") + attr + ) + ); + maybePath = + if lib.strings.isCoercibleToString pkg then + tryEval "${pkg}" + else + throw "Tried building attr set with the following content: ${debugAttr pkg}"; + in + rec { + exists = lib.hasAttrByPath attrPath pkgs; + broken = !exists || !maybePath.success; + path = if !broken then maybePath.value else null; + drvPath = if !broken then pkg.drvPath else null; + }; in - pkgs.lib.genAttrs attrs getProperties +pkgs.lib.genAttrs attrs getProperties