wrapper-manager-fds/modules: add configuring XDG-related directories per-wrapper

This commit is contained in:
Gabriel Arazas 2024-07-21 17:43:30 +08:00
parent 6a590fb47d
commit cbabbcf71b
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
2 changed files with 60 additions and 0 deletions

View File

@ -2,6 +2,7 @@
imports = [
./base.nix
./xdg-desktop-entries.nix
./xdg-dirs.nix
./build.nix
./extra-args.nix
];

View File

@ -0,0 +1,59 @@
{ 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
xdgDirsType = { name, lib, config, ... }: {
options.xdg = xdgDirsOption;
config.makeWrapperArgs =
let
# Just take note wrapper-specific values should be the one taking over.
configDirs = cfg.configDirs ++ config.xdg.configDirs;
dataDirs = cfg.dataDirs ++ config.xdg.dataDirs;
in
builtins.map (v: "--prefix 'XDG_CONFIG_DIRS' ':' ${v}") configDirs
++ (builtins.map (v: "--prefix 'XDG_DATA_DIRS' ':' ${v}") dataDirs);
};
in
with lib.types; attrsOf (submodule xdgDirsType);
};
}