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 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 custom/notify-user.nix (limited to 'custom') 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 + ''; +} -- cgit v1.2.3