diff options
author | Robert Helgesson <robert@rycee.net> | 2017-01-07 19:16:26 +0100 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2017-01-14 13:15:24 +0100 |
commit | d7d02c3ce8f723b3cff03ea7502011883eef8fde (patch) | |
tree | f48d291967d59a91dd6590941745fb876c3a29bf /modules/xsession.nix | |
parent | e4c63eb66aaa10e447f010b3d0f28e3a278ad30d (diff) |
Initial import
Diffstat (limited to 'modules/xsession.nix')
-rw-r--r-- | modules/xsession.nix | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/modules/xsession.nix b/modules/xsession.nix new file mode 100644 index 00000000000..ab6629743d8 --- /dev/null +++ b/modules/xsession.nix @@ -0,0 +1,77 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xsession; + +in + +{ + options = { + xsession = { + enable = mkEnableOption "X Session"; + + windowManager = mkOption { + default = {}; + type = types.str; + description = "Path to window manager to exec."; + }; + + initExtra = mkOption { + type = types.lines; + default = ""; + description = "Extra shell commands to run during initialization."; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.setxkbmap = { + Unit = { + Description = "Set up keyboard in X"; + }; + + Install = { + WantedBy = [ "xorg.target" ]; + }; + + Service = { + Type = "oneshot"; + ExecStart = + let + args = concatStringsSep " " ( + [ + "-layout '${config.home.keyboard.layout}'" + "-variant '${config.home.keyboard.variant}'" + ] ++ + (map (v: "-option '${v}'") config.home.keyboard.options) + ); + in + "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}"; + }; + }; + + home.file.".xsession" = { + mode = "555"; + text = '' + # Rely on Bash to set session variables. + . "$HOME/.profile" + + systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS + systemctl --user import-environment DISPLAY + systemctl --user import-environment SSH_AUTH_SOCK + systemctl --user import-environment XDG_DATA_DIRS + systemctl --user import-environment XDG_RUNTIME_DIR + systemctl --user start xorg.target + + ${cfg.initExtra} + + ${cfg.windowManager} + + systemctl --user stop xorg.target + ''; + }; + }; +} |