about summary refs log tree commit diff
path: root/users/Profpatsch/nixpkgs-rewriter
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 /users/Profpatsch/nixpkgs-rewriter
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 'users/Profpatsch/nixpkgs-rewriter')
-rw-r--r--users/Profpatsch/nixpkgs-rewriter/default.nix128
1 files changed, 82 insertions, 46 deletions
diff --git a/users/Profpatsch/nixpkgs-rewriter/default.nix b/users/Profpatsch/nixpkgs-rewriter/default.nix
index 787162d4973a..0740a870aa4a 100644
--- a/users/Profpatsch/nixpkgs-rewriter/default.nix
+++ b/users/Profpatsch/nixpkgs-rewriter/default.nix
@@ -8,12 +8,12 @@ let
     ;
 
   bins = depot.nix.getBins pkgs.coreutils [ "head" "shuf" ]
-      // depot.nix.getBins pkgs.jq [ "jq" ]
-      // depot.nix.getBins pkgs.findutils [ "xargs" ]
-      // depot.nix.getBins pkgs.gnused [ "sed" ]
-      ;
+    // depot.nix.getBins pkgs.jq [ "jq" ]
+    // depot.nix.getBins pkgs.findutils [ "xargs" ]
+    // depot.nix.getBins pkgs.gnused [ "sed" ]
+  ;
 
-  export-json-object = pkgs.writers.writePython3 "export-json-object" {} ''
+  export-json-object = pkgs.writers.writePython3 "export-json-object" { } ''
     import json
     import sys
     import os
@@ -29,34 +29,50 @@ let
     os.execvp(sys.argv[1], sys.argv[1:])
   '';
 
-  meta-stdenv-lib = pkgs.writers.writeHaskell "meta-stdenv-lib" {
-    libraries = [
-      pkgs.haskellPackages.hnix
-      pkgs.haskellPackages.aeson
-    ];
-  } ./MetaStdenvLib.hs;
+  meta-stdenv-lib = pkgs.writers.writeHaskell "meta-stdenv-lib"
+    {
+      libraries = [
+        pkgs.haskellPackages.hnix
+        pkgs.haskellPackages.aeson
+      ];
+    } ./MetaStdenvLib.hs;
 
   replace-between-lines = writeExecline "replace-between-lines" { readNArgs = 1; } [
-    "importas" "-ui" "file" "fileName"
-    "importas" "-ui" "from" "fromLine"
-    "importas" "-ui" "to" "toLine"
-    "if" [ depot.tools.eprintf "%s-%s\n" "$from" "$to" ]
+    "importas"
+    "-ui"
+    "file"
+    "fileName"
+    "importas"
+    "-ui"
+    "from"
+    "fromLine"
+    "importas"
+    "-ui"
+    "to"
+    "toLine"
+    "if"
+    [ depot.tools.eprintf "%s-%s\n" "$from" "$to" ]
     (debugExec "adding lib")
     bins.sed
-      "-e" "\${from},\${to} \${1}"
-      "-i" "$file"
+    "-e"
+    "\${from},\${to} \${1}"
+    "-i"
+    "$file"
   ];
 
   add-lib-if-necessary = writeExecline "add-lib-if-necessary" { readNArgs = 1; } [
-    "pipeline" [ meta-stdenv-lib "$1" ]
-     export-json-object
-     # first replace any stdenv.lib mentions in the arg header
-     # if this is not done, the replace below kills these.
-     # Since we want it anyway ultimately, let’s do it here.
-     "if" [ replace-between-lines "s/stdenv\.lib/lib/" ]
-     # then add the lib argument
-     # (has to be before stdenv, otherwise default arguments might be in the way)
-     replace-between-lines "s/stdenv/lib, stdenv/"
+    "pipeline"
+    [ meta-stdenv-lib "$1" ]
+    export-json-object
+    # first replace any stdenv.lib mentions in the arg header
+    # if this is not done, the replace below kills these.
+    # Since we want it anyway ultimately, let’s do it here.
+    "if"
+    [ replace-between-lines "s/stdenv\.lib/lib/" ]
+    # then add the lib argument
+    # (has to be before stdenv, otherwise default arguments might be in the way)
+    replace-between-lines
+    "s/stdenv/lib, stdenv/"
   ];
 
   metaString = ''meta = with stdenv.lib; {'';
@@ -80,33 +96,53 @@ let
   '';
 
   instantiate-nixpkgs-randomly = writeExecline "instantiate-nixpkgs-randomly" { readNArgs = 1; } [
-    "export" "NIXPKGS_ALLOW_BROKEN" "1"
-    "export" "NIXPKGS_ALLOW_UNFREE" "1"
-    "export" "NIXPKGS_ALLOW_INSECURE" "1"
-    "export" "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM" "1"
-    "pipeline" [
+    "export"
+    "NIXPKGS_ALLOW_BROKEN"
+    "1"
+    "export"
+    "NIXPKGS_ALLOW_UNFREE"
+    "1"
+    "export"
+    "NIXPKGS_ALLOW_INSECURE"
+    "1"
+    "export"
+    "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM"
+    "1"
+    "pipeline"
+    [
       "nix"
-        "eval"
-        "--raw"
-        ''(
+      "eval"
+      "--raw"
+      ''(
           let pkgs = import ''${1} {};
           in builtins.toJSON (builtins.attrNames pkgs)
         )''
     ]
-    "pipeline" [ bins.jq "-r" ".[]" ]
-    "pipeline" [ bins.shuf ]
-    "pipeline" [ bins.head "-n" "1000" ]
-    bins.xargs "-I" "{}" "-n1"
-    "if" [ depot.tools.eprintf "instantiating %s\n" "{}" ]
-    "nix-instantiate" "$1" "-A" "{}"
+    "pipeline"
+    [ bins.jq "-r" ".[]" ]
+    "pipeline"
+    [ bins.shuf ]
+    "pipeline"
+    [ bins.head "-n" "1000" ]
+    bins.xargs
+    "-I"
+    "{}"
+    "-n1"
+    "if"
+    [ depot.tools.eprintf "instantiating %s\n" "{}" ]
+    "nix-instantiate"
+    "$1"
+    "-A"
+    "{}"
   ];
 
-in depot.nix.readTree.drvTargets {
+in
+depot.nix.readTree.drvTargets {
   inherit
-   instantiate-nixpkgs-randomly
-  # requires hnix, which we don’t want in tvl for now
-  # uncomment manually if you want to use it.
-  #   meta-stdenv-lib
-  #   replace-stdenv-lib
+    instantiate-nixpkgs-randomly
+    # requires hnix, which we don’t want in tvl for now
+    # uncomment manually if you want to use it.
+    #   meta-stdenv-lib
+    #   replace-stdenv-lib
     ;
 }