From 3d503fd1c2e91b5c500fd3b32392f74785e5423c Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Sun, 23 Jun 2024 16:39:46 +0300 Subject: [PATCH] Expand xdg config Signed-off-by: Nikolaos Karaolidis --- users/common/configs/xdg/default.nix | 59 +++++++------------ users/common/default.nix | 1 + .../options/home-manager/theme/default.nix | 1 - .../options/home-manager/xdg/default.nix | 48 +++++++++++++++ users/configs/gpg-agent/default.nix | 2 +- users/configs/kitty/default.nix | 7 ++- users/configs/rofi/default.nix | 7 ++- users/configs/swww/default.nix | 2 +- users/configs/theme/default.nix | 7 ++- users/configs/vscode/default.nix | 4 +- users/configs/zsh/default.nix | 11 ++-- 11 files changed, 97 insertions(+), 52 deletions(-) create mode 100644 users/common/options/home-manager/xdg/default.nix diff --git a/users/common/configs/xdg/default.nix b/users/common/configs/xdg/default.nix index c1e3b3f..196f813 100644 --- a/users/common/configs/xdg/default.nix +++ b/users/common/configs/xdg/default.nix @@ -5,46 +5,31 @@ let in { home-manager.users = lib.attrsets.mapAttrs - (user: cfg: ( - let - cacheHome = "${cfg.home}/.cache"; - configHome = "${cfg.home}/.config"; - dataHome = "${cfg.home}/.local/share"; - stateHome = "${cfg.home}/.local/state"; - xdgVmDir = "${cfg.home}/VMs"; - xdgGitDir = "${cfg.home}/git"; - in - { - xdg = { + (user: cfg: ({ + xdg = { + enable = true; + mimeApps.enable = true; + + userDirs = { enable = true; - mimeApps.enable = true; - - inherit cacheHome; - inherit configHome; - inherit dataHome; - inherit stateHome; - - userDirs = { - enable = true; - extraConfig = { - XDG_VM_DIR = xdgVmDir; - XDG_GIT_DIR = xdgGitDir; - }; + extraConfig = { + XDG_VM_DIR = "${cfg.home}/VMs"; + XDG_GIT_DIR = "${cfg.home}/git"; }; }; + }; - home.persistence."/persist${cfg.home}".directories = [ - "Desktop" # userDirs.desktop - "Documents" # userDirs.documents - "Downloads" # userDirs.download - "Music" # userDirs.music - "Pictures" # userDirs.pictures - "Templates" # userDirs.templates - "Videos" # userDirs.videos - "VMs" # xdgVmDir - "git" # xdgGitDir - ]; - } - )) + home.persistence."/persist${cfg.home}".directories = [ + "Desktop" # userDirs.desktop + "Documents" # userDirs.documents + "Downloads" # userDirs.download + "Music" # userDirs.music + "Pictures" # userDirs.pictures + "Templates" # userDirs.templates + "Videos" # userDirs.videos + "VMs" + "git" + ]; + })) users; } diff --git a/users/common/default.nix b/users/common/default.nix index 391b1f7..8490e63 100644 --- a/users/common/default.nix +++ b/users/common/default.nix @@ -15,6 +15,7 @@ useGlobalPkgs = true; sharedModules = [{ imports = [ + ./options/home-manager/xdg ./options/home-manager/matugen ./options/home-manager/theme ]; diff --git a/users/common/options/home-manager/theme/default.nix b/users/common/options/home-manager/theme/default.nix index 4f631cc..83d9ba0 100644 --- a/users/common/options/home-manager/theme/default.nix +++ b/users/common/options/home-manager/theme/default.nix @@ -247,7 +247,6 @@ in fi ${cfg.extraConfig} - $ ''; }; in diff --git a/users/common/options/home-manager/xdg/default.nix b/users/common/options/home-manager/xdg/default.nix new file mode 100644 index 0000000..3a4482e --- /dev/null +++ b/users/common/options/home-manager/xdg/default.nix @@ -0,0 +1,48 @@ +{ config, lib, ... }: + +let + cfg = config.xdg; +in +{ + options.xdg = with lib; with types; { + relativeCacheHome = mkOption { + type = str; + default = ".cache"; + description = "Relative path to directory holding application caches."; + }; + + cacheHome = mkOption { + default = "${config.home.homeDirectory}/${cfg.relativeCacheHome}"; + }; + + relativeConfigHome = mkOption { + type = str; + default = ".config"; + description = "Relative path to directory holding application configurations."; + }; + + configHome = mkOption { + default = "${config.home.homeDirectory}/${cfg.relativeConfigHome}"; + }; + + relativeDataHome = mkOption { + type = str; + default = ".local/share"; + description = "Relative path to directory holding application data."; + }; + + dataHome = mkOption { + default = "${config.home.homeDirectory}/${cfg.relativeDataHome}"; + }; + + relativeStateHome = mkOption { + type = str; + default = ".local/state"; + description = "Relative path to directory holding application states."; + }; + + stateHome = mkOption { + default = "${config.home.homeDirectory}/${cfg.relativeStateHome}"; + }; + }; +} diff --git a/users/configs/gpg-agent/default.nix b/users/configs/gpg-agent/default.nix index bb93531..23de8aa 100644 --- a/users/configs/gpg-agent/default.nix +++ b/users/configs/gpg-agent/default.nix @@ -50,7 +50,7 @@ in Install.WantedBy = [ "default.target" ]; }; - tmpfiles.rules = [ "d ${hmConfig.xdg.dataHome}/gnupg 0700 ${user.name} users -" ]; + tmpfiles.rules = [ "d ${gpgPath} 0700 ${user.name} users -" ]; }; sops.secrets = { diff --git a/users/configs/kitty/default.nix b/users/configs/kitty/default.nix index 6eb5cfd..3de5e6d 100644 --- a/users/configs/kitty/default.nix +++ b/users/configs/kitty/default.nix @@ -1,5 +1,8 @@ -{ user ? throw "user argument is required" }: { ... }: +{ user ? throw "user argument is required" }: { config, ... }: +let + hmConfig = config.home-manager.users."${user.name}"; +in { home-manager.users."${user.name}" = { programs.kitty = { @@ -9,6 +12,6 @@ ''; }; - home.persistence."/cache${user.home}".directories = [ ".cache/kitty" ]; + home.persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/kitty" ]; }; } diff --git a/users/configs/rofi/default.nix b/users/configs/rofi/default.nix index 1f854c6..5cedc33 100644 --- a/users/configs/rofi/default.nix +++ b/users/configs/rofi/default.nix @@ -1,10 +1,13 @@ -{ user ? throw "user argument is required" }: { pkgs, ... }: +{ user ? throw "user argument is required" }: { config, pkgs, ... }: +let + hmConfig = config.home-manager.users."${user.name}"; +in { home-manager.users."${user.name}" = { home = { packages = with pkgs; [ rofi-wayland ]; - persistence."/cache${user.home}".directories = [ ".cache/rofi" ]; + persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/rofi" ]; }; }; } diff --git a/users/configs/swww/default.nix b/users/configs/swww/default.nix index 49dc174..b75b8b1 100644 --- a/users/configs/swww/default.nix +++ b/users/configs/swww/default.nix @@ -7,7 +7,7 @@ in home-manager.users."${user.name}" = { home = { packages = with pkgs; [ swww ]; - persistence."/cache${user.home}".directories = [ ".cache/swww" ]; + persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/swww" ]; }; theme.extraConfig = let name = "theme-swww"; in diff --git a/users/configs/theme/default.nix b/users/configs/theme/default.nix index 3a2e0fc..e34d5c8 100644 --- a/users/configs/theme/default.nix +++ b/users/configs/theme/default.nix @@ -1,8 +1,11 @@ -{ user ? throw "user argument is required" }: { pkgs, ... }: +{ user ? throw "user argument is required" }: { config, pkgs, ... }: +let + hmConfig = config.home-manager.users."${user.name}"; +in { home-manager.users."${user.name}" = { theme.enable = true; - home.persistence."/persist${user.home}".directories = [ ".config/theme" ]; + home.persistence."/persist${user.home}".directories = [ "${hmConfig.xdg.relativeConfigHome}/theme" ]; }; } diff --git a/users/configs/vscode/default.nix b/users/configs/vscode/default.nix index 053dfe7..e2377e9 100644 --- a/users/configs/vscode/default.nix +++ b/users/configs/vscode/default.nix @@ -62,8 +62,8 @@ home.persistence = { "/persist${user.home}".directories = [ ".config/Code" ]; - # Bastard: https://github.com/microsoft/vscode/issues/3884 - # Even bigger Bastards: + # Bastard: + # - https://github.com/microsoft/vscode/issues/3884 # - https://github.com/nix-community/impermanence/issues/22 # - https://github.com/nix-community/impermanence/pull/97 # "/cache${user.home}".directories = [ diff --git a/users/configs/zsh/default.nix b/users/configs/zsh/default.nix index a7bc9af..2091c1c 100644 --- a/users/configs/zsh/default.nix +++ b/users/configs/zsh/default.nix @@ -1,13 +1,16 @@ -{ user ? throw "user argument is required" }: { ... }: +{ user ? throw "user argument is required" }: { config, ... }: +let + hmConfig = config.home-manager.users."${user.name}"; +in { home-manager.users."${user.name}" = { programs.zsh = { enable = true; - dotDir = ".config/zsh"; + dotDir = "${hmConfig.xdg.relativeConfigHome}/zsh"; autocd = true; history = { - path = "${user.home}/.local/share/zsh/history"; + path = "${hmConfig.xdg.dataHome}/zsh/history"; expireDuplicatesFirst = true; }; historySubstringSearch.enable = true; @@ -15,6 +18,6 @@ syntaxHighlighting.enable = true; }; - home.persistence."/persist${user.home}".directories = [ ".local/share/zsh" ]; + home.persistence."/persist${user.home}".directories = [ "${hmConfig.xdg.relativeDataHome}/zsh" ]; }; }