aboutsummaryrefslogtreecommitdiff
path: root/home-manager/tests/modules/misc/xsession
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2019-10-05 22:42:42 +0000
committerKatharina Fey <kookie@spacekookie.de>2019-10-05 22:44:50 +0000
commit73d865b1dae7585d0eff167271dabe77c9d0b8e6 (patch)
tree337324fab29014f3d60a8bff4979e397fb556d88 /home-manager/tests/modules/misc/xsession
parent670a2de0037acadb83433165344710dd3ac03adf (diff)
parente14d8e29606feddb29d7c27ea62dd514ef80f1e4 (diff)
Replacing nixcfg with libkookierebuild
Generally, nixcfg grew out of a dotfiles repository, that happened to also have some scripts in it. As more and more of the configuration was replaced with nix specifics (home-manager, etc...), so did nixcfg change over time (previously "stuff"). As part of this, kookiepkgs was introduced along-side nixcfg, to make it easier to add custom things to nixpkgs-based systems (NixOS). Additionally, the core system configuration was handled via private infrastructure repositories, each specific to the machine in question. The problem with this approach is a lot of redundancy when building non-userspace (read home-manager) systems and a lot of chaos with having to cherry-pick commits from different branches to work with nixpkgs trees in development. Ultimately, keeping both new package definitions, patches and configuration for the root system and userspace (home-manager) in the same repository is a _much_ better approach to solving these issues. And as such, libkookie was started: the general idea is that it includes all nix expressions that are relevant to _any_ of my computers. Under `roots`, a machine can have it's primary configuration file which is built andcopied into the nix store, so that nixpkgs can always point at the version a generation was built with, not what is on disk). Overlays contains everything that kookiepkgs used to, modules contains both system-level modules (only required on NixOS), as well as anything that is being built with home-manager. Modules are all kept in the same tree, however some require system-level access while others don't. There could be some kind of list to distinguish the two, so that userspace-only systems can still take advantage of libkookie.
Diffstat (limited to 'home-manager/tests/modules/misc/xsession')
-rw-r--r--home-manager/tests/modules/misc/xsession/basic-setxkbmap-expected.service12
-rw-r--r--home-manager/tests/modules/misc/xsession/basic-xprofile-expected.txt16
-rw-r--r--home-manager/tests/modules/misc/xsession/basic-xsession-expected.txt18
-rw-r--r--home-manager/tests/modules/misc/xsession/basic.nix37
-rw-r--r--home-manager/tests/modules/misc/xsession/default.nix4
-rw-r--r--home-manager/tests/modules/misc/xsession/keyboard-without-layout-expected.service12
-rw-r--r--home-manager/tests/modules/misc/xsession/keyboard-without-layout.nix33
7 files changed, 132 insertions, 0 deletions
diff --git a/home-manager/tests/modules/misc/xsession/basic-setxkbmap-expected.service b/home-manager/tests/modules/misc/xsession/basic-setxkbmap-expected.service
new file mode 100644
index 00000000000..39f876dd60e
--- /dev/null
+++ b/home-manager/tests/modules/misc/xsession/basic-setxkbmap-expected.service
@@ -0,0 +1,12 @@
+[Install]
+WantedBy=graphical-session.target
+
+[Service]
+ExecStart=@setxkbmap@/bin/setxkbmap -layout 'us' -variant ''
+RemainAfterExit=true
+Type=oneshot
+
+[Unit]
+After=graphical-session-pre.target
+Description=Set up keyboard in X
+PartOf=graphical-session.target
diff --git a/home-manager/tests/modules/misc/xsession/basic-xprofile-expected.txt b/home-manager/tests/modules/misc/xsession/basic-xprofile-expected.txt
new file mode 100644
index 00000000000..05733a974ff
--- /dev/null
+++ b/home-manager/tests/modules/misc/xsession/basic-xprofile-expected.txt
@@ -0,0 +1,16 @@
+. "/test-home/.nix-profile/etc/profile.d/hm-session-vars.sh"
+
+if [ -e "$HOME/.profile" ]; then
+ . "$HOME/.profile"
+fi
+
+# If there are any running services from a previous session.
+# Need to run this in xprofile because the NixOS xsession
+# script starts up graphical-session.target.
+systemctl --user stop graphical-session.target graphical-session-pre.target
+
+systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS DISPLAY SSH_AUTH_SOCK XAUTHORITY XDG_DATA_DIRS XDG_RUNTIME_DIR XDG_SESSION_ID EXTRA_IMPORTED_VARIABLE
+
+profile extra commands
+
+export HM_XPROFILE_SOURCED=1
diff --git a/home-manager/tests/modules/misc/xsession/basic-xsession-expected.txt b/home-manager/tests/modules/misc/xsession/basic-xsession-expected.txt
new file mode 100644
index 00000000000..c11b7c33048
--- /dev/null
+++ b/home-manager/tests/modules/misc/xsession/basic-xsession-expected.txt
@@ -0,0 +1,18 @@
+if [ -z "$HM_XPROFILE_SOURCED" ]; then
+ . ~/.xprofile
+fi
+unset HM_XPROFILE_SOURCED
+
+systemctl --user start hm-graphical-session.target
+
+init extra commands
+
+window manager command
+
+systemctl --user stop graphical-session.target
+systemctl --user stop graphical-session-pre.target
+
+# Wait until the units actually stop.
+while [ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]; do
+ sleep 0.5
+done
diff --git a/home-manager/tests/modules/misc/xsession/basic.nix b/home-manager/tests/modules/misc/xsession/basic.nix
new file mode 100644
index 00000000000..60623d1bf6b
--- /dev/null
+++ b/home-manager/tests/modules/misc/xsession/basic.nix
@@ -0,0 +1,37 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+ config = {
+ home.homeDirectory = "/test-home";
+
+ xsession = {
+ enable = true;
+ windowManager.command = "window manager command";
+ importedVariables = [ "EXTRA_IMPORTED_VARIABLE" ];
+ initExtra = "init extra commands";
+ profileExtra = "profile extra commands";
+ };
+
+ nmt.script = ''
+ assertFileExists home-files/.xprofile
+ assertFileContent \
+ home-files/.xprofile \
+ ${./basic-xprofile-expected.txt}
+
+ assertFileExists home-files/.xsession
+ assertFileContent \
+ home-files/.xsession \
+ ${./basic-xsession-expected.txt}
+
+ assertFileExists home-files/.config/systemd/user/setxkbmap.service
+ assertFileContent \
+ home-files/.config/systemd/user/setxkbmap.service \
+ ${pkgs.substituteAll {
+ src = ./basic-setxkbmap-expected.service;
+ inherit (pkgs.xorg) setxkbmap;
+ }}
+ '';
+ };
+}
diff --git a/home-manager/tests/modules/misc/xsession/default.nix b/home-manager/tests/modules/misc/xsession/default.nix
new file mode 100644
index 00000000000..2ddbf47efac
--- /dev/null
+++ b/home-manager/tests/modules/misc/xsession/default.nix
@@ -0,0 +1,4 @@
+{
+ xsession-basic = ./basic.nix;
+ xsession-keyboard-without-layout = ./keyboard-without-layout.nix;
+}
diff --git a/home-manager/tests/modules/misc/xsession/keyboard-without-layout-expected.service b/home-manager/tests/modules/misc/xsession/keyboard-without-layout-expected.service
new file mode 100644
index 00000000000..a04af53dad7
--- /dev/null
+++ b/home-manager/tests/modules/misc/xsession/keyboard-without-layout-expected.service
@@ -0,0 +1,12 @@
+[Install]
+WantedBy=graphical-session.target
+
+[Service]
+ExecStart=@setxkbmap@/bin/setxkbmap -option 'ctrl:nocaps' -option 'altwin:no_win'
+RemainAfterExit=true
+Type=oneshot
+
+[Unit]
+After=graphical-session-pre.target
+Description=Set up keyboard in X
+PartOf=graphical-session.target
diff --git a/home-manager/tests/modules/misc/xsession/keyboard-without-layout.nix b/home-manager/tests/modules/misc/xsession/keyboard-without-layout.nix
new file mode 100644
index 00000000000..b7eb3decebb
--- /dev/null
+++ b/home-manager/tests/modules/misc/xsession/keyboard-without-layout.nix
@@ -0,0 +1,33 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+ config = {
+ home.stateVersion = "19.09";
+
+ home.homeDirectory = "/test-home";
+
+ home.keyboard = {
+ options = [ "ctrl:nocaps" "altwin:no_win" ];
+ };
+
+ xsession = {
+ enable = true;
+ windowManager.command = "window manager command";
+ importedVariables = [ "EXTRA_IMPORTED_VARIABLE" ];
+ initExtra = "init extra commands";
+ profileExtra = "profile extra commands";
+ };
+
+ nmt.script = ''
+ assertFileExists home-files/.config/systemd/user/setxkbmap.service
+ assertFileContent \
+ home-files/.config/systemd/user/setxkbmap.service \
+ ${pkgs.substituteAll {
+ src = ./keyboard-without-layout-expected.service;
+ inherit (pkgs.xorg) setxkbmap;
+ }}
+ '';
+ };
+}