git.iko.soy/typeable/nixpkgs
on master help sign in
weechat: add NixOS module
commitb54987715bf9240622a4d135217fe2201d7cd3d0 authorYegor Timoshenko <yegortimoshenko@gmail.com> dateSat 6 Jan 2018, 13:25 (9 years ago) parent7158e74
2 files changed+68
nixos/modules/module-list.nix+1 nixos/modules/services/misc/weechat.nix+67
nixos/modules/module-list.nix+1
@@ -406,6 +406,7 @@
406406 ./services/misc/taskserver
407407 ./services/misc/tzupdate.nix
408408 ./services/misc/uhub.nix
409+ ./services/misc/weechat.nix
409410 ./services/misc/xmr-stak.nix
410411 ./services/misc/zookeeper.nix
411412 ./services/monitoring/apcupsd.nix
nixos/modules/services/misc/weechat.nixnew file+67
@@ -0,0 +1,67 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.weechat;
7+in
8+
9+{
10+ options.services.weechat = {
11+ enable = mkEnableOption "weechat";
12+ init = mkOption {
13+ description = "Weechat commands applied at start, one command per line.";
14+ example = ''
15+ /set relay.network.password correct-horse-battery-staple
16+ /relay add weechat 9001
17+ '';
18+ type = types.str;
19+ default = "";
20+ };
21+ root = mkOption {
22+ description = "Weechat state directory.";
23+ type = types.str;
24+ default = "/var/lib/weechat";
25+ };
26+ };
27+
28+ config = mkIf cfg.enable {
29+ users = {
30+ users.weechat = {
31+ createHome = true;
32+ group = "weechat";
33+ home = cfg.root;
34+ };
35+ };
36+
37+ systemd.services.weechat = {
38+ environment.WEECHAT_HOME = cfg.root;
39+ serviceConfig = {
40+ User = "weechat";
41+ Group = "weechat";
42+ };
43+ script = "exec ${pkgs.screen}/bin/screen -D -m ${pkgs.weechat}/bin/weechat";
44+ wantedBy = [ "multi-user.target" ];
45+ wants = [ "network.target" ];
46+ };
47+
48+ systemd.paths.weechat-fifo = {
49+ pathConfig = {
50+ PathExists = "${cfg.root}/weechat_fifo";
51+ Unit = "weechat-apply-init.service";
52+ };
53+ wantedBy = [ "multi-user.target" ];
54+ };
55+
56+ systemd.services.weechat-apply-init = let
57+ initFile = pkgs.writeText "weechat-init" cfg.init;
58+ in {
59+ script = "sed 's/^/*/' ${initFile} > ${cfg.root}/weechat_fifo";
60+ serviceConfig = {
61+ Type = "oneshot";
62+ User = "weechat";
63+ Group = "weechat";
64+ };
65+ };
66+ };
67+}