about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
authorEvgeny Zemtsov <eze@resoptima.com>2023-11-01T11·58+0100
committerezemtsov <eugene.zemtsov@gmail.com>2023-11-03T13·54+0000
commite3fe6826f87e3de5f77d0ceaaad06f560d231014 (patch)
tree6f71d616370bc65c847b535134e583bb70ee94ba /tools
parent99f618bcb4301c2265122d21bc00dbb1f148c37c (diff)
fix(tools/magrathea): isolate from environment packages r/6933
This makes magrathea use the repostory version of nix and git. This is
done in the pursuit of enforcing guaranteed unified experience of
magrathea tool across all users of a `tvl-kit`-based
repository. Especially among ubuntu users with uncontrolled set of
packages and versions installed on their system.

Not having this was giving build problems for `mg build` as one of the
users has 2.17 version of nix that had inconsistent hash computation
with 2.3.

Change-Id: I3182faf4c545ac61f6cc1cc862dc23d51c1cd397
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9892
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tools')
-rw-r--r--tools/magrathea/default.nix24
1 files changed, 20 insertions, 4 deletions
diff --git a/tools/magrathea/default.nix b/tools/magrathea/default.nix
index 1d6dacf67c48..5e8019852abd 100644
--- a/tools/magrathea/default.nix
+++ b/tools/magrathea/default.nix
@@ -3,21 +3,37 @@
 # it is a tool for working with monorepos in the style of tvl's depot
 { pkgs, ... }:
 
-pkgs.stdenv.mkDerivation {
+let
+  inherit (pkgs)
+    stdenv
+    chicken
+    chickenPackages
+    makeWrapper
+    git
+    nix
+    lib
+    ;
+
+in
+stdenv.mkDerivation {
   name = "magrathea";
   src = ./.;
   dontInstall = true;
 
-  nativeBuildInputs = [ pkgs.chicken ];
-  buildInputs = with pkgs.chickenPackages.chickenEggs; [
+  nativeBuildInputs = [ chicken makeWrapper ];
+  buildInputs = with chickenPackages.chickenEggs; [
     matchable
     srfi-13
   ];
 
-  propagatedBuildInputs = [ pkgs.git ];
+  propagatedBuildInputs = [ git ];
 
   buildPhase = ''
     mkdir -p $out/bin
     csc -o $out/bin/mg -host -static ${./mg.scm}
   '';
+
+  fixupPhase = ''
+    wrapProgram $out/bin/mg --prefix PATH ${lib.makeBinPath [ nix ]}
+  '';
 }