{ 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 cp notify-${user} $out/bin ''; }