about summary refs log tree commit diff
path: root/users/Profpatsch/tree-sitter.nix
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/tree-sitter.nix
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/tree-sitter.nix')
-rw-r--r--users/Profpatsch/tree-sitter.nix176
1 files changed, 103 insertions, 73 deletions
diff --git a/users/Profpatsch/tree-sitter.nix b/users/Profpatsch/tree-sitter.nix
index 4f81b8e7a7..2224da2a3b 100644
--- a/users/Profpatsch/tree-sitter.nix
+++ b/users/Profpatsch/tree-sitter.nix
@@ -2,17 +2,18 @@
 
 let
   bins = depot.nix.getBins pkgs.coreutils [ "head" "printf" "cat" ]
-      // depot.nix.getBins pkgs.ncurses [ "tput" ]
-      // depot.nix.getBins pkgs.bc [ "bc" ]
-      // depot.nix.getBins pkgs.ocamlPackages.sexp [ "sexp" ];
-
-  print-ast = depot.nix.writers.rustSimple {
-    name = "print-ast";
-    dependencies = with depot.third_party.rust-crates; [
-      libloading
-      tree-sitter
-    ];
-  } ''
+    // depot.nix.getBins pkgs.ncurses [ "tput" ]
+    // depot.nix.getBins pkgs.bc [ "bc" ]
+    // depot.nix.getBins pkgs.ocamlPackages.sexp [ "sexp" ];
+
+  print-ast = depot.nix.writers.rustSimple
+    {
+      name = "print-ast";
+      dependencies = with depot.third_party.rust-crates; [
+        libloading
+        tree-sitter
+      ];
+    } ''
     extern crate libloading;
     extern crate tree_sitter;
     use std::mem;
@@ -58,13 +59,14 @@ let
     };
   };
 
-  watch-file-modified = depot.nix.writers.rustSimple {
-    name = "watch-file-modified";
-    dependencies = [
-      depot.third_party.rust-crates.inotify
-      depot.users.Profpatsch.netstring.rust-netstring
-    ];
-  } ''
+  watch-file-modified = depot.nix.writers.rustSimple
+    {
+      name = "watch-file-modified";
+      dependencies = [
+        depot.third_party.rust-crates.inotify
+        depot.users.Profpatsch.netstring.rust-netstring
+      ];
+    } ''
     extern crate inotify;
     extern crate netstring;
     use inotify::{EventMask, WatchMask, Inotify};
@@ -101,75 +103,103 @@ let
   '';
 
   # clear screen and set LINES and COLUMNS to terminal height & width
-  clear-screen = depot.nix.writeExecline "clear-screen" {} [
-    "if" [ bins.tput "clear" ]
-    "backtick" "-in" "LINES" [ bins.tput "lines" ]
-    "backtick" "-in" "COLUMNS" [ bins.tput "cols" ]
+  clear-screen = depot.nix.writeExecline "clear-screen" { } [
+    "if"
+    [ bins.tput "clear" ]
+    "backtick"
+    "-in"
+    "LINES"
+    [ bins.tput "lines" ]
+    "backtick"
+    "-in"
+    "COLUMNS"
+    [ bins.tput "cols" ]
     "$@"
   ];
 
   print-nix-file = depot.nix.writeExecline "print-nix-file" { readNArgs = 1; } [
-    "pipeline" [ print-ast "${tree-sitter-nix}/parser" "tree_sitter_nix" "$1" ]
-    "pipeline" [ bins.sexp "print" ]
+    "pipeline"
+    [ print-ast "${tree-sitter-nix}/parser" "tree_sitter_nix" "$1" ]
+    "pipeline"
+    [ bins.sexp "print" ]
     clear-screen
-    "importas" "-ui" "lines" "LINES"
-    "backtick" "-in" "ls" [
+    "importas"
+    "-ui"
+    "lines"
+    "LINES"
+    "backtick"
+    "-in"
+    "ls"
+    [
       "pipeline"
-        # when you pull out bc to decrement an integer it’s time to switch to python lol
-        [ bins.printf "x=%s; --x\n" "$lines" ]
-        bins.bc
+      # when you pull out bc to decrement an integer it’s time to switch to python lol
+      [ bins.printf "x=%s; --x\n" "$lines" ]
+      bins.bc
     ]
-    "importas" "-ui" "l" "ls"
-    bins.head "-n\${l}"
+    "importas"
+    "-ui"
+    "l"
+    "ls"
+    bins.head
+    "-n\${l}"
   ];
 
   print-nix-file-on-update = depot.nix.writeExecline "print-nix-file-on-update" { readNArgs = 1; } [
-    "if" [ print-nix-file "$1" ]
-    "pipeline" [ watch-file-modified "$1" ]
-    "forstdin" "-d" "" "file"
-    "importas" "file" "file"
-    print-nix-file "$file"
+    "if"
+    [ print-nix-file "$1" ]
+    "pipeline"
+    [ watch-file-modified "$1" ]
+    "forstdin"
+    "-d"
+    ""
+    "file"
+    "importas"
+    "file"
+    "file"
+    print-nix-file
+    "$file"
   ];
 
   # copied from nixpkgs
   buildTreeSitterGrammar =
-      {
-        # language name
-        language
-        # source for the language grammar
-      , source
-      }:
-
-      pkgs.stdenv.mkDerivation {
-
-        pname = "${language}-grammar";
-        inherit (pkgs.tree-sitter) version;
-
-        src = source;
-
-        buildInputs = [ pkgs.tree-sitter ];
-
-        dontUnpack = true;
-        configurePhase= ":";
-        buildPhase = ''
-          runHook preBuild
-          scanner_cc="$src/src/scanner.cc"
-          if [ ! -f "$scanner_cc" ]; then
-            scanner_cc=""
-          fi
-          $CXX -I$src/src/ -c $scanner_cc
-          $CC -I$src/src/ -shared -o parser -Os  scanner.o $src/src/parser.c -lstdc++
-          runHook postBuild
-        '';
-        installPhase = ''
-          runHook preInstall
-          mkdir $out
-          mv parser $out/
-          runHook postInstall
-        '';
-      };
-
-in depot.nix.readTree.drvTargets {
+    {
+      # language name
+      language
+      # source for the language grammar
+    , source
+    }:
+
+    pkgs.stdenv.mkDerivation {
+
+      pname = "${language}-grammar";
+      inherit (pkgs.tree-sitter) version;
+
+      src = source;
+
+      buildInputs = [ pkgs.tree-sitter ];
+
+      dontUnpack = true;
+      configurePhase = ":";
+      buildPhase = ''
+        runHook preBuild
+        scanner_cc="$src/src/scanner.cc"
+        if [ ! -f "$scanner_cc" ]; then
+          scanner_cc=""
+        fi
+        $CXX -I$src/src/ -c $scanner_cc
+        $CC -I$src/src/ -shared -o parser -Os  scanner.o $src/src/parser.c -lstdc++
+        runHook postBuild
+      '';
+      installPhase = ''
+        runHook preInstall
+        mkdir $out
+        mv parser $out/
+        runHook postInstall
+      '';
+    };
+
+in
+depot.nix.readTree.drvTargets {
   inherit
     print-ast
     tree-sitter-nix