1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00
home-manager/modules/misc/xdg-system-dirs.nix
Austin Horstman cba2f9ce95 treewide: reformat nixfmt-rfc-style
Reformat repository using new nixfmt-rfc-style.
2025-04-08 08:50:05 -07:00

62 lines
1.5 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib) types;
cfg = config.xdg.systemDirs;
configDirs = lib.concatStringsSep ":" cfg.config;
dataDirs = lib.concatStringsSep ":" cfg.data;
in
{
meta.maintainers = with lib.maintainers; [ tadfisher ];
options.xdg.systemDirs = {
config = lib.mkOption {
type = types.listOf types.str;
default = [ ];
example = lib.literalExpression ''[ "/etc/xdg" ]'';
description = ''
Directory names to add to {env}`XDG_CONFIG_DIRS`
in the user session.
'';
};
data = lib.mkOption {
type = types.listOf types.str;
default = [ ];
example = lib.literalExpression ''[ "/usr/share" "/usr/local/share" ]'';
description = ''
Directory names to add to {env}`XDG_DATA_DIRS`
in the user session.
'';
};
};
config = lib.mkMerge [
(lib.mkIf (cfg.config != [ ] || cfg.data != [ ]) {
assertions = [
(lib.hm.assertions.assertPlatform "xdg.systemDirs" pkgs lib.platforms.linux)
];
})
(lib.mkIf (cfg.config != [ ]) {
home.sessionVariables.XDG_CONFIG_DIRS = "${configDirs}\${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}";
systemd.user.sessionVariables.XDG_CONFIG_DIRS = "${configDirs}\${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}";
})
(lib.mkIf (cfg.data != [ ]) {
home.sessionVariables.XDG_DATA_DIRS = "${dataDirs}\${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}";
systemd.user.sessionVariables.XDG_DATA_DIRS = "${dataDirs}\${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}";
})
];
}