46 lines
1.3 KiB
Nix
46 lines
1.3 KiB
Nix
# --- This file has been auto-generated. For permanent changes alter the appropriate block in the README.org. ---
|
|
{ lib, config, pkgs, ... }:
|
|
|
|
let
|
|
cfg = config.xdg.userDirs;
|
|
in
|
|
{
|
|
options.xdg.userDirs = {
|
|
enable = lib.mkEnableOption "XDG User Directories";
|
|
|
|
directories = lib.mkOption {
|
|
type = lib.types.attrsOf lib.types.str;
|
|
default = {
|
|
DESKTOP = "Desktop";
|
|
DOWNLOAD = "Downloads";
|
|
TEMPLATES = "Templates";
|
|
PUBLICSHARE = "Public";
|
|
DOCUMENTS = "Documents";
|
|
MUSIC = "Music";
|
|
PICTURES = "Pictures";
|
|
VIDEOS = "Videos";
|
|
};
|
|
description = ''
|
|
XDG User Directories.
|
|
Specify the subdirectory names for each XDG user directory type.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
environment.sessionVariables = lib.genAttrs cfg.directories (
|
|
dirName: dirValue: "XDG_${toUpper dirName}_DIR" -> "${config.xdg.dataHome}/${dirValue}"
|
|
);
|
|
|
|
system.activationScripts.xdgUserDirs = ''
|
|
mkdir -p ${toString (
|
|
builtins.attrValues (
|
|
builtins.mapAttrs (dirName: dirValue: "${config.xdg.dataHome}/${dirValue}")
|
|
cfg.directories
|
|
)
|
|
)}
|
|
chown -R ${toString config.users.users.${config.defaultUser or "henrov"}.name}: "${config.xdg.dataHome}"
|
|
'';
|
|
};
|
|
}
|