blob: a62e64a986cc942bd1cb8d36d4f880d779e2d982 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
{ config, lib, pkgs, ... }:
let
inherit (import ../../lib { inherit pkgs; }) shell-escape;
inherit (pkgs) writeScript;
in
with builtins;
with 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";
};
xresources = mkOption {
type = types.string;
default = "";
description = ''
X server resources for urxvt.
'';
};
};
};
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;
ExecStartPre = writeScript "urxvtd-prestart" ''
#!/bin/sh
echo ${shell-escape cfg.xresources} | xrdb -merge
'';
ExecStart = "${urxvt}/bin/urxvtd";
};
};
in
mkIf cfg.enable {
environment.systemPackages = [ urxvt ];
systemd.services = listToAttrs (map (u: { name = "${u}-urxvtd"; value = mkService u; }) users);
};
}
|