about summary refs log tree commit diff
path: root/pkgs/applications/editors/sublime3
diff options
context:
space:
mode:
authorDemin Dmitriy <demindf@gmail.com>2015-10-24 18:14:59 +0300
committerDemin Dmitriy <demindf@gmail.com>2015-10-24 18:14:59 +0300
commitc66f8b293b873e07d0b2de49d9741ffc035baa03 (patch)
treec571258e61632ec87ebd56c3b608d95d31ffa84b /pkgs/applications/editors/sublime3
parent0cea20a6522ed0d84d39c550e46f1d755176adcc (diff)
downloadnixlib-c66f8b293b873e07d0b2de49d9741ffc035baa03.tar
nixlib-c66f8b293b873e07d0b2de49d9741ffc035baa03.tar.gz
nixlib-c66f8b293b873e07d0b2de49d9741ffc035baa03.tar.bz2
nixlib-c66f8b293b873e07d0b2de49d9741ffc035baa03.tar.lz
nixlib-c66f8b293b873e07d0b2de49d9741ffc035baa03.tar.xz
nixlib-c66f8b293b873e07d0b2de49d9741ffc035baa03.tar.zst
nixlib-c66f8b293b873e07d0b2de49d9741ffc035baa03.zip
sublime3: add pkexec and gksudo support
Diffstat (limited to 'pkgs/applications/editors/sublime3')
-rw-r--r--pkgs/applications/editors/sublime3/default.nix14
1 files changed, 13 insertions, 1 deletions
diff --git a/pkgs/applications/editors/sublime3/default.nix b/pkgs/applications/editors/sublime3/default.nix
index b26d27a8bc51..aa5492dbe7ad 100644
--- a/pkgs/applications/editors/sublime3/default.nix
+++ b/pkgs/applications/editors/sublime3/default.nix
@@ -1,10 +1,15 @@
-{ fetchurl, stdenv, glib, xorg, cairo, gtk, pango, makeWrapper, openssl, bzip2 }:
+{ fetchurl, stdenv, glib, xorg, cairo, gtk, pango, makeWrapper, openssl, bzip2,
+  pkexecPath ? "/var/setuid-wrappers/pkexec", libredirect,
+  gksuSupport ? false, gksu}:
 
 assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
+assert gksuSupport -> gksu != null;
 
 let
   build = "3083";
   libPath = stdenv.lib.makeLibraryPath [glib xorg.libX11 gtk cairo pango];
+  redirects = [ "/usr/bin/pkexec=${pkexecPath}" ]
+    ++ stdenv.lib.optional gksuSupport "/usr/bin/gksudo=${gksu}/bin/gksudo";
 in let
   # package with just the binaries
   sublime = stdenv.mkDerivation {
@@ -35,6 +40,9 @@ in let
           --set-rpath ${libPath}:${stdenv.cc.cc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"} \
           $i
       done
+
+      # Rewrite pkexec|gksudo argument. Note that we can't delete bytes in binary.
+      sed -i -e 's,/bin/cp\x00,cp\x00\x00\x00\x00\x00\x00,g' sublime_text
     '';
 
     installPhase = ''
@@ -44,6 +52,10 @@ in let
       mkdir -p $out
       cp -prvd * $out/
 
+      wrapProgram $out/sublime_text \
+        --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
+        --set NIX_REDIRECTS ${builtins.concatStringsSep ":" redirects}
+
       # Without this, plugin_host crashes, even though it has the rpath
       wrapProgram $out/plugin_host --prefix LD_PRELOAD : ${stdenv.cc.cc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"}/libgcc_s.so.1:${openssl}/lib/libssl.so:${bzip2}/lib/libbz2.so
     '';