summaryrefslogtreecommitdiff
path: root/modules/nixos/common/xdg.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2022-12-17 16:39:09 +0300
committerAzat Bahawi <azat@bahawi.net>2022-12-17 16:39:09 +0300
commit8f137c28230623259a964484adcf31fe00756594 (patch)
tree82bce6a13fda125087cf6d9dc80aa91d9230d6c4 /modules/nixos/common/xdg.nix
parent3229e56e0d3620ddc735edcfbbefb167efa3b23f (diff)
2022-12-17
Diffstat (limited to 'modules/nixos/common/xdg.nix')
-rw-r--r--modules/nixos/common/xdg.nix87
1 files changed, 87 insertions, 0 deletions
diff --git a/modules/nixos/common/xdg.nix b/modules/nixos/common/xdg.nix
new file mode 100644
index 0000000..8ddf1ac
--- /dev/null
+++ b/modules/nixos/common/xdg.nix
@@ -0,0 +1,87 @@
+{
+ config,
+ lib,
+ this,
+ ...
+}:
+with lib; {
+ imports = let
+ withBase = s: ["home-manager" "users" my.username "xdg" s];
+ in [
+ (mkAliasOptionModule ["dirs" "cache"] (withBase "cacheHome"))
+ (mkAliasOptionModule ["dirs" "config"] (withBase "configHome"))
+ (mkAliasOptionModule ["dirs" "data"] (withBase "dataHome"))
+ (mkAliasOptionModule ["dirs" "state"] (withBase "stateHome"))
+ (mkAliasOptionModule ["userDirs"] (withBase "userDirs"))
+ ];
+
+ hm.xdg = mkMerge [
+ {
+ enable = true;
+
+ userDirs = let
+ inherit (config.my) home;
+ tmp = home + "/tmp";
+ in {
+ enable = true;
+
+ desktop = tmp;
+ documents = "${home}/doc";
+ download = tmp;
+ music = tmp;
+ pictures = tmp;
+ publicShare = "${home}/share";
+ templates = tmp;
+ videos = tmp;
+ };
+ }
+ (mkIf this.isHeadful {
+ mimeApps = {
+ enable = true;
+ defaultApplications = mkMerge (mapAttrsToList
+ (n: v: genAttrs v (_: ["${n}.desktop"]))
+ {
+ emacsclient = [
+ "application/json"
+ "application/vnd.ms-publisher"
+ "application/x-desktop"
+ "application/x-shellscript"
+ "application/x-trash"
+ "application/x-wine-extension-ini"
+ "application/xml"
+ "text/markdown"
+ "text/plain"
+ ];
+ firefox = [
+ "text/html"
+ "x-scheme-handler/http"
+ "x-scheme-handler/https"
+ ];
+ imv = [
+ "image/bmp"
+ "image/gif"
+ "image/jpeg"
+ "image/jpg"
+ "image/png"
+ "image/svg+xml"
+ "image/tiff"
+ "image/webp"
+ ];
+ mpv = [
+ "audio/aac"
+ "audio/flac"
+ "audio/mp3"
+ "audio/ogg"
+ "audio/wav"
+ "audio/webm"
+ "video/mkv"
+ "video/mp4"
+ "video/ogg"
+ "video/webm"
+ "video/x-matroska"
+ ];
+ });
+ };
+ })
+ ];
+}