-
Notifications
You must be signed in to change notification settings - Fork 15
/
weechat.nix
57 lines (56 loc) · 1.72 KB
/
weechat.nix
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
54
55
56
57
{ pkgs, lib, ... }:
let
pkgs2_src = pkgs.fetchFromGitHub {
owner = "nixos";
repo = "nixpkgs";
rev = "831ef4756e3";
sha256 = "1rbfgfp9y2wqn1k0q00363hrb6dc0jbqm7nmnnmi9az3sw55q0rv";
};
pkgs2 = import pkgs2_src { config = {}; overlays = []; };
weechat = pkgs2.weechat;
slack_plugin_src = pkgs.fetchFromGitHub {
owner = "cleverca22";
repo = "slack-irc-gateway";
rev = "eb4b3ca";
sha256 = "1xvwrd59a0xj0jhk0y61fwvzfzf51s95haqykk14gb3d49w3hx88";
};
wee-slack = import "${slack_plugin_src}/wee-slack.nix";
mkService = name: {
"weechat-${name}" = {
description = "weechat - ${name}";
wantedBy = [ "multi-user.target" ];
path = [ weechat pkgs.tmux ];
preStart = ''
mkdir -pv /var/lib/weechat-${name}/.weechat/python/autoload/
cp -vf ${wee-slack}/wee_slack.py /var/lib/weechat-${name}/.weechat/python/autoload/wee_slack.py
chown -R ${name} /var/lib/weechat-${name}
'';
script = ''
tmux new-session -d -s ${name} weechat
'';
preStop = ''
tmux kill-session -t ${name}
'';
serviceConfig = {
User = name;
KillMode = "process";
Restart = "always";
WorkingDirectory = "/var/lib/weechat-${name}";
RemainAfterExit = "yes";
};
};
};
mkUser = name: {
"${name}" = {
createHome = true;
home = "/var/lib/weechat-${name}";
isNormalUser = true;
};
};
secrets = import ./load-secrets.nix;
configs = secrets.weechats;
in {
systemd.services = lib.foldl' (state: name: state // (mkService name)) {} configs;
users.extraUsers = lib.foldl' (state: name: state // (mkUser name)) {} configs;
environment.systemPackages = [ pkgs.tmux weechat ];
}