mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
xsession: add option importedVariables
This option lists the environment variables to be imported into the systemd user session. Also add a basic test of the xsession module.
This commit is contained in:
parent
f83c49baa3
commit
95d55b8da1
8 changed files with 96 additions and 9 deletions
16
tests/modules/misc/xsession/basic-xprofile-expected.txt
Normal file
16
tests/modules/misc/xsession/basic-xprofile-expected.txt
Normal file
|
|
@ -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
|
||||
18
tests/modules/misc/xsession/basic-xsession-expected.txt
Normal file
18
tests/modules/misc/xsession/basic-xsession-expected.txt
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
if [[ ! -v 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
|
||||
30
tests/modules/misc/xsession/basic.nix
Normal file
30
tests/modules/misc/xsession/basic.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
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}
|
||||
|
||||
'';
|
||||
};
|
||||
}
|
||||
3
tests/modules/misc/xsession/default.nix
Normal file
3
tests/modules/misc/xsession/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
xsession-basic = ./basic.nix;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue