Misc formatting

This commit is contained in:
Oystein Kristoffer Tveit 2021-12-15 03:25:01 +01:00
parent be91349e6a
commit a7ed77a74c

View File

@ -21,7 +21,8 @@ let
inherit (lib.strings) concatStringsSep; inherit (lib.strings) concatStringsSep;
inherit (lib.termColors.front) blue; inherit (lib.termColors.front) blue;
genWrapper = type: value: { inherit type; inherit value; }; genWrapper = type: value: { inherit type; inherit value; };
in { in
{
shellPipe = { shellPipe = {
wrap = genWrapper "shellPipe"; wrap = genWrapper "shellPipe";
apply = f: concatStringsSep " | " f.value; apply = f: concatStringsSep " | " f.value;
@ -35,7 +36,14 @@ let
}; };
# AttrSet -> Bool # AttrSet -> Bool
isFunctor = attrset: if !(attrset ? "type") then false else lib.lists.any (f: (f.wrap "").type == attrset.type) (lib.attrsets.attrValues functors); isFunctor = let
inherit (lib.lists) any;
inherit (lib.attrsets) attrValues;
in
attrset:
if !(attrset ? "type")
then false
else any (f: (f.wrap "").type == attrset.type) (attrValues functors);
in rec { in rec {
_module.args.shellOptions = { _module.args.shellOptions = {
@ -349,14 +357,16 @@ in rec {
removeNixLinks = text: let removeNixLinks = text: let
maybeMatches = builtins.match "(|.*[^)])(/nix/store/.*/bin/).*" text; maybeMatches = builtins.match "(|.*[^)])(/nix/store/.*/bin/).*" text;
matches = mapNullable (remove "") maybeMatches; matches = mapNullable (remove "") maybeMatches;
in if (maybeMatches == null) in
if (maybeMatches == null)
then text then text
else replaceStrings' matches "" text; else replaceStrings' matches "" text;
applyFunctor = attrset: let applyFunctor = attrset: let
applied = functors.${attrset.type}.stringify attrset; applied = functors.${attrset.type}.stringify attrset;
indent' = indent + (repeatString " " ((stringLength " ->") + (stringLength n))); indent' = indent + (repeatString " " ((stringLength " -> \"") + (stringLength n))) + " ";
in replaceStrings' ["\n"] ("\n" + indent') applied; in
replaceStrings' ["\n"] ("\n" + indent') applied;
recurse = stringifyCategory (level + 1) n v; recurse = stringifyCategory (level + 1) n v;
in in