Expand xdg config

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-06-23 16:39:46 +03:00
parent e7d328cab5
commit 3d503fd1c2
11 changed files with 97 additions and 52 deletions

View File

@@ -5,30 +5,16 @@ let
in in
{ {
home-manager.users = lib.attrsets.mapAttrs home-manager.users = lib.attrsets.mapAttrs
(user: cfg: ( (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 = { xdg = {
enable = true; enable = true;
mimeApps.enable = true; mimeApps.enable = true;
inherit cacheHome;
inherit configHome;
inherit dataHome;
inherit stateHome;
userDirs = { userDirs = {
enable = true; enable = true;
extraConfig = { extraConfig = {
XDG_VM_DIR = xdgVmDir; XDG_VM_DIR = "${cfg.home}/VMs";
XDG_GIT_DIR = xdgGitDir; XDG_GIT_DIR = "${cfg.home}/git";
}; };
}; };
}; };
@@ -41,10 +27,9 @@ in
"Pictures" # userDirs.pictures "Pictures" # userDirs.pictures
"Templates" # userDirs.templates "Templates" # userDirs.templates
"Videos" # userDirs.videos "Videos" # userDirs.videos
"VMs" # xdgVmDir "VMs"
"git" # xdgGitDir "git"
]; ];
} }))
))
users; users;
} }

View File

@@ -15,6 +15,7 @@
useGlobalPkgs = true; useGlobalPkgs = true;
sharedModules = [{ sharedModules = [{
imports = [ imports = [
./options/home-manager/xdg
./options/home-manager/matugen ./options/home-manager/matugen
./options/home-manager/theme ./options/home-manager/theme
]; ];

View File

@@ -247,7 +247,6 @@ in
fi fi
${cfg.extraConfig} ${cfg.extraConfig}
$
''; '';
}; };
in in

View File

@@ -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}";
};
};
}

View File

@@ -50,7 +50,7 @@ in
Install.WantedBy = [ "default.target" ]; 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 = { sops.secrets = {

View File

@@ -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}" = { home-manager.users."${user.name}" = {
programs.kitty = { programs.kitty = {
@@ -9,6 +12,6 @@
''; '';
}; };
home.persistence."/cache${user.home}".directories = [ ".cache/kitty" ]; home.persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/kitty" ];
}; };
} }

View File

@@ -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-manager.users."${user.name}" = {
home = { home = {
packages = with pkgs; [ rofi-wayland ]; packages = with pkgs; [ rofi-wayland ];
persistence."/cache${user.home}".directories = [ ".cache/rofi" ]; persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/rofi" ];
}; };
}; };
} }

View File

@@ -7,7 +7,7 @@ in
home-manager.users."${user.name}" = { home-manager.users."${user.name}" = {
home = { home = {
packages = with pkgs; [ swww ]; 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 theme.extraConfig = let name = "theme-swww"; in

View File

@@ -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}" = { home-manager.users."${user.name}" = {
theme.enable = true; theme.enable = true;
home.persistence."/persist${user.home}".directories = [ ".config/theme" ]; home.persistence."/persist${user.home}".directories = [ "${hmConfig.xdg.relativeConfigHome}/theme" ];
}; };
} }

View File

@@ -62,8 +62,8 @@
home.persistence = { home.persistence = {
"/persist${user.home}".directories = [ ".config/Code" ]; "/persist${user.home}".directories = [ ".config/Code" ];
# Bastard: https://github.com/microsoft/vscode/issues/3884 # Bastard:
# Even bigger Bastards: # - https://github.com/microsoft/vscode/issues/3884
# - https://github.com/nix-community/impermanence/issues/22 # - https://github.com/nix-community/impermanence/issues/22
# - https://github.com/nix-community/impermanence/pull/97 # - https://github.com/nix-community/impermanence/pull/97
# "/cache${user.home}".directories = [ # "/cache${user.home}".directories = [

View File

@@ -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}" = { home-manager.users."${user.name}" = {
programs.zsh = { programs.zsh = {
enable = true; enable = true;
dotDir = ".config/zsh"; dotDir = "${hmConfig.xdg.relativeConfigHome}/zsh";
autocd = true; autocd = true;
history = { history = {
path = "${user.home}/.local/share/zsh/history"; path = "${hmConfig.xdg.dataHome}/zsh/history";
expireDuplicatesFirst = true; expireDuplicatesFirst = true;
}; };
historySubstringSearch.enable = true; historySubstringSearch.enable = true;
@@ -15,6 +18,6 @@
syntaxHighlighting.enable = true; syntaxHighlighting.enable = true;
}; };
home.persistence."/persist${user.home}".directories = [ ".local/share/zsh" ]; home.persistence."/persist${user.home}".directories = [ "${hmConfig.xdg.relativeDataHome}/zsh" ];
}; };
} }