about summary refs log tree commit diff
path: root/modules/nixos/common/xdg.nix
blob: b46c3506b62aa044b719971e0fe58f8978c3d9dd (plain) (blame)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{
  config,
  lib,
  this,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.common.xdg;
in {
  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;
        # https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
        defaultApplications = mkMerge (mapAttrsToList
          (n: v: genAttrs v (_: ["${n}.desktop"]))
          {
            emacsclient = [
              "application/json"
              "application/ld+json"
              "application/vnd.ms-publisher"
              "application/x-c"
              "application/x-desktop"
              "application/x-httpd-php"
              "application/x-sh"
              "application/x-tex"
              "application/xhtml+xml"
              "application/xml"
              "text/css"
              "text/csv"
              "text/javascript"
              "text/markdown"
              "text/plain"
              "text/x-lisp"
            ];
            firefox = [
              "text/html"
              "x-scheme-handler/http"
              "x-scheme-handler/https"
            ];
            mpv = [
              "audio/3gpp"
              "audio/3gpp2"
              "audio/aac"
              "audio/flac"
              "audio/mp3"
              "audio/mpeg"
              "audio/ogg"
              "audio/opus"
              "audio/wav"
              "audio/webm"
              "image/avif"
              "image/bmp"
              "image/gif"
              "image/jpeg"
              "image/jpg"
              "image/png"
              "image/tiff"
              "image/vnd.microsoft.icon"
              "image/webp"
              "video/mkv"
              "video/mp2t"
              "video/mp4"
              "video/mpeg"
              "video/ogg"
              "video/webm"
              "video/x-matroska"
              "video/x-msvideo"
            ];
            "org.pwmt.zathura" = [
              "application/pdf"
              "application/epub+zip"
            ];
          });
      };
    })
  ];
}

Consider giving Nix/NixOS a try! <3