tv xserver: refactor

This commit is contained in:
tv 2016-05-25 11:06:22 +02:00
parent 36c5834c28
commit b4ca66d23a
2 changed files with 107 additions and 117 deletions

View File

@ -1,37 +1,9 @@
{ config, lib, pkgs, ... }@args:
{ config, pkgs, ... }@args:
with config.krebs.lib;
let
# TODO krebs.build.user
user = config.users.users.tv;
out = {
services.xserver.display = 11;
services.xserver.tty = 11;
services.xserver.synaptics = {
enable = true;
twoFingerScroll = true;
accelFactor = "0.035";
};
fonts.fonts = [
pkgs.xlibs.fontschumachermisc
];
systemd.services.urxvtd = {
wantedBy = [ "multi-user.target" ];
reloadIfChanged = true;
serviceConfig = {
ExecReload = need-reload "urxvtd.service";
ExecStart = "${pkgs.rxvt_unicode}/bin/urxvtd";
Restart = "always";
RestartSec = "2s";
StartLimitBurst = 0;
User = user.name;
};
};
in {
environment.systemPackages = [
pkgs.ff
@ -42,6 +14,10 @@ let
pkgs.zathura
];
fonts.fonts = [
pkgs.xlibs.fontschumachermisc
];
# TODO dedicated group, i.e. with a single user
# TODO krebs.setuid.slock.path vs /var/setuid-wrappers
krebs.setuid.slock = {
@ -53,46 +29,24 @@ let
};
};
systemd.services.display-manager.enable = false;
services.xserver = {
enable = true;
display = 11;
tty = 11;
services.xserver.enable = true;
synaptics = {
enable = true;
twoFingerScroll = true;
accelFactor = "0.035";
};
};
systemd.services.display-manager.enable = false;
systemd.services.xmonad = {
wantedBy = [ "multi-user.target" ];
requires = [ "xserver.service" ];
environment = xmonad-environment;
serviceConfig = {
ExecStart = "${pkgs.xmonad-tv}/bin/xmonad-tv";
ExecStop = "${pkgs.xmonad-tv}/bin/xmonad-tv --shutdown";
User = user.name;
WorkingDirectory = user.home;
};
};
systemd.services.xserver = {
after = [
"systemd-udev-settle.service"
"local-fs.target"
"acpid.service"
];
reloadIfChanged = true;
environment = xserver-environment;
serviceConfig = {
ExecReload = need-reload "xserver.service";
ExecStart = toString [
"${pkgs.xorg.xorgserver}/bin/X"
":${toString config.services.xserver.display}"
"vt${toString config.services.xserver.tty}"
"-config ${import ./xserver.conf.nix args}"
"-logfile /var/log/X.${toString config.services.xserver.display}.log"
"-nolisten tcp"
"-xkbdir ${pkgs.xkeyboard_config}/etc/X11/xkb"
];
};
};
};
xmonad-environment = {
environment = {
DISPLAY = ":${toString config.services.xserver.display}";
XMONAD_STARTUP_HOOK = pkgs.writeDash "xmonad-startup-hook" ''
@ -118,18 +72,53 @@ let
"za" "zh" "zj" "zs"
]);
};
serviceConfig = {
ExecStart = "${pkgs.xmonad-tv}/bin/xmonad-tv";
ExecStop = "${pkgs.xmonad-tv}/bin/xmonad-tv --shutdown";
User = user.name;
WorkingDirectory = user.home;
};
};
xserver-environment = {
systemd.services.xserver = {
after = [
"systemd-udev-settle.service"
"local-fs.target"
"acpid.service"
];
reloadIfChanged = true;
environment = {
XKB_BINDIR = "${pkgs.xorg.xkbcomp}/bin"; # Needed for the Xkb extension.
XORG_DRI_DRIVER_PATH = "/run/opengl-driver/lib/dri"; # !!! Depends on the driver selected at runtime.
LD_LIBRARY_PATH = concatStringsSep ":" (
[ "${pkgs.xorg.libX11}/lib" "${pkgs.xorg.libXext}/lib" ]
++ concatLists (catAttrs "libPath" config.services.xserver.drivers));
};
need-reload = s: toString [
"${pkgs.writeDashBin "need-reload" ''echo "$*"''}/bin/need-reload"
(shell.escape s)
serviceConfig = {
SyslogIdentifier = "xserver";
ExecReload = "${pkgs.need-reload}/bin/need-reload xserver.service";
ExecStart = toString [
"${pkgs.xorg.xorgserver}/bin/X"
":${toString config.services.xserver.display}"
"vt${toString config.services.xserver.tty}"
"-config ${import ./xserver.conf.nix args}"
"-logfile /var/log/X.${toString config.services.xserver.display}.log"
"-nolisten tcp"
"-xkbdir ${pkgs.xkeyboard_config}/etc/X11/xkb"
];
};
};
in out
systemd.services.urxvtd = {
wantedBy = [ "multi-user.target" ];
reloadIfChanged = true;
serviceConfig = {
ExecReload = "${pkgs.need-reload}/bin/need-reload urxvtd.service";
ExecStart = "${pkgs.rxvt_unicode}/bin/urxvtd";
Restart = "always";
RestartSec = "2s";
StartLimitBurst = 0;
User = user.name;
};
};
}

View File

@ -17,6 +17,7 @@
erlang = pkgs.erlangR16;
};
ff = pkgs.callPackage ./ff {};
need-reload = pkgs.writeDashBin "need-reload" ''echo "$*"'';
viljetic-pages = pkgs.callPackage ./viljetic-pages {};
xmonad-tv = import ./xmonad-tv.nix { inherit pkgs; };
};