From 9f6e296ad8ab3546aebb5da4b99a770546603a13 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 21 Jul 2016 21:07:32 +0200 Subject: revert to more complicated version of notify-user --- custom/notify-user.nix | 29 +++++++++++++++++++++++++++++ hel.nix | 9 +-------- 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 custom/notify-user.nix diff --git a/custom/notify-user.nix b/custom/notify-user.nix new file mode 100644 index 00000000..ae8ea56c --- /dev/null +++ b/custom/notify-user.nix @@ -0,0 +1,29 @@ +{ stdenv, writeTextFile +, ghcWithPackages +, user ? "gkleen" +, libnotify +}: + +stdenv.mkDerivation { + name = ''notify-${user}''; + src = writeTextFile { name = ''notify-${user}.hs''; text = '' + import Control.Shell + import System.FilePath.Glob (glob) + + import Data.List (isPrefixOf) + + main = shell_ $ do + (envFile:_) <- liftIO $ glob "/home/${user}/.dbus/session-bus/*-0" + sessionAddr <- snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> input envFile + env <- getShellEnv + withEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr $ run "${libnotify}/bin/notify-send" cmdline + ''; }; + phases = [ "buildPhase" "installPhase" ]; + buildPhase = '' + ${ghcWithPackages (p: with p; [ shellmate Glob ])}/bin/ghc -odir . -hidir . $src -o notify-${user} + ''; + installPhase = '' + mkdir -p $out/bin + install -m 755 notify-${user} $out/bin + ''; +} diff --git a/hel.nix b/hel.nix index 13d0c6e5..4255dcca 100644 --- a/hel.nix +++ b/hel.nix @@ -254,14 +254,7 @@ program = "notify-gkleen"; setgid = true; setuid = true; - source = pkgs.writeScript "notify-gkleen" '' - #!${pkgs.zsh}/bin/zsh - - trap "exit 0" EXIT - - DBUS_ADDRESS=$(grep "DBUS_SESSION_BUS_ADDRESS=" /home/gkleen/.dbus/session-bus/${"*"} | cut -d "=" -f 2-) - exec env DBUS_SESSION_BUS_ADDRESS=''${DBUS_ADDRESS} ${pkgs.libnotify}/bin/notify-send $@ - ''; + source = pkgs.callPackage ./custom/notify-user.nix { inherit (pkgs.haskellPackages) ghcWithPackages; }; } ]; }; -- cgit v1.2.3