Files
nix/modules/home/xdg/default.nix

52 lines
1.9 KiB
Nix

# XDG stands for "Cross-Desktop Group", with X used to mean "cross".
# It's a bunch of specifications from freedesktop.org intended to standardize desktops and
# other GUI applications on various systems (primarily Unix-like) to be interoperable:
# https://www.freedesktop.org/wiki/Specifications/
{ config, pkgs, ... }: {
home.packages = with pkgs; [
xdg-utils # provides cli tools such as `xdg-mime` `xdg-open`
xdg-user-dirs
];
xdg = {
enable = true;
cacheHome = config.home.homeDirectory + "/.cache";
# manage $XDG_CONFIG_HOME/mimeapps.list
# xdg search all desktop entries from $XDG_DATA_DIRS, check it by command:
# echo $XDG_DATA_DIRS
# the system-level desktop entries can be list by command:
# ls -l /run/current-system/sw/share/applications/
# the user-level desktop entries can be list by command(user ryan):
# ls /etc/profiles/per-user/ryan/share/applications/
userDirs = {
enable = true;
createDirectories = false;
documents = config.home.homeDirectory + "/doc";
music = config.home.homeDirectory + "/doc/music";
desktop = config.home.homeDirectory + "/tmp";
download = config.home.homeDirectory + "/tmp";
videos = config.home.homeDirectory + "/tmp";
pictures = config.home.homeDirectory + "/tmp";
# templates = config.home.homeDirectory + "/tmp";
# publicShare = config.home.homeDirectory + "/tmp";
extraConfig = {
XDG_SCREENSHOTS_DIR = config.home.homeDirectory + "/tmp/Screenshots";
};
};
};
# 使用map函数循环 conf 变量,动态的生成 home.file.<user>.config.${i}
xdg.configFile = builtins.listToAttrs
(builtins.map
(name: {
inherit name;
value = {
source = config.home-libs.mkOutOfStoreSymlink "modules/home/xdg/conf/${name}";
};
})
(builtins.attrNames (builtins.readDir ./conf))
);
}