wrapper-manager-fds/lib: add function for getting XDG-related directories

This commit is contained in:
Gabriel Arazas 2024-07-21 17:41:05 +08:00
parent 62cc18faf5
commit 724ac43d83
2 changed files with 38 additions and 0 deletions

View File

@ -9,7 +9,23 @@ rec {
builtins.map (v: lib.getBin v) drvs;
/*
Given a list of derivations, return a list of the store paths with the
`libexec` appended.
*/
getLibexec = drvs:
builtins.map (v: "${v}/libexec") drvs;
/*
Given a list of derivations, return a list of the store paths appended with
`/etc/xdg` suitable as part of the XDG_CONFIG_DIRS environment variable.
*/
getXdgConfigDirs = drvs:
builtins.map (v: "${v}/etc/xdg") drvs;
/*
Given a list of derivations, return a list of store paths appended with
`/share` suitable as part of the XDG_DATA_DIRS environment variable.
*/
getXdgDataDirs = drvs:
builtins.map (v: "${v}/share") drvs;
}

View File

@ -22,4 +22,26 @@ lib.runTests {
"${../../modules}/libexec"
];
};
testsUtilsGetXdgConfigDirs = {
expr = self.utils.getXdgConfigDirs [
../../lib
../../modules
];
expected = [
"${../../lib}/etc/xdg"
"${../../modules}/etc/xdg"
];
};
testsUtilsGetXdgDataDirs = {
expr = self.utils.getXdgDataDirs [
../../lib
../../modules
];
expected = [
"${../../lib}/share"
"${../../modules}/share"
];
};
}