stockholm/modules/lass/urxvtd.nix

69 lines
1.7 KiB
Nix
Raw Normal View History

2015-04-06 16:03:18 +00:00
{ config, lib, pkgs, ... }:
2015-04-07 18:47:56 +00:00
let
2015-04-07 23:07:01 +00:00
inherit (import ../../lib { inherit pkgs; }) shell-escape;
2015-04-07 18:47:56 +00:00
inherit (pkgs) writeScript;
in
2015-04-06 16:03:18 +00:00
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";
};
2015-04-07 18:47:56 +00:00
xresources = mkOption {
type = types.string;
default = "";
description = ''
X server resources for urxvt.
'';
};
2015-04-06 16:03:18 +00:00
};
};
config =
let
cfg = config.services.urxvtd;
users = cfg.users;
urxvt = cfg.urxvtPackage;
mkService = user: {
description = "urxvt terminal daemon";
wantedBy = [ "multi-user.target" ];
restartIfChanged = false;
2015-04-07 18:47:56 +00:00
path = [ pkgs.xlibs.xrdb ];
2015-04-07 18:47:09 +00:00
environment = {
2015-04-07 18:47:56 +00:00
DISPLAY = ":0";
2015-04-07 18:47:09 +00:00
URXVT_PERL_LIB = "${urxvt}/lib/urxvt/perl";
};
2015-04-06 16:03:18 +00:00
serviceConfig = {
Restart = "always";
User = user;
2015-04-07 18:47:56 +00:00
ExecStartPre = writeScript "urxvtd-prestart" ''
#!/bin/sh
echo ${shell-escape cfg.xresources} | xrdb -merge
'';
2015-04-06 16:03:18 +00:00
ExecStart = "${urxvt}/bin/urxvtd";
};
};
in
mkIf cfg.enable {
environment.systemPackages = [ urxvt ];
systemd.services = listToAttrs (map (u: { name = "${u}-urxvtd"; value = mkService u; }) users);
};
}