about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix
new file mode 100644
index 00000000..0e2caf1b
--- /dev/null
+++ b/lib/default.nix
@@ -0,0 +1,20 @@
+{
+  pkgs,
+  shell-library,
+  ...
+}: {
+  makeShellScriptWithLibrary = {
+    dependencies,
+    name,
+    script,
+    ...
+  }:
+    pkgs.runCommandLocal name {
+      nativeBuildInputs = [pkgs.makeWrapper] ++ dependencies;
+    } ''
+      install -m755 ${script} -D "$out/bin/${name}"
+      sed -i 's|%SHELL_LIBRARY_PATH|${shell-library}/lib|' "$out/bin/${name}"
+      patchShebangs "$out/bin/${name}"
+      wrapProgram "$out/bin/${name}" --prefix PATH : ${pkgs.lib.makeBinPath dependencies}
+    '';
+}