From 5ec0a8f9302a35ba08251be52e000f87693fcf37 Mon Sep 17 00:00:00 2001 From: Sam Lehman Date: Wed, 24 Jul 2024 06:11:23 -0400 Subject: [PATCH] feat: //hive/homeProfiles/xdg: set home.preferXdgDirectories --- hm/profiles/xdg.nix | 186 +++++++++++++++++++++----------------------- 1 file changed, 89 insertions(+), 97 deletions(-) diff --git a/hm/profiles/xdg.nix b/hm/profiles/xdg.nix index 15ee7bed..23373865 100644 --- a/hm/profiles/xdg.nix +++ b/hm/profiles/xdg.nix @@ -1,85 +1,82 @@ -{ self -, inputs -, config -, lib -, pkgs -, ... -}: +{ config, lib, pkgs, ... }: +# TODO: Only define directories here & prevent pollution of $HOME +# TODO: Set program data dirs, etc. in their own Nix configs if they respect XDG Base Directories spec. +# TODO: Split into directory w/ {default,mime,basedirs,userDirs,paths,etc}.nix ??? +# xdg/ +# default.nix +# force.nix +# mimetypes.nix +# userdirs.nix let homedir = config.home.homeDirectory; in -# TODO: Only define directories here & prevent pollution of $HOME - # TODO: Set program data dirs, etc. in their own Nix configs if they respect XDG Base Directories spec. - # TODO: Split into directory w/ {default,mime,basedirs,userDirs,paths,etc}.nix ??? { - imports = [ ]; - xdg = { enable = true; # --- Base Dirs --- - cacheHome = "${homedir}/.cache"; + cacheHome = "${homedir}/.cache"; configHome = "${homedir}/.config"; - dataHome = "${homedir}/.local/share"; - stateHome = "${homedir}/.local/state"; + dataHome = "${homedir}/.local/share"; + stateHome = "${homedir}/.local/state"; # --- MIME Type Handling --- + # TODO: Move to separate file: mimetypes.nix + # TODO: Set MimeType for default terminal application: `x-scheme-handler/terminal` + # TODO: Configure: `~/.config/handlr/handlr.toml` + #xdg.mimeApps = { associations = { added={}; removed={}; }; defaultApplications={}; }; + #home.packages = [pkgs.handlr]; + mimeApps.enable = true; mime.enable = true; - mimeApps = { - enable = true; - #associations.added = { - #}; - #associations.removed = { - #}; - #defaultApplications = { - #}; + + systemDirs = { + config = [ "/etc/xdg" ]; + data = [ "/usr/share" "/usr/local/share" ]; }; - systemDirs.config = [ "/etc/xdg" ]; - systemDirs.data = [ "/usr/share" "/usr/local/share" ]; - - userDirs.enable = true; - userDirs.createDirectories = true; - userDirs.extraConfig = with config.xdg; { - XDG_BACKUP_DIR = "${homedir}/Backup"; - XDG_BOOKS_DIR = "${homedir}/Books"; - XDG_CODE_DIR = "${homedir}/Code"; - XDG_GAMES_DIR = "${homedir}/Games"; - XDG_NOTES_DIR = "${homedir}/Notes"; - - XDG_AUDIO_DIR = "${homedir}/Audio"; - #XDG_AUDIOBOOKS_DIR = "$XDG_AUDIO_DIR/Audiobooks"; - #XDG_SOUNDS_DIR = "$XDG_AUDIO_DIR/Sounds"; - #XDG_ALARMS_DIR = "$XDG_SOUNDS_DIR/Alarms"; - #XDG_SOUNDEFFECTS_DIR = "$XDG_SOUNDS_DIR/Effects"; - #XDG_NOTIFICATIONS_DIR = "$XDG_SOUNDS_DIR/Notifications"; - #XDG_NOISE_DIR = "$XDG_SOUNDS_DIR/Relax"; - #XDG_RINGTONES_DIR = "$XDG_SOUNDS_DIR/Ringtones"; - - #XDG_CLIPS_DIR = "${userdirs.videos}/Clips"; - #XDG_MOVIES_DIR = "${userdirs.videos}/Movies"; - #XDG_MUSICVIDEOS_DIR = "${userdirs.videos}/Songs"; - #XDG_TV_DIR = "${userdirs.videos}/TV"; - #XDG_YOUTUBE_DIR = "${userdirs.videos}/YouTube"; - - XDG_APPS_DIR = "${homedir}/.local/apps"; - XDG_BIN_DIR = "${homedir}/.local/bin"; - XDG_REPOS_DIR = "${homedir}/.local/repos"; - XDG_SCRIPTS_DIR = "${homedir}/.local/scripts"; - XDG_SECRETS_DIR = "${homedir}/.local/secrets"; - XDG_SYNC_DIR = "${homedir}/.local/sync"; - - XDG_ICONS_DIR = "${dataHome}/icons"; - XDG_THEMES_DIR = "${dataHome}/themes"; - - XDG_LAUNCHERS_DIR = "${dataHome}/applications"; - XDG_AUTOSTART_DIR = "${dataHome}/autostart"; - - XDG_UNITS_DIR = "${configHome}/systemd"; + userDirs = { + enable = true; + createDirectories = true; + extraConfig = with config.xdg; { + XDG_BACKUP_DIR = "${homedir}/Backup"; + XDG_BOOKS_DIR = "${homedir}/Books"; + XDG_CODE_DIR = "${homedir}/Code"; + XDG_GAMES_DIR = "${homedir}/Games"; + XDG_NOTES_DIR = "${homedir}/Notes"; + + XDG_AUDIO_DIR = "${homedir}/Audio"; + #XDG_AUDIOBOOKS_DIR = "$XDG_AUDIO_DIR/Audiobooks"; + #XDG_SOUNDS_DIR = "$XDG_AUDIO_DIR/Sounds"; + #XDG_ALARMS_DIR = "$XDG_SOUNDS_DIR/Alarms"; + #XDG_SOUNDEFFECTS_DIR = "$XDG_SOUNDS_DIR/Effects"; + #XDG_NOTIFICATIONS_DIR = "$XDG_SOUNDS_DIR/Notifications"; + #XDG_NOISE_DIR = "$XDG_SOUNDS_DIR/Relax"; + #XDG_RINGTONES_DIR = "$XDG_SOUNDS_DIR/Ringtones"; + + #XDG_CLIPS_DIR = "${userdirs.videos}/Clips"; + #XDG_MOVIES_DIR = "${userdirs.videos}/Movies"; + #XDG_MUSICVIDEOS_DIR = "${userdirs.videos}/Songs"; + #XDG_TV_DIR = "${userdirs.videos}/TV"; + #XDG_YOUTUBE_DIR = "${userdirs.videos}/YouTube"; + + XDG_APPS_DIR = "${homedir}/.local/apps"; + XDG_BIN_DIR = "${homedir}/.local/bin"; + XDG_REPOS_DIR = "${homedir}/.local/repos"; + XDG_SCRIPTS_DIR = "${homedir}/.local/scripts"; + XDG_SECRETS_DIR = "${homedir}/.local/secrets"; + XDG_SYNC_DIR = "${homedir}/.local/sync"; + + XDG_ICONS_DIR = "${dataHome}/icons"; + XDG_THEMES_DIR = "${dataHome}/themes"; + + XDG_LAUNCHERS_DIR = "${dataHome}/applications"; + XDG_AUTOSTART_DIR = "${dataHome}/autostart"; + + XDG_UNITS_DIR = "${configHome}/systemd"; + }; }; }; - # --- XDG Base Dirs: Force respect --------------------------------- home.sessionPath = with config.xdg.userDirs.extraConfig; [ # --- Custom Executables --- XDG_APPS_DIR @@ -90,6 +87,8 @@ in config.programs.go.goBin # TODO: CARGO_HOME/bin? # TODO: NPM bin dir + # TODO: AppImages? + # TODO: Script dirs? # TODO: Other package managers? # --- Editor Executables --- @@ -99,35 +98,34 @@ in #".git/safe/../../bin" ]; - # --- Nix --- - # TODO: Check what normally determines default: - # - "${home.homeDirectory}/.nix-profile" - # - "/etc/profiles/per-user/${home.username}" - #home.profileDirectory = "${dataDir}/nix/profiles"; - #nix.extraOptions = '' - # use-xdg-base-directories = ${if config.xdg.enable then "true" else "false"} - #''; + home = { + # TODO: Package: https://github.com/doron-cohen/antidot + packages = with pkgs; [ handlr xdg-ninja ]; + preferXdgDirectories = true; + #profileDirectory = "${dataDir}/nix/profiles"; + }; + + # --- XDG Base Dirs: Force respect --------------------------------- + nix.settings.use-xdg-base-directories = true; # --- System ----------------------------------- - gtk.gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc"; + gtk.gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc"; pam.yubico.authorizedYubiKeys.path = "${config.xdg.dataHome}/yubico/authorized_yubikeys"; - # --- Programming Languages -------------------- programs = with config.xdg; with config.xdg.userDirs.extraConfig; { - - #home-manager.path = pkgs.home-manager; - #home-manager.path = null; # Default (ordered): $HOME/{.config/nixpkgs, .nixpkgs}/home-manager - - go.goPath = ".local/go"; - go.goBin = ".local/bin.go"; - go.extraGoPaths = [ "${dataHome}/go" "${config.home.homeDirectory}/.go" ]; + # --- Programming Languages -------------------- + go = { + goPath = ".local/go"; + goBin = ".local/bin.go"; + extraGoPaths = [ "${dataHome}/go" "${config.home.homeDirectory}/.go" ]; + }; # --- Shells ----------------------------------- bash.historyFile = "${dataHome}/bash/history"; zsh.history.path = "${dataHome}/zsh/history"; nushell = { configFile.source = "${configHome}/nushell/config.nu"; - envFile.source = "${configHome}/nushell/env.nu"; + envFile.source = "${configHome}/nushell/env.nu"; }; @@ -136,17 +134,21 @@ in navi.settings.cheats.paths = [ "${dataHome}/cheats" "${configHome}/navi/cheats" ]; script-directory.settings.SD_ROOT = XDG_SCRIPTS_DIR; kodi.datadir = "${dataHome}/kodi"; - #kodi = { + #kodi = let + # inherit (config.xdg) userDirs; + # inherit (userDirs) music videos extraConfig; + #in with extraConfig; { # datadir = "${dataHome}/kodi"; # sources = { # video = { # default = "movies"; # source = [ - # { name = "videos"; path=userdirs.videos; allowsharing="true"; } + # { name = "videos"; path=videos; allowsharing="true"; } + # { name = "clips"; path=XDG_CLIPS_DIR; allowsharing="true"; } # { name = "movies"; path=XDG_MOVIES_DIR; allowsharing="true"; } # { name = "tv"; path=XDG_TV_DIR; allowsharing="true"; } # { name = "songs"; path=XDG_MUSICVIDEOS_DIR; allowsharing="true"; } - # { name = "clips"; path=XDG_CLIPS_DIR; allowsharing="true"; } + # { name = "shorts"; path=XDG_SHORTS_DIR; allowsharing="true"; } # ]; # }; # audio = { @@ -164,8 +166,7 @@ in # --- GUI Programs ----------------------------- services = with config.xdg.userDirs.extraConfig; with config.xdg; { dropbox.path = "${XDG_SYNC_DIR}/dropbox"; - recoll = { - # File indexer + recoll = { # File indexer configDir = "${configHome}/recoll"; settings = { dbdir = "${dataHome}/recoll"; @@ -177,13 +178,4 @@ in }; }; - - # --- XDG Utils ---------------------------------------------------- - home.packages = [ - # TODO: Set MimeType for default terminal application: `x-scheme-handler/terminal` - # TODO: Configure: `~/.config/handlr/handlr.toml` - pkgs.handlr - pkgs.xdg-ninja - ]; - }