mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
`literalExpression` is intended just to signify code that needs to stay a string that gets represented exactly as-is for docs. It has been misused heavily and people get confused repeatedly on when or not to use it because of the rampant misuse.
66 lines
1.5 KiB
Nix
66 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 = [ "/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 = [
|
|
"/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}";
|
|
})
|
|
];
|
|
}
|