From 5c04e88375d80b9310aee73f1ef6b7c6e9bd69b1 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 2 Jan 2019 22:26:58 -0500 Subject: [PATCH] Fixup formatting --- ofborg/src/maintainers.nix | 123 ++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 63 deletions(-) diff --git a/ofborg/src/maintainers.nix b/ofborg/src/maintainers.nix index 8b7d611..9f8f975 100644 --- a/ofborg/src/maintainers.nix +++ b/ofborg/src/maintainers.nix @@ -22,89 +22,86 @@ let }) changedattrs; -validPackageAttributes = builtins.filter - (pkg: - if (pkgs.lib.attrsets.hasAttrByPath pkg.path pkgs) then - (if (builtins.tryEval (pkgs.lib.attrsets.attrByPath pkg.path null pkgs)).success - then true - else builtins.trace "Failed to access ${pkg.name} even though it exists" false) - else builtins.trace "Failed to locate ${pkg.name}." false - ) - enrichedAttrs; + validPackageAttributes = builtins.filter + (pkg: + if (pkgs.lib.attrsets.hasAttrByPath pkg.path pkgs) + then (if (builtins.tryEval (pkgs.lib.attrsets.attrByPath pkg.path null pkgs)).success + then true + else builtins.trace "Failed to access ${pkg.name} even though it exists" false) + else builtins.trace "Failed to locate ${pkg.name}." false + ) + enrichedAttrs; attrsWithPackages = builtins.map (pkg: pkg // { package = pkgs.lib.attrsets.attrByPath pkg.path null pkgs; }) validPackageAttributes; -attrsWithMaintainers = builtins.map - (pkg: pkg // { maintainers = (pkg.package.meta or {}).maintainers or []; }) - attrsWithPackages; + attrsWithMaintainers = builtins.map + (pkg: pkg // { maintainers = (pkg.package.meta or {}).maintainers or []; }) + attrsWithPackages; -attrsWeCanPing = builtins.filter - (pkg: if (builtins.length pkg.maintainers) > 0 - then true - else builtins.trace "Package has no maintainers: ${pkg.name}" false - ) - attrsWithMaintainers; + attrsWeCanPing = builtins.filter + (pkg: if (builtins.length pkg.maintainers) > 0 + then true + else builtins.trace "Package has no maintainers: ${pkg.name}" false + ) + attrsWithMaintainers; -relevantFilenames = drv: - (pkgs.lib.lists.unique - (builtins.map - (pos: pos.file) - (builtins.filter (x: x != null) - [ - (builtins.unsafeGetAttrPos "maintainers" (drv.meta or {})) - (builtins.unsafeGetAttrPos "src" drv) - # broken because name is always set in stdenv: - # # 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. - # name = assert validity.handled; name + lib.optionalString - #(builtins.unsafeGetAttrPos "name" drv) - (builtins.unsafeGetAttrPos "pname" drv) - (builtins.unsafeGetAttrPos "version" drv) - ] + relevantFilenames = drv: + (pkgs.lib.lists.unique + (builtins.map + (pos: pos.file) + (builtins.filter (x: x != null) + [ + (builtins.unsafeGetAttrPos "maintainers" (drv.meta or {})) + (builtins.unsafeGetAttrPos "src" drv) + # broken because name is always set by stdenv: + # # 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. + # name = assert validity.handled; name + lib.optionalString + #(builtins.unsafeGetAttrPos "name" drv) + (builtins.unsafeGetAttrPos "pname" drv) + (builtins.unsafeGetAttrPos "version" drv) + ] ))); -attrsWithFilenames = builtins.map - (pkg: pkg // { filenames = relevantFilenames pkg.package; }) - attrsWithMaintainers; + attrsWithFilenames = builtins.map + (pkg: pkg // { filenames = relevantFilenames pkg.package; }) + attrsWithMaintainers; -attrsWithModifiedFiles = builtins.filter - (pkg: anyMatchingFiles pkg.filenames) - attrsWithFilenames; + attrsWithModifiedFiles = builtins.filter + (pkg: anyMatchingFiles pkg.filenames) + attrsWithFilenames; -listToPing = pkgs.lib.lists.flatten - (builtins.map - (pkg: - builtins.map - (maintainer: { + listToPing = pkgs.lib.lists.flatten + (builtins.map + (pkg: + builtins.map (maintainer: { handle = maintainer.github; packageName = pkg.name; dueToFiles = pkg.filenames; }) - pkg.maintainers - ) - attrsWithModifiedFiles); + pkg.maintainers + ) + attrsWithModifiedFiles); -byMaintainer = pkgs.lib.lists.foldr - (ping: collector: collector // { "${ping.handle}" = [ { inherit (ping) packageName dueToFiles; } ] ++ (collector."${ping.handle}" or []); }) - {} - listToPing; + byMaintainer = pkgs.lib.lists.foldr + (ping: collector: collector // { "${ping.handle}" = [ { inherit (ping) packageName dueToFiles; } ] ++ (collector."${ping.handle}" or []); }) + {} + listToPing; -textForPackages = packages: - pkgs.lib.strings.concatStringsSep ", " ( - builtins.map - (pkg: pkg.packageName) + textForPackages = packages: + pkgs.lib.strings.concatStringsSep ", " ( + builtins.map (pkg: pkg.packageName) packages); -textPerMaintainer = pkgs.lib.attrsets.mapAttrs - (maintainer: packages: "- @${maintainer} for ${textForPackages packages}") - byMaintainer; + textPerMaintainer = pkgs.lib.attrsets.mapAttrs + (maintainer: packages: "- @${maintainer} for ${textForPackages packages}") + byMaintainer; packagesPerMaintainer = pkgs.lib.attrsets.mapAttrs - (maintainer: packages: - builtins.map - (pkg: pkg.packageName) - packages) + (maintainer: packages: + builtins.map (pkg: pkg.packageName) + packages) byMaintainer; in packagesPerMaintainer