summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <pngwjpgh@users.noreply.github.com>2016-07-21 16:42:03 +0200
committerGregor Kleen <pngwjpgh@users.noreply.github.com>2016-07-21 16:42:03 +0200
commitf670428abfce7f2d38358a15a0da22c17943736f (patch)
treef0086d83330e85d7a9fa85847ebcd46d9106270d
parentc93c2951a71c3c88806db829a41ae34799d4c84a (diff)
downloadnixos-f670428abfce7f2d38358a15a0da22c17943736f.tar
nixos-f670428abfce7f2d38358a15a0da22c17943736f.tar.gz
nixos-f670428abfce7f2d38358a15a0da22c17943736f.tar.bz2
nixos-f670428abfce7f2d38358a15a0da22c17943736f.tar.xz
nixos-f670428abfce7f2d38358a15a0da22c17943736f.zip
better notify-gkleen
-rw-r--r--custom/notify-user.nix29
-rw-r--r--hel.nix9
2 files changed, 37 insertions, 1 deletions
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 @@
1{ stdenv, writeTextFile
2, ghcWithPackages
3, user ? "gkleen"
4, libnotify
5}:
6
7stdenv.mkDerivation {
8 name = ''notify-${user}'';
9 src = writeTextFile { name = ''notify-${user}.hs''; text = ''
10 import Control.Shell
11 import System.FilePath.Glob (glob)
12
13 import Data.List (isPrefixOf)
14
15 main = shell_ $ do
16 (envFile:_) <- liftIO $ glob "/home/${user}/.dbus/session-bus/*-0"
17 sessionAddr <- snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> input envFile
18 env <- getShellEnv
19 withEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr $ run "${libnotify}/bin/notify-send" cmdline
20 ''; };
21 phases = [ "buildPhase" "installPhase" ];
22 buildPhase = ''
23 ${ghcWithPackages (p: with p; [ shellmate Glob ])}/bin/ghc -odir . -hidir . $src -o notify-${user}
24 '';
25 installPhase = ''
26 mkdir -p $out/bin
27 cp notify-${user} $out/bin
28 '';
29}
diff --git a/hel.nix b/hel.nix
index 68998d3b..95532a8a 100644
--- a/hel.nix
+++ b/hel.nix
@@ -248,7 +248,14 @@
248 248
249 setuidPrograms = ["slock" "mount" "mount.nfs" "umount" "newgrp" "thinklight"]; 249 setuidPrograms = ["slock" "mount" "mount.nfs" "umount" "newgrp" "thinklight"];
250 250
251 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; } 251 setuidOwners = [ { group = "users";
252 owner = "gkleen";
253 permissions = "u+rx,g+x,o+x";
254 program = "notify-gkleen";
255 setgid = true;
256 setuid = true;
257 source = pkgs.callPackage ./notify-user.nix { inherit (pkgs.haskellPackages) ghcWithPackages; user = "gkleen"; };
258 }
252 ]; 259 ];
253 }; 260 };
254 261