summaryrefslogtreecommitdiff
path: root/modules/nixos/common/xdg.nix
blob: 668996feb45dcdb10c15e5dd05dcad3bd01d14d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{
  config,
  lib,
  this,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.common.xdg;
in {
  options.nixfiles.modules.common.xdg.defaultApplications = mkOption {
    description = "Default applications.";
    type = with types; attrsOf (listOf str);
    default = {};
  };

  config = {
    xdg.portal = mkIf this.isHeadful {
      enable = true;
    };

    hm.xdg = mkMerge [
      (with cfg; {
        enable = true;

        inherit cacheHome;
        inherit configHome;
        inherit dataHome;
        inherit stateHome;
        inherit userDirs;
      })
      (mkIf this.isHeadful {
        mimeApps = {
          enable = true;
          defaultApplications =
            mkMerge
            (mapAttrsToList
              (n: v: genAttrs v (_: ["${n}.desktop"]))
              cfg.defaultApplications);
        };
      })
    ];
  };
}