From f670428abfce7f2d38358a15a0da22c17943736f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 21 Jul 2016 16:42:03 +0200 Subject: better notify-gkleen --- custom/notify-user.nix | 29 +++++++++++++++++++++++++++++ hel.nix | 9 ++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) 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..f7fbc7c0 --- /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 + cp notify-${user} $out/bin + ''; +} diff --git a/hel.nix b/hel.nix index 68998d3b..95532a8a 100644 --- a/hel.nix +++ b/hel.nix @@ -248,7 +248,14 @@ setuidPrograms = ["slock" "mount" "mount.nfs" "umount" "newgrp" "thinklight"]; - setuidOwners = [ { group = "users"; owner = "gkleen"; permissions = "u+rx,g+x,o+x"; program = "notify-gkleen"; source = ''${pkgs.libnotify}/bin/notify-send''; setgid = true; setuid = true; } + setuidOwners = [ { group = "users"; + owner = "gkleen"; + permissions = "u+rx,g+x,o+x"; + program = "notify-gkleen"; + setgid = true; + setuid = true; + source = pkgs.callPackage ./notify-user.nix { inherit (pkgs.haskellPackages) ghcWithPackages; user = "gkleen"; }; + } ]; }; -- cgit v1.2.3