summaryrefslogtreecommitdiff
path: root/custom/notify-users.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2018-06-02 17:58:57 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2018-06-02 17:58:57 +0200
commitd49dd672463aff72bd754d657abbd11cf8a0d8e0 (patch)
tree87f2c40733ec18528a518013f84e2dd523d15f66 /custom/notify-users.nix
parent329245b4e3b9a2a9bbf7afd4570d7da311c58a42 (diff)
downloadnixos-d49dd672463aff72bd754d657abbd11cf8a0d8e0.tar
nixos-d49dd672463aff72bd754d657abbd11cf8a0d8e0.tar.gz
nixos-d49dd672463aff72bd754d657abbd11cf8a0d8e0.tar.bz2
nixos-d49dd672463aff72bd754d657abbd11cf8a0d8e0.tar.xz
nixos-d49dd672463aff72bd754d657abbd11cf8a0d8e0.zip
revamp uucp-mediaclient
Diffstat (limited to 'custom/notify-users.nix')
-rw-r--r--custom/notify-users.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/custom/notify-users.nix b/custom/notify-users.nix
new file mode 100644
index 00000000..e68b0be2
--- /dev/null
+++ b/custom/notify-users.nix
@@ -0,0 +1,53 @@
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.notify-users;
7
8 notify-user = userName: with pkgs; stdenv.mkDerivation {
9 name = "notify-${userName}";
10 src = ./notify-user.hs;
11
12 phases = [ "unpackPhase" "buildPhase" "installPhase" ];
13
14 unpackPhase = ''
15 cp $src notify-user.hs
16 '';
17
18 inherit userName;
19 userHome = config.users.users."${userName}".home;
20
21 buildPhase = ''
22 substituteAllInPlace notify-user.hs
23 ${ghcWithPackages (p: with p; [ Glob process libnotify getopt-simple containers ])}/bin/ghc -odir . -hidir . $src -o notify-${userName}
24 '';
25
26 installPhase = ''
27 mkdir -p $out/bin
28
29 install -m 755 -t $out/bin \
30 notify-${userName}
31 '';
32 };
33in {
34 options = {
35 services.notify-users = mkOption {
36 type = with types; listOf str;
37 default = [];
38 description = ''
39 Users to install a notify-user script for
40 '';
41 };
42 };
43
44 config = mkIf (cfg != []) {
45 security.wrappers = listToAttrs (map (user: nameValuePair "notify-${user}" {
46 owner = user;
47 setuid = true;
48 setgid = false;
49 permissions = "u+rx,g+x,o+x";
50 source = "${notify-user user}/bin/notify-${user}";
51 }) cfg);
52 };
53}