summaryrefslogtreecommitdiff
path: root/config/weechat.nix
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2017-05-14 22:44:21 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2017-05-14 22:44:21 -0400
commit74c9f6d8f833f03ad81bd284a99ce6e0cdacec6d (patch)
treeb869569abf524132c549b58500ce87dde805ebf3 /config/weechat.nix
parent75b7a3c6963b160416918e3b1e8659ecf7560c38 (diff)
Add weechat service
Diffstat (limited to 'config/weechat.nix')
-rw-r--r--config/weechat.nix30
1 files changed, 30 insertions, 0 deletions
diff --git a/config/weechat.nix b/config/weechat.nix
new file mode 100644
index 0000000..e15cd33
--- /dev/null
+++ b/config/weechat.nix
@@ -0,0 +1,30 @@
+{ config, pkgs, ... }:
+{
+ systemd.services = {
+ weechat = {
+ description = "weechat session";
+ path = [ pkgs.weechat pkgs.tmux pkgs.coreutils ];
+ after = [ "networking.target" ];
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ Type = "oneshot";
+ User = "orbekk";
+ RemainAfterExit = true;
+ };
+ script = ''
+ tmux -2 new-session -d -s irc "${pkgs.weechat}/bin/weechat"
+ '';
+ preStop = ''
+ # Gently shut down weechat.
+ # -xf is needed to kill precisely weechat (and not this script).
+ pkill -SIGTERM -xf "${pkgs.weechat}/bin/weechat"
+ for i in {1..10}; do
+ echo "Waiting for weechat to stop"
+ pgrep -xlf "${pkgs.weechat}/bin/weechat" || break
+ sleep 1
+ done
+ tmux kill-session -t irc || true
+ '';
+ };
+ };
+}