summaryrefslogtreecommitdiffstats
path: root/lass/3modules/urxvtd.nix
blob: 1eb463955e5585019116f10618f7ae975e9249a8 (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
53
54
{ config, lib, pkgs, ... }:

let
in

with config.krebs.lib;

{
  options = {
    services.urxvtd = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Enable urxvtd per user";
      };
      users = mkOption {
        type = types.listOf types.string;
        default = [];
        description = "users to run urxvtd for";
      };
      urxvtPackage = mkOption {
        type = types.package;
        default = pkgs.rxvt_unicode;
        description = "urxvt package to use";
      };
    };
  };

  config = 
    let
      cfg = config.services.urxvtd;
      users = cfg.users;
      urxvt = cfg.urxvtPackage;
      mkService = user: {
        description = "urxvt terminal daemon";
        wantedBy = [ "multi-user.target" ];
        restartIfChanged = false;
        path = [ pkgs.xlibs.xrdb ];
        environment = {
          DISPLAY = ":0";
          URXVT_PERL_LIB = "${urxvt}/lib/urxvt/perl";
        };
        serviceConfig = {
          Restart = "always";
          User = user;
          ExecStart = "${urxvt}/bin/urxvtd";
        };
      };
    in
      mkIf cfg.enable {
        environment.systemPackages = [ urxvt ];
        systemd.services = listToAttrs (map (u: { name = "${u}-urxvtd"; value = mkService u; }) users);
      };
}