2024-07-21 09:43:30 +00:00
|
|
|
{ config, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.xdg;
|
|
|
|
|
|
|
|
xdgDirsOption = {
|
|
|
|
configDirs = lib.mkOption {
|
|
|
|
type = with lib.types; listOf str;
|
|
|
|
description = ''
|
|
|
|
A list of paths to be appended as part of the `XDG_CONFIG_DIRS`
|
|
|
|
environment to be applied per-wrapper.
|
|
|
|
'';
|
|
|
|
default = [ ];
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
wrapperManagerLib.getXdgConfigDirs (with pkgs; [
|
|
|
|
yt-dlp
|
|
|
|
neofetch
|
|
|
|
])
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDirs = lib.mkOption {
|
|
|
|
type = with lib.types; listOf str;
|
|
|
|
description = ''
|
|
|
|
A list of paths to be appended as part of the `XDG_DATA_DIRS`
|
|
|
|
environment to be applied per-wrapper.
|
|
|
|
'';
|
|
|
|
default = [ ];
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
wrapperManagerLib.getXdgDataDirs (with pkgs; [
|
|
|
|
yt-dlp
|
|
|
|
neofetch
|
|
|
|
])
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.xdg = xdgDirsOption;
|
|
|
|
|
|
|
|
options.wrappers = lib.mkOption {
|
|
|
|
type =
|
|
|
|
let
|
2024-07-31 13:51:40 +00:00
|
|
|
xdgDirsType =
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
{
|
|
|
|
options.xdg = xdgDirsOption;
|
2024-07-21 09:43:30 +00:00
|
|
|
|
2024-07-31 13:51:40 +00:00
|
|
|
config = lib.mkMerge [
|
|
|
|
{
|
|
|
|
# When set this way, we could allow the user to override everything.
|
|
|
|
xdg.configDirs = cfg.configDirs;
|
|
|
|
xdg.dataDirs = cfg.dataDirs;
|
|
|
|
}
|
2024-07-23 13:41:09 +00:00
|
|
|
|
2024-07-31 13:51:40 +00:00
|
|
|
(lib.mkIf (config.xdg.configDirs != [ ]) {
|
2024-08-03 08:45:48 +00:00
|
|
|
env.XDG_CONFIG_DIRS.value = lib.lists.map builtins.toString config.xdg.configDirs;
|
|
|
|
env.XDG_CONFIG_DIRS.action = "prefix";
|
2024-07-31 13:51:40 +00:00
|
|
|
})
|
2024-07-27 12:00:36 +00:00
|
|
|
|
2024-07-31 13:51:40 +00:00
|
|
|
(lib.mkIf (config.xdg.dataDirs != [ ]) {
|
2024-08-03 08:45:48 +00:00
|
|
|
env.XDG_DATA_DIRS.value = lib.lists.map builtins.toString config.xdg.dataDirs;
|
|
|
|
env.XDG_DATA_DIRS.action = "prefix";
|
2024-07-31 13:51:40 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
2024-07-21 09:43:30 +00:00
|
|
|
in
|
2024-07-31 13:51:40 +00:00
|
|
|
with lib.types;
|
|
|
|
attrsOf (submodule xdgDirsType);
|
2024-07-21 09:43:30 +00:00
|
|
|
};
|
|
|
|
}
|