summaryrefslogtreecommitdiffstats
path: root/tv/2configs/xserver/default.nix
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2015-10-25 21:27:26 +0100
committerlassulus <lass@aidsballs.de>2015-10-25 21:27:26 +0100
commit43b856994ff2501562081152260d22626cea10f7 (patch)
tree102f201bd27ae705c842b2cc786b20cf8e394903 /tv/2configs/xserver/default.nix
parentcc5220a4477e290f1833e609fed1e0f9f56e4a41 (diff)
parent4b22988392f940c705e7f3fddc39481635777895 (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'tv/2configs/xserver/default.nix')
-rw-r--r--tv/2configs/xserver/default.nix50
1 files changed, 39 insertions, 11 deletions
diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix
index 5d3372609..c5cffbb30 100644
--- a/tv/2configs/xserver/default.nix
+++ b/tv/2configs/xserver/default.nix
@@ -44,11 +44,14 @@ let
systemd.services.display-manager = mkForce {};
services.xserver.enable = true;
+
systemd.services.xmonad = {
wantedBy = [ "multi-user.target" ];
requires = [ "xserver.service" ];
+ environment = xmonad-environment;
serviceConfig = {
- ExecStart = "${xmonad}/bin/xmonad";
+ ExecStart = "${xmonad-start}/bin/xmonad";
+ ExecStop = "${xmonad-stop}/bin/xmonad-stop";
User = user.name;
WorkingDirectory = user.home;
};
@@ -69,15 +72,30 @@ let
};
};
- xmonad = let
- pkg = pkgs.haskellPackages.callPackage src {};
- src = pkgs.runCommand "xmonad-package" {} ''
- ${pkgs.cabal2nix}/bin/cabal2nix ${./xmonad} > $out
- '';
- in pkgs.writeScriptBin "xmonad" ''
- #! /bin/sh
+ xmonad-pkg = pkgs.haskellPackages.callPackage xmonad-src {};
+ xmonad-src = pkgs.writeNixFromCabal "xmonad.nix" ./xmonad;
+
+ xmonad-environment = {
+ DISPLAY = ":${toString config.services.xserver.display}";
+ XMONAD_STATE = "/tmp/xmonad.state";
+
+ # XXX JSON is close enough :)
+ XMONAD_WORKSPACES0_FILE = pkgs.writeText "xmonad.workspaces0" (toJSON [
+ "Dashboard" # we start here
+ "23"
+ "cr"
+ "ff"
+ "hack"
+ "im"
+ "mail"
+ "stockholm"
+ "za" "zj" "zs"
+ ]);
+ };
+
+ xmonad-start = pkgs.writeScriptBin "xmonad" ''
+ #! ${pkgs.bash}/bin/bash
set -efu
- export DISPLAY; DISPLAY=:${toString config.services.xserver.display}
export PATH; PATH=${makeSearchPath "bin" [
pkgs.rxvt_unicode
]}:/var/setuid-wrappers
@@ -93,7 +111,17 @@ let
settle ${pkgs.xorg.xhost}/bin/xhost +LOCAL:
settle ${pkgs.xorg.xrdb}/bin/xrdb -merge ${import ./Xresources.nix args}
settle ${pkgs.xorg.xsetroot}/bin/xsetroot -solid '#1c1c1c'
- exec ${pkg}/bin/xmonad
+ if test -e "$XMONAD_STATE"; then
+ IFS=''$'\n'
+ exec ${xmonad-pkg}/bin/xmonad --resume $(< "$XMONAD_STATE")
+ else
+ exec ${xmonad-pkg}/bin/xmonad
+ fi
+ '';
+
+ xmonad-stop = pkgs.writeScriptBin "xmonad-stop" ''
+ #! /bin/sh
+ exec ${xmonad-pkg}/bin/xmonad --shutdown
'';
xserver-environment = {
@@ -103,7 +131,7 @@ let
[ "${pkgs.xorg.libX11}/lib" "${pkgs.xorg.libXext}/lib" ]
++ concatLists (catAttrs "libPath" config.services.xserver.drivers));
};
-
+
xserver = pkgs.writeScriptBin "xserver" ''
#! /bin/sh
set -efu