about summary refs log tree commit diff
path: root/pkgs/by-name/ha
diff options
context:
space:
mode:
authorCoutinho de Souza <dev@onemoresuza.com>2024-05-16 13:09:03 -0300
committerCoutinho de Souza <dev@onemoresuza.com>2024-05-16 13:09:03 -0300
commitb155c656a0ebd9b1bcdcf1f281a72ee58677b9fb (patch)
tree75fb01e72c6ca709b26894acae21324ec37a9032 /pkgs/by-name/ha
parentd3195bd6d58c52397d6401406ae386a0e7caf5cc (diff)
haredo: remove shell wrapper overhead
There's only three mentions of `sh` in the source code, being only two
of them command calls; thus, is very trivial to patch them directly.
Diffstat (limited to 'pkgs/by-name/ha')
-rw-r--r--pkgs/by-name/ha/haredo/001-use-nix-store-sh.patch20
-rw-r--r--pkgs/by-name/ha/haredo/package.nix14
2 files changed, 29 insertions, 5 deletions
diff --git a/pkgs/by-name/ha/haredo/001-use-nix-store-sh.patch b/pkgs/by-name/ha/haredo/001-use-nix-store-sh.patch
new file mode 100644
index 0000000000000..4bd6507d7ea45
--- /dev/null
+++ b/pkgs/by-name/ha/haredo/001-use-nix-store-sh.patch
@@ -0,0 +1,20 @@
+diff --git a/src/haredo.ha b/src/haredo.ha
+index c2e56e6..304c9ad 100644
+--- a/src/haredo.ha
++++ b/src/haredo.ha
+@@ -280,12 +280,12 @@ fn try_do(
+ 	const tmpfilepath = strings::concat(ctx.tmpdir, "/", tmpfilename);
+ 
+ 	const cmd = if (ctx.verbose) {
+-		fmt::errorln("* sh -ev", dopaths.do, dopaths.target,
++		fmt::errorln("* @bash@/bin/sh -ev", dopaths.do, dopaths.target,
+ 			dopaths.basename, tmpfilepath)?;
+-		yield exec::cmd("sh", "-ev", dopaths.do, dopaths.target,
++		yield exec::cmd("@bash@/bin/sh", "-ev", dopaths.do, dopaths.target,
+ 			dopaths.basename, tmpfilepath)?;
+ 	} else {
+-		yield exec::cmd("sh", "-e", dopaths.do, dopaths.target,
++		yield exec::cmd("@bash@/bin/sh", "-e", dopaths.do, dopaths.target,
+ 			dopaths.basename, tmpfilepath)?;
+ 	};
+ 
diff --git a/pkgs/by-name/ha/haredo/package.nix b/pkgs/by-name/ha/haredo/package.nix
index b3b0a345d258d..a6db89149eb8c 100644
--- a/pkgs/by-name/ha/haredo/package.nix
+++ b/pkgs/by-name/ha/haredo/package.nix
@@ -7,6 +7,7 @@
   nix-update-script,
   makeWrapper,
   bash,
+  substituteAll,
 }:
 stdenv.mkDerivation (finalAttrs: {
   pname = "haredo";
@@ -24,6 +25,14 @@ stdenv.mkDerivation (finalAttrs: {
     hash = "sha256-gpui5FVRw3NKyx0AB/4kqdolrl5vkDudPOgjHc/IE4U=";
   };
 
+  patches = [
+    # Use nix store's bash instead of sh. `@bash@/bin/sh` is used, since haredo expects a posix shell.
+    (substituteAll {
+      src = ./001-use-nix-store-sh.patch;
+      inherit bash;
+    })
+  ];
+
   nativeBuildInputs = [
     hare
     makeWrapper
@@ -66,11 +75,6 @@ stdenv.mkDerivation (finalAttrs: {
     runHook postInstall
   '';
 
-  postFixup = ''
-    wrapProgram $out/bin/haredo \
-      --prefix PATH : "${lib.makeBinPath [ bash ]}"
-  '';
-
   setupHook = ./setup-hook.sh;
 
   passthru.updateScript = nix-update-script { };