fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.5 KiB61 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.xdg.systemDirs;
8
9  configDirs = concatStringsSep ":" cfg.config;
10
11  dataDirs = concatStringsSep ":" cfg.data;
12
13in {
14  meta.maintainers = with maintainers; [ tadfisher ];
15
16  options.xdg.systemDirs = {
17    config = mkOption {
18      type = types.listOf types.str;
19      default = [ ];
20      example = literalExpression ''[ "/etc/xdg" ]'';
21      description = ''
22        Directory names to add to {env}`XDG_CONFIG_DIRS`
23        in the user session.
24      '';
25    };
26
27    data = mkOption {
28      type = types.listOf types.str;
29      default = [ ];
30      example = literalExpression ''[ "/usr/share" "/usr/local/share" ]'';
31      description = ''
32        Directory names to add to {env}`XDG_DATA_DIRS`
33        in the user session.
34      '';
35    };
36  };
37
38  config = mkMerge [
39    (mkIf (cfg.config != [ ] || cfg.data != [ ]) {
40      assertions = [
41        (hm.assertions.assertPlatform "xdg.systemDirs" pkgs platforms.linux)
42      ];
43    })
44
45    (mkIf (cfg.config != [ ]) {
46      home.sessionVariables.XDG_CONFIG_DIRS =
47        "${configDirs}\${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}";
48
49      systemd.user.sessionVariables.XDG_CONFIG_DIRS =
50        "${configDirs}\${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}";
51    })
52
53    (mkIf (cfg.data != [ ]) {
54      home.sessionVariables.XDG_DATA_DIRS =
55        "${dataDirs}\${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}";
56
57      systemd.user.sessionVariables.XDG_DATA_DIRS =
58        "${dataDirs}\${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}";
59    })
60  ];
61}