blob: 42c45403133b1cb155b66c7cd7103adc71fa8ac3 (
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
|
{ 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" ];
user = userName;
home = config.users.users."${userName}".home;
unpackPhase = ''
substituteAll $src notify-${userName}.hs
'';
buildPhase = ''
${haskellPackages.ghcWithPackages (p: with p; [ Glob process libnotify getopt-simple containers ])}/bin/ghc -odir . -hidir . notify-${userName}.hs -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);
};
}
|