2019-12-29 17:41:44 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
var base_nix = []byte(`
|
2018-07-12 19:29:35 +00:00
|
|
|
{pkgs, ...}:
|
2018-06-30 08:39:47 +00:00
|
|
|
{
|
2018-06-30 21:56:43 +00:00
|
|
|
imports = [
|
2018-07-01 06:56:16 +00:00
|
|
|
<nix/local.nix>
|
2018-06-30 21:56:43 +00:00
|
|
|
];
|
|
|
|
|
2018-06-30 08:39:47 +00:00
|
|
|
services.xserver = {
|
|
|
|
enable = true;
|
|
|
|
desktopManager.xterm.enable = false;
|
|
|
|
displayManager.slim = {
|
|
|
|
enable = true;
|
|
|
|
defaultUser = "user";
|
|
|
|
autoLogin = true;
|
|
|
|
};
|
|
|
|
windowManager.xmonad.enable = true;
|
|
|
|
windowManager.default = "xmonad";
|
|
|
|
};
|
|
|
|
|
2018-07-12 17:43:42 +00:00
|
|
|
services.spice-vdagentd.enable = true;
|
|
|
|
|
2018-06-30 08:39:47 +00:00
|
|
|
users.extraUsers.user = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "audio" ];
|
|
|
|
createHome = true;
|
|
|
|
};
|
2018-07-06 15:06:00 +00:00
|
|
|
|
|
|
|
environment.etc."xmonad.hs".text = ''
|
|
|
|
import XMonad
|
|
|
|
main = xmonad defaultConfig
|
|
|
|
{ workspaces = [ "" ]
|
|
|
|
, borderWidth = 0
|
2018-07-12 17:43:42 +00:00
|
|
|
, startupHook = startup
|
2018-07-06 15:06:00 +00:00
|
|
|
}
|
2018-07-12 17:43:42 +00:00
|
|
|
|
|
|
|
startup :: X ()
|
|
|
|
startup = do
|
2019-12-29 13:15:24 +00:00
|
|
|
spawn "${pkgs.spice-vdagent}/bin/spice-vdagent"
|
2018-07-06 15:06:00 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
systemd.services.home-user-build-xmonad = {
|
2019-12-29 13:27:10 +00:00
|
|
|
description = "Link xmonad configuration";
|
2018-07-06 15:06:00 +00:00
|
|
|
serviceConfig = {
|
|
|
|
ConditionFileNotEmpty = "!/home/user/.xmonad/xmonad.hs";
|
2018-07-12 17:43:20 +00:00
|
|
|
ExecStart = "/bin/sh -c 'mkdir -p /home/user/.xmonad && ln -s /etc/xmonad.hs /home/user/.xmonad/xmonad.hs'";
|
2018-07-06 15:06:00 +00:00
|
|
|
RemainAfterExit = "yes";
|
|
|
|
User = "user";
|
2019-12-29 13:52:24 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
TimeoutSec = 10;
|
2018-07-06 15:06:00 +00:00
|
|
|
};
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
};
|
2018-07-11 23:34:36 +00:00
|
|
|
|
|
|
|
systemd.services.mount-home-user = {
|
|
|
|
description = "Mount /home/user (crutch)";
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "/bin/sh -c '/run/current-system/sw/bin/mount -t 9p -o trans=virtio,version=9p2000.L,uid=1000 home /home/user'";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
Type = "oneshot";
|
|
|
|
User = "root";
|
|
|
|
};
|
|
|
|
wantedBy = [ "sysinit.target" ];
|
|
|
|
};
|
2019-12-29 14:32:28 +00:00
|
|
|
|
|
|
|
systemd.user.services."xrandr" = {
|
2019-12-29 17:24:14 +00:00
|
|
|
serviceConfig = {
|
|
|
|
StartLimitBurst = 100;
|
|
|
|
};
|
2019-12-29 14:32:28 +00:00
|
|
|
script = "${pkgs.xorg.xrandr}/bin/xrandr --output Virtual-1 --mode $(${pkgs.xorg.xrandr}/bin/xrandr | grep ' ' | head -n 2 | tail -n 1 | ${pkgs.gawk}/bin/awk '{ print $1 }')";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.user.timers."xrandr" = {
|
|
|
|
description = "Auto update resolution crutch";
|
|
|
|
timerConfig = {
|
|
|
|
OnBootSec = "1s";
|
|
|
|
OnUnitInactiveSec = "1s";
|
|
|
|
Unit = "xrandr.service";
|
|
|
|
AccuracySec = "1us";
|
|
|
|
};
|
|
|
|
wantedBy = ["timers.target"];
|
|
|
|
};
|
2019-12-29 18:57:36 +00:00
|
|
|
|
|
|
|
systemd.services."autoballoon" = {
|
|
|
|
serviceConfig = {
|
|
|
|
StartLimitBurst = 100;
|
|
|
|
};
|
|
|
|
script = ''
|
|
|
|
${pkgs.procps}/bin/free -m | grep Mem | \
|
|
|
|
${pkgs.gawk}/bin/awk '{print $2 "-" $4}' | \
|
|
|
|
${pkgs.bc}/bin/bc > /home/user/.memory_used
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.timers."autoballoon" = {
|
|
|
|
description = "Auto update resolution crutch";
|
|
|
|
timerConfig = {
|
|
|
|
OnBootSec = "1s";
|
|
|
|
OnUnitInactiveSec = "1s";
|
|
|
|
Unit = "autoballoon.service";
|
|
|
|
AccuracySec = "1us";
|
|
|
|
};
|
|
|
|
wantedBy = ["timers.target"];
|
|
|
|
};
|
2018-06-30 08:39:47 +00:00
|
|
|
}
|
2019-12-29 17:41:44 +00:00
|
|
|
`)
|