diff --git a/lib/utils.nix b/lib/utils.nix index b65f2c8..edf5a95 100644 --- a/lib/utils.nix +++ b/lib/utils.nix @@ -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; } diff --git a/tests/lib/utils.nix b/tests/lib/utils.nix index 76d7f97..735fc03 100644 --- a/tests/lib/utils.nix +++ b/tests/lib/utils.nix @@ -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" + ]; + }; }