summaryrefslogtreecommitdiff
path: root/home.nix
blob: 9bbce4d248d6b7c57210343cef691efb07b7b16d (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
{ config, pkgs, ... }:

{
  programs.home-manager.enable = true;
  programs.neovim.enable = true;

  home.stateVersion = "19.03";

  home.sessionVariables = {
    EDITOR = "nvim";
  };

  systemd.user.startServices = true;

  systemd.user.services = {
    weechat = {
      Unit = {
        Description = "Weechat";
        After = [ "networking.target" ];
      };

      Service = {
        Environment = ["TERM=${pkgs.rxvt_unicode.terminfo}" "TMUX_TMPDIR=/run/user/1000"];
        Type = "oneshot";
        RemainAfterExit = "yes";
        ExecStart = "" + pkgs.writeScript "weechat-start" ''
          #!${pkgs.stdenv.shell}
          ${pkgs.tmux}/bin/tmux -2 new-session -d -s irc "${pkgs.weechat}/bin/weechat"
        '';
        ExecStop = "" + pkgs.writeScript "weechat-stop" ''
          #!${pkgs.stdenv.shell}
          pkill -SIGTERM -xf "${pkgs.weechat}/bin/weechat"
          for i in {1..10}; do
            echo "Waiting for weechat to stop... $i"
            pgrep -xlf "${pkgs.weechat}/bin/weechat" || break
            sleep 1
          done
          tmux kill-session -t irc || true
        '';
      };

      Install = {
        WantedBy = [ "default.target" ];
      };
    };
  };
}