From 36804c75e484810173ed448a55f20c5c77ef628d Mon Sep 17 00:00:00 2001
From: Michael Raskin <7c6f434c@mail.ru>
Date: Sat, 15 Oct 2016 15:28:12 +0200
Subject: [PATCH] singular: Wrap executables instead of symlinking

This way config scripts can fidn out their own location
---
 pkgs/applications/science/math/singular/default.nix | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pkgs/applications/science/math/singular/default.nix b/pkgs/applications/science/math/singular/default.nix
index 73c0d7ca5108..6cd66c62a0ad 100644
--- a/pkgs/applications/science/math/singular/default.nix
+++ b/pkgs/applications/science/math/singular/default.nix
@@ -33,7 +33,11 @@ stdenv.mkDerivation rec {
     binaries="$(find "$out"/* \( -type f -o -type l \) -perm -111 \! -name '*.so' -maxdepth 1)"
     ln -s "$out"/*/{include,lib} "$out"
     mkdir -p "$out/bin"
-    ln -s $binaries "$out/bin"
+    for b in $binaries; do
+      bbn="$(basename "$b")"
+      echo -e '#! ${stdenv.shell}\n"'"$b"'" "$@"' > "$out/bin/$bbn"
+      chmod a+x "$out/bin/$bbn"
+    done
   '';
 
   enableParallelBuild = true;