about summary refs log tree commit diff
path: root/tools/tvlc/default.nix
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-08-21T01·15-0700
committerkanepyork <rikingcoding@gmail.com>2020-08-25T22·34+0000
commita9650041bb73366d9be73bcbe34faf8694f9aa2c (patch)
treebf9a6aa435d1cb1a2dbd9ae9bf866578fe8ca7a3 /tools/tvlc/default.nix
parente5392420325cda9070d1a3d47f5ef3f4b03489b1 (diff)
feat(tools/tvlc): pass list of derivations to depot-scanner r/1711
You can now provide a list of Nix derivations to tvlc to get a git worktree + sparse-checkout containing only the paths needed to build the specified derivations.

Known bugs: even though //third_party is only passed to readdir(), git doesn't know this and includes all of //third_party/*.

Change-Id: I9dccebd3fbff4bb04ebd568175cf0a7e37d71ab3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1826
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'tools/tvlc/default.nix')
-rw-r--r--tools/tvlc/default.nix25
1 files changed, 20 insertions, 5 deletions
diff --git a/tools/tvlc/default.nix b/tools/tvlc/default.nix
index de18af236fdd..ef0c69927fef 100644
--- a/tools/tvlc/default.nix
+++ b/tools/tvlc/default.nix
@@ -1,17 +1,31 @@
 { pkgs, depot, ... }:
 
 let
-  commonsh = ./common.sh;
-
-  # TODO(riking): path deduction
-  #tvix-instantiate="${third_party.nix}/bin/nix-instantiate"
   pathScripts = pkgs.writeShellScript "imports" ''
+    export tvix_instantiate="${depot.third_party.nix}/bin/nix-instantiate"
+    export depot_scanner="${depot.tools.depot-scanner}/bin/depot-scanner"
   '';
 
   # setup: git rev-parse --show-toplevel > $tvlc_root/depot_root
   # setup: mkdir $tvlc_root/clients
   # setup: echo 1 > $tvlc_root/next_clientid
 
+  commonsh = pkgs.stdenv.mkDerivation {
+    name = "common.sh";
+    src = ./common.sh;
+    doCheck = true;
+    unpackPhase = "true";
+    buildPhase = ''
+      substitute ${./common.sh} $out --replace path-scripts ${pathScripts}
+    '';
+    checkPhase = ''
+      ${pkgs.shellcheck}/bin/shellcheck $out ${pathScripts} && echo "SHELLCHECK OK"
+    '';
+    installPhase = ''
+      chmod +x $out
+    '';
+  };
+
   tvlcNew = pkgs.stdenv.mkDerivation {
     name = "tvlc-new";
     src = ./tvlc-new;
@@ -22,7 +36,7 @@ let
       substitute ${./tvlc-new} $out --replace common.sh ${commonsh}
     '';
     checkPhase = ''
-      ${pkgs.shellcheck}/bin/shellcheck $out ${commonsh} && echo "SHELLCHECK OK"
+      ${pkgs.shellcheck}/bin/shellcheck $out ${commonsh} ${pathScripts} && echo "SHELLCHECK OK"
     '';
     installPhase = ''
       chmod +x $out
@@ -30,6 +44,7 @@ let
   };
 
 in pkgs.stdenv.mkDerivation rec {
+  inherit pathScripts;
   inherit commonsh;
   inherit tvlcNew;
 }