about summary refs log tree commit diff
path: root/nix/buildGo/external
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-01-30T16·06+0300
committertazjin <tazjin@tvl.su>2022-01-31T16·11+0000
commitaa122cbae78ce97d60c0c98ba14df753d97e40b1 (patch)
tree12b98d85c4b18fe870feb26de70db9ba61837bd7 /nix/buildGo/external
parent2d10d60fac0fd00a71b65cfdcb9fba0477b2086c (diff)
style: format entire depot with nixpkgs-fmt r/3723
This CL can be used to compare the style of nixpkgs-fmt against other
formatters (nixpkgs, alejandra).

Change-Id: I87c6abff6bcb546b02ead15ad0405f81e01b6d9e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4397
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: lukegb <lukegb@tvl.fyi>
Reviewed-by: wpcarro <wpcarro@gmail.com>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Reviewed-by: cynthia <cynthia@tvl.fyi>
Reviewed-by: edef <edef@edef.eu>
Reviewed-by: eta <tvl@eta.st>
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'nix/buildGo/external')
-rw-r--r--nix/buildGo/external/default.nix50
1 files changed, 32 insertions, 18 deletions
diff --git a/nix/buildGo/external/default.nix b/nix/buildGo/external/default.nix
index 6540faf04c36..f713783a58be 100644
--- a/nix/buildGo/external/default.nix
+++ b/nix/buildGo/external/default.nix
@@ -17,12 +17,12 @@ let
 
   inherit (pkgs) lib runCommand go jq ripgrep;
 
-  pathToName = p: replaceStrings ["/"] ["_"] (toString p);
+  pathToName = p: replaceStrings [ "/" ] [ "_" ] (toString p);
 
   # Collect all non-vendored dependencies from the Go standard library
   # into a file that can be used to filter them out when processing
   # dependencies.
-  stdlibPackages = runCommand "stdlib-pkgs.json" {} ''
+  stdlibPackages = runCommand "stdlib-pkgs.json" { } ''
     export HOME=$PWD
     export GOPATH=/dev/null
     ${go}/bin/go list std | \
@@ -45,20 +45,28 @@ let
   };
 
   mkset = path: value:
-    if path == [] then { gopkg = value; }
+    if path == [ ] then { gopkg = value; }
     else { "${head path}" = mkset (tail path) value; };
 
   last = l: elemAt l ((length l) - 1);
 
   toPackage = self: src: path: depMap: entry:
     let
-      localDeps = map (d: lib.attrByPath (d ++ [ "gopkg" ]) (
-        throw "missing local dependency '${lib.concatStringsSep "." d}' in '${path}'"
-      ) self) entry.localDeps;
-
-      foreignDeps = map (d: lib.attrByPath [ d.path ] (
-        throw "missing foreign dependency '${d.path}' in '${path}, imported at ${d.position}'"
-      ) depMap) entry.foreignDeps;
+      localDeps = map
+        (d: lib.attrByPath (d ++ [ "gopkg" ])
+          (
+            throw "missing local dependency '${lib.concatStringsSep "." d}' in '${path}'"
+          )
+          self)
+        entry.localDeps;
+
+      foreignDeps = map
+        (d: lib.attrByPath [ d.path ]
+          (
+            throw "missing foreign dependency '${d.path}' in '${path}, imported at ${d.position}'"
+          )
+          depMap)
+        entry.foreignDeps;
 
       args = {
         srcs = map (f: src + ("/" + f)) entry.files;
@@ -74,22 +82,28 @@ let
       binArgs = args // {
         name = (last ((lib.splitString "/" path) ++ entry.locator));
       };
-    in if entry.isCommand then (program binArgs) else (package libArgs);
+    in
+    if entry.isCommand then (program binArgs) else (package libArgs);
 
-in { src, path, deps ? [] }: let
+in
+{ src, path, deps ? [ ] }:
+let
   # Build a map of dependencies (from their import paths to their
   # derivation) so that they can be conditionally imported only in
   # sub-packages that require them.
-  depMap = listToAttrs (map (d: {
-    name = d.goImportPath;
-    value = d;
-  }) (map (d: d.gopkg) deps));
+  depMap = listToAttrs (map
+    (d: {
+      name = d.goImportPath;
+      value = d;
+    })
+    (map (d: d.gopkg) deps));
 
   name = pathToName path;
-  analysisOutput = runCommand "${name}-structure.json" {} ''
+  analysisOutput = runCommand "${name}-structure.json" { } ''
     ${analyser}/bin/analyser -path ${path} -source ${src} > $out
   '';
   analysis = fromJSON (readFile analysisOutput);
-in lib.fix(self: foldl' lib.recursiveUpdate {} (
+in
+lib.fix (self: foldl' lib.recursiveUpdate { } (
   map (entry: mkset entry.locator (toPackage self src path depMap entry)) analysis
 ))