add urxvtd service module

This commit is contained in:
lassulus 2015-04-06 18:03:18 +02:00 committed by tv
parent eb4c0b21e8
commit 5e264d7ec6
1 changed files with 48 additions and 0 deletions

48
modules/urxvtd.nix Normal file
View File

@ -0,0 +1,48 @@
{ config, lib, pkgs, ... }:
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";
};
};
};
config =
let
cfg = config.services.urxvtd;
users = cfg.users;
urxvt = cfg.urxvtPackage;
mkService = user: {
description = "urxvt terminal daemon";
wantedBy = [ "multi-user.target" ];
restartIfChanged = false;
serviceConfig = {
Restart = "always";
User = user;
Environment = "URXVT_PERL_LIB=${urxvt}/lib/urxvt/perl";
ExecStart = "${urxvt}/bin/urxvtd";
};
};
in
mkIf cfg.enable {
environment.systemPackages = [ urxvt ];
systemd.services = listToAttrs (map (u: { name = "${u}-urxvtd"; value = mkService u; }) users);
};
}