Fixup formatting

This commit is contained in:
Graham Christensen 2019-01-02 22:26:58 -05:00
parent 07a5a145a1
commit 5c04e88375
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C

View file

@ -22,89 +22,86 @@ let
}) })
changedattrs; changedattrs;
validPackageAttributes = builtins.filter validPackageAttributes = builtins.filter
(pkg: (pkg:
if (pkgs.lib.attrsets.hasAttrByPath pkg.path pkgs) then if (pkgs.lib.attrsets.hasAttrByPath pkg.path pkgs)
(if (builtins.tryEval (pkgs.lib.attrsets.attrByPath pkg.path null pkgs)).success then (if (builtins.tryEval (pkgs.lib.attrsets.attrByPath pkg.path null pkgs)).success
then true then true
else builtins.trace "Failed to access ${pkg.name} even though it exists" false) else builtins.trace "Failed to access ${pkg.name} even though it exists" false)
else builtins.trace "Failed to locate ${pkg.name}." false else builtins.trace "Failed to locate ${pkg.name}." false
) )
enrichedAttrs; enrichedAttrs;
attrsWithPackages = builtins.map attrsWithPackages = builtins.map
(pkg: pkg // { package = pkgs.lib.attrsets.attrByPath pkg.path null pkgs; }) (pkg: pkg // { package = pkgs.lib.attrsets.attrByPath pkg.path null pkgs; })
validPackageAttributes; validPackageAttributes;
attrsWithMaintainers = builtins.map attrsWithMaintainers = builtins.map
(pkg: pkg // { maintainers = (pkg.package.meta or {}).maintainers or []; }) (pkg: pkg // { maintainers = (pkg.package.meta or {}).maintainers or []; })
attrsWithPackages; attrsWithPackages;
attrsWeCanPing = builtins.filter attrsWeCanPing = builtins.filter
(pkg: if (builtins.length pkg.maintainers) > 0 (pkg: if (builtins.length pkg.maintainers) > 0
then true then true
else builtins.trace "Package has no maintainers: ${pkg.name}" false else builtins.trace "Package has no maintainers: ${pkg.name}" false
) )
attrsWithMaintainers; attrsWithMaintainers;
relevantFilenames = drv: relevantFilenames = drv:
(pkgs.lib.lists.unique (pkgs.lib.lists.unique
(builtins.map (builtins.map
(pos: pos.file) (pos: pos.file)
(builtins.filter (x: x != null) (builtins.filter (x: x != null)
[ [
(builtins.unsafeGetAttrPos "maintainers" (drv.meta or {})) (builtins.unsafeGetAttrPos "maintainers" (drv.meta or {}))
(builtins.unsafeGetAttrPos "src" drv) (builtins.unsafeGetAttrPos "src" drv)
# broken because name is always set in stdenv: # broken because name is always set by stdenv:
# # A hack to make `nix-env -qa` and `nix search` ignore broken packages. # # A hack to make `nix-env -qa` and `nix search` ignore broken packages.
# # TODO(@oxij): remove this assert when something like NixOS/nix#1771 gets merged into nix. # # TODO(@oxij): remove this assert when something like NixOS/nix#1771 gets merged into nix.
# name = assert validity.handled; name + lib.optionalString # name = assert validity.handled; name + lib.optionalString
#(builtins.unsafeGetAttrPos "name" drv) #(builtins.unsafeGetAttrPos "name" drv)
(builtins.unsafeGetAttrPos "pname" drv) (builtins.unsafeGetAttrPos "pname" drv)
(builtins.unsafeGetAttrPos "version" drv) (builtins.unsafeGetAttrPos "version" drv)
] ]
))); )));
attrsWithFilenames = builtins.map attrsWithFilenames = builtins.map
(pkg: pkg // { filenames = relevantFilenames pkg.package; }) (pkg: pkg // { filenames = relevantFilenames pkg.package; })
attrsWithMaintainers; attrsWithMaintainers;
attrsWithModifiedFiles = builtins.filter attrsWithModifiedFiles = builtins.filter
(pkg: anyMatchingFiles pkg.filenames) (pkg: anyMatchingFiles pkg.filenames)
attrsWithFilenames; attrsWithFilenames;
listToPing = pkgs.lib.lists.flatten listToPing = pkgs.lib.lists.flatten
(builtins.map (builtins.map
(pkg: (pkg:
builtins.map builtins.map (maintainer: {
(maintainer: {
handle = maintainer.github; handle = maintainer.github;
packageName = pkg.name; packageName = pkg.name;
dueToFiles = pkg.filenames; dueToFiles = pkg.filenames;
}) })
pkg.maintainers pkg.maintainers
) )
attrsWithModifiedFiles); attrsWithModifiedFiles);
byMaintainer = pkgs.lib.lists.foldr byMaintainer = pkgs.lib.lists.foldr
(ping: collector: collector // { "${ping.handle}" = [ { inherit (ping) packageName dueToFiles; } ] ++ (collector."${ping.handle}" or []); }) (ping: collector: collector // { "${ping.handle}" = [ { inherit (ping) packageName dueToFiles; } ] ++ (collector."${ping.handle}" or []); })
{} {}
listToPing; listToPing;
textForPackages = packages: textForPackages = packages:
pkgs.lib.strings.concatStringsSep ", " ( pkgs.lib.strings.concatStringsSep ", " (
builtins.map builtins.map (pkg: pkg.packageName)
(pkg: pkg.packageName)
packages); packages);
textPerMaintainer = pkgs.lib.attrsets.mapAttrs textPerMaintainer = pkgs.lib.attrsets.mapAttrs
(maintainer: packages: "- @${maintainer} for ${textForPackages packages}") (maintainer: packages: "- @${maintainer} for ${textForPackages packages}")
byMaintainer; byMaintainer;
packagesPerMaintainer = pkgs.lib.attrsets.mapAttrs packagesPerMaintainer = pkgs.lib.attrsets.mapAttrs
(maintainer: packages: (maintainer: packages:
builtins.map builtins.map (pkg: pkg.packageName)
(pkg: pkg.packageName) packages)
packages)
byMaintainer; byMaintainer;
in packagesPerMaintainer in packagesPerMaintainer