blob: 296195f6a0f3472c143c437b216c67f896db1fb8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.notify-users;
notify-user = userName: with pkgs; stdenv.mkDerivation {
name = "notify-${userName}";
src = ./notify-user.hs;
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
unpackPhase = ''
cp $src notify-user.hs
'';
inherit user;
home = config.users.users."${userName}".home;
buildPhase = ''
substituteAllInPlace notify-user.hs
${haskellPackages.ghcWithPackages (p: with p; [ Glob process libnotify getopt-simple containers ])}/bin/ghc -odir . -hidir . $src -o notify-${userName}
'';
installPhase = ''
mkdir -p $out/bin
install -m 755 -t $out/bin \
notify-${userName}
'';
};
in {
options = {
services.notify-users = mkOption {
type = with types; listOf str;
default = [];
description = ''
Users to install a notify-user script for
'';
};
};
config = mkIf (cfg != []) {
security.wrappers = listToAttrs (map (user: nameValuePair "notify-${user}" {
owner = user;
setuid = true;
setgid = false;
permissions = "u+rx,g+x,o+x";
source = "${notify-user user}/bin/notify-${user}";
}) cfg);
};
}
|