tests/configs: add test for setting XDG base directories

This commit is contained in:
Gabriel Arazas 2024-11-07 17:46:42 +08:00
parent 96ba0a0702
commit 9c4ea57cc7
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
2 changed files with 54 additions and 0 deletions

View File

@ -16,6 +16,7 @@ in
specialArgs.yourMomName = "Yor mom";
};
xdg-desktop-entry = build { modules = [ ./xdg-desktop-entry.nix ]; };
xdg-basedirs = build { modules = [ ./xdg-basedirs.nix ]; };
single-basepackage = build { modules = [ ./single-basepackage.nix ]; };
neofetch-with-additional-files = build { modules = [ ./neofetch-with-additional-files.nix ]; };
lib-modules-make-wraparound = build { modules = [ ./lib-modules-subset/make-wraparound.nix ]; };

View File

@ -0,0 +1,53 @@
{
config,
lib,
pkgs,
wrapperManagerLib,
...
}:
{
xdg.configDirs = wrapperManagerLib.getXdgConfigDirs (
with pkgs;
[
yt-dlp
]
);
xdg.dataDirs = wrapperManagerLib.getXdgDataDirs (
with pkgs;
[
yt-dlp
]
);
wrappers.xdg-config-dirs-script = {
arg0 = let
app = pkgs.writeShellScript "xdg-dirs-script" ''
echo "$XDG_CONFIG_DIRS" | tr ':' '\n'
'';
in builtins.toString app;
};
wrappers.xdg-data-dirs-script = {
arg0 = let
app = pkgs.writeShellScript "xdg-dirs-script" ''
echo "$XDG_DATA_DIRS" | tr ':' '\n'
'';
in builtins.toString app;
};
build.extraPassthru.wrapperManagerTests = {
actuallyBuilt =
let
wrapper = config.build.toplevel;
in
pkgs.runCommand "wrapper-manager-xdg-desktop-entry-actually-built" { } ''
[ -x "${wrapper}/bin/xdg-data-dirs-script" ] && {
${lib.getExe' wrapper "xdg-data-dirs-script"} | grep "${pkgs.yt-dlp}/share" > /dev/null
} && [ -x "${wrapper}/bin/xdg-config-dirs-script" ] && {
${lib.getExe' wrapper "xdg-config-dirs-script"} | grep "${pkgs.yt-dlp}/etc/xdg" > /dev/null
} && touch $out
'';
};
}