mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-18 22:33:00 +00:00
* nixos: remove with lib * nix-darwin: remove with lib * home-manager: remove with lib * modules/accounts: remove with lib * modules/config: remove with lib * modules/i18n: remove with lib * modules/misc: remove with lib * modules: remove with lib * modules/targets: remove with lib * tests/modules/firefox: remove with lib * tests/modules/services: remove with lib
61 lines
1.6 KiB
Nix
61 lines
1.6 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}";
|
|
})
|
|
];
|
|
}
|