Format with nixfmt-rfc-style
This commit is contained in:
parent
6efb6110a6
commit
82b543859f
85
default.nix
85
default.nix
|
@ -1,44 +1,81 @@
|
||||||
{ pkgs ? import <nixpkgs> {}, ... }: let
|
{
|
||||||
inherit (builtins) genericClosure hasAttr length map;
|
pkgs ? import <nixpkgs> { },
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (builtins)
|
||||||
|
genericClosure
|
||||||
|
hasAttr
|
||||||
|
length
|
||||||
|
map
|
||||||
|
;
|
||||||
inherit (pkgs) runCommandLocal writeText;
|
inherit (pkgs) runCommandLocal writeText;
|
||||||
inherit (pkgs.lib) concatLines concatLists concatMap filter isDerivation isList mapAttrsToList;
|
inherit (pkgs.lib)
|
||||||
in rec {
|
concatLines
|
||||||
|
concatLists
|
||||||
|
concatMap
|
||||||
|
filter
|
||||||
|
isDerivation
|
||||||
|
isList
|
||||||
|
mapAttrsToList
|
||||||
|
;
|
||||||
|
in
|
||||||
|
rec {
|
||||||
drvOutputs = drv: if hasAttr "outputs" drv then map (out: drv.${out}) drv.outputs else [ drv ];
|
drvOutputs = drv: if hasAttr "outputs" drv then map (out: drv.${out}) drv.outputs else [ drv ];
|
||||||
drvDeps = drv:
|
drvDeps =
|
||||||
mapAttrsToList (k: v:
|
drv:
|
||||||
if isDerivation v then (drvOutputs v)
|
mapAttrsToList (
|
||||||
else if isList v then concatMap drvOutputs (filter isDerivation v)
|
k: v:
|
||||||
else []
|
if isDerivation v then
|
||||||
|
(drvOutputs v)
|
||||||
|
else if isList v then
|
||||||
|
concatMap drvOutputs (filter isDerivation v)
|
||||||
|
else
|
||||||
|
[ ]
|
||||||
) drv;
|
) drv;
|
||||||
drvClosure = let
|
drvClosure =
|
||||||
wrap = drv: { key = drv.outPath; inherit drv; };
|
let
|
||||||
in drv: map (obj: obj.drv) (genericClosure {
|
wrap = drv: {
|
||||||
|
key = drv.outPath;
|
||||||
|
inherit drv;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
drv:
|
||||||
|
map (obj: obj.drv) (genericClosure {
|
||||||
startSet = map wrap (drvOutputs drv);
|
startSet = map wrap (drvOutputs drv);
|
||||||
operator = obj: map wrap (concatLists (drvDeps obj.drv.drvAttrs));
|
operator = obj: map wrap (concatLists (drvDeps obj.drv.drvAttrs));
|
||||||
});
|
});
|
||||||
drvMaintainers = drv:
|
drvMaintainers =
|
||||||
if ! hasAttr "meta" drv then []
|
drv:
|
||||||
else if ! hasAttr "maintainers" drv.meta then []
|
if !hasAttr "meta" drv then
|
||||||
else drv.meta.maintainers;
|
[ ]
|
||||||
nobodyMaintains = drv:
|
else if !hasAttr "maintainers" drv.meta then
|
||||||
hasAttr "meta" drv &&
|
[ ]
|
||||||
hasAttr "maintainers" drv.meta &&
|
else
|
||||||
(length drv.meta.maintainers) == 0;
|
drv.meta.maintainers;
|
||||||
|
nobodyMaintains =
|
||||||
|
drv: hasAttr "meta" drv && hasAttr "maintainers" drv.meta && (length drv.meta.maintainers) == 0;
|
||||||
stringJoin = objToString: objs: writeText "txt" (concatLines (map objToString objs));
|
stringJoin = objToString: objs: writeText "txt" (concatLines (map objToString objs));
|
||||||
|
|
||||||
allMaintainers = drv: let
|
allMaintainers =
|
||||||
|
drv:
|
||||||
|
let
|
||||||
closure = drvClosure drv;
|
closure = drvClosure drv;
|
||||||
maintainers = concatMap drvMaintainers closure;
|
maintainers = concatMap drvMaintainers closure;
|
||||||
mainToString = m: "${m.name} (${m.email})";
|
mainToString = m: "${m.name} (${m.email})";
|
||||||
in runCommandLocal "uniq-maintainers.txt" {} ''
|
in
|
||||||
|
runCommandLocal "uniq-maintainers.txt" { } ''
|
||||||
<${stringJoin mainToString maintainers} sort | uniq -c > $out
|
<${stringJoin mainToString maintainers} sort | uniq -c > $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
noMaintainers = drv: let
|
noMaintainers =
|
||||||
|
drv:
|
||||||
|
let
|
||||||
closure = drvClosure drv;
|
closure = drvClosure drv;
|
||||||
unmaintained = filter nobodyMaintains closure;
|
unmaintained = filter nobodyMaintains closure;
|
||||||
drvToString = drv: "${drv.name} ${drv.meta.position}";
|
drvToString = drv: "${drv.name} ${drv.meta.position}";
|
||||||
in runCommandLocal "no-maintainers.txt" {} ''
|
in
|
||||||
|
runCommandLocal "no-maintainers.txt" { } ''
|
||||||
<${stringJoin drvToString unmaintained} sort -u \
|
<${stringJoin drvToString unmaintained} sort -u \
|
||||||
| sed 's/\/nix\/store\/[^/]*/https:\/\/github.com\/NixOS\/nixpkgs\/blob\/master/' \
|
| sed 's/\/nix\/store\/[^/]*/https:\/\/github.com\/NixOS\/nixpkgs\/blob\/master/' \
|
||||||
| sed 's/.nix:\(.*\)$/#L\1/' \
|
| sed 's/.nix:\(.*\)$/#L\1/' \
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
{
|
{
|
||||||
outputs = { self, nixpkgs, ... }: let
|
outputs =
|
||||||
|
{ self, nixpkgs, ... }:
|
||||||
|
let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
lib = import ./default.nix { inherit pkgs; };
|
lib = import ./default.nix { inherit pkgs; };
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
bundlers."x86_64-linux" = rec {
|
bundlers."x86_64-linux" = rec {
|
||||||
default = adopt;
|
default = adopt;
|
||||||
maintainers = lib.allMaintainers;
|
maintainers = lib.allMaintainers;
|
||||||
adopt = lib.noMaintainers;
|
adopt = lib.noMaintainers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
formatter."x86_64-linux" = pkgs.nixfmt-rfc-style;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue