Skip to content

Commit 0342467

Browse files
committed
xdg.userDirs: add test cases
Make the existing test case non-Linux-specific, and add a couple of others for the new functionality.
1 parent 7facb3f commit 0342467

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed

tests/modules/misc/xdg/default.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
xdg-mime-disabled = ./mime-disabled.nix;
55
xdg-autostart = ./autostart.nix;
66
xdg-autostart-readonly = ./autostart-readonly.nix;
7+
xdg-user-dirs-mixed = ./user-dirs-mixed.nix;
8+
xdg-user-dirs-null = ./user-dirs-null.nix;
9+
xdg-user-dirs-short = ./user-dirs-short.nix;
710
}

tests/modules/misc/xdg/linux.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
xdg-mime-apps-basics = ./mime-apps-basics.nix;
33
xdg-system-dirs = ./system-dirs.nix;
44
xdg-desktop-entries = ./desktop-entries.nix;
5-
xdg-user-dirs-null = ./user-dirs-null.nix;
65
xdg-portal = ./portal.nix;
76
xdg-mime = ./mime.nix;
87
xdg-mime-package = ./mime-packages.nix;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
config,
3+
pkgs,
4+
...
5+
}:
6+
7+
{
8+
config = {
9+
home.stateVersion = "25.05";
10+
11+
xdg.userDirs = {
12+
enable = true;
13+
extraConfig.PROJECTS = "${config.home.homeDirectory}/Projects";
14+
## This will stop working with stateVersion 25.11.
15+
extraConfig.XDG_MISC_DIR = "${config.home.homeDirectory}/Misc";
16+
};
17+
18+
nmt.script = ''
19+
configFile=home-files/.config/user-dirs.dirs
20+
assertFileExists $configFile
21+
assertFileContent $configFile ${pkgs.writeText "expected" ''
22+
XDG_DESKTOP_DIR="/home/hm-user/Desktop"
23+
XDG_DOCUMENTS_DIR="/home/hm-user/Documents"
24+
XDG_DOWNLOAD_DIR="/home/hm-user/Downloads"
25+
XDG_MISC_DIR="/home/hm-user/Misc"
26+
XDG_MUSIC_DIR="/home/hm-user/Music"
27+
XDG_PICTURES_DIR="/home/hm-user/Pictures"
28+
XDG_PROJECTS_DIR="/home/hm-user/Projects"
29+
XDG_PUBLICSHARE_DIR="/home/hm-user/Public"
30+
XDG_TEMPLATES_DIR="/home/hm-user/Templates"
31+
XDG_VIDEOS_DIR="/home/hm-user/Videos"
32+
''}
33+
'';
34+
};
35+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
config,
3+
pkgs,
4+
...
5+
}:
6+
7+
{
8+
config = {
9+
xdg.userDirs = {
10+
enable = true;
11+
extraConfig.PROJECTS = "${config.home.homeDirectory}/Projects";
12+
};
13+
14+
nmt.script = ''
15+
configFile=home-files/.config/user-dirs.dirs
16+
assertFileExists $configFile
17+
assertFileContent $configFile ${pkgs.writeText "expected" ''
18+
XDG_DESKTOP_DIR="/home/hm-user/Desktop"
19+
XDG_DOCUMENTS_DIR="/home/hm-user/Documents"
20+
XDG_DOWNLOAD_DIR="/home/hm-user/Downloads"
21+
XDG_MUSIC_DIR="/home/hm-user/Music"
22+
XDG_PICTURES_DIR="/home/hm-user/Pictures"
23+
XDG_PROJECTS_DIR="/home/hm-user/Projects"
24+
XDG_PUBLICSHARE_DIR="/home/hm-user/Public"
25+
XDG_TEMPLATES_DIR="/home/hm-user/Templates"
26+
XDG_VIDEOS_DIR="/home/hm-user/Videos"
27+
''}
28+
'';
29+
};
30+
}

0 commit comments

Comments
 (0)