From 2343a739da725b37dd800422017008e7773feb8b Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 17 Mar 2025 20:05:16 +0000 Subject: [PATCH] Add XDG_REPOS_HOME variable --- bin/start-traefik | 2 +- bin/update-all-git-repos | 2 +- nix/home/opdavies/default.nix | 2 +- nix/modules/home-manager/cli/git.nix | 2 +- nix/modules/home-manager/cli/tmux-sessionizer.nix | 2 +- nix/modules/home-manager/cli/zsh.nix | 6 +++--- nix/modules/home-manager/cli/zsh/aliases.nix | 4 +++- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/start-traefik b/bin/start-traefik index 547e890b..6bbdb9d9 100755 --- a/bin/start-traefik +++ b/bin/start-traefik @@ -3,7 +3,7 @@ set -o errexit set -o nounset -cd "${REPOS}/traefik-development" +cd "${XDG_REPOS_DIR}/traefik-development" docker compose up --detach docker container ps diff --git a/bin/update-all-git-repos b/bin/update-all-git-repos index e5fbbc49..f3fa29e6 100755 --- a/bin/update-all-git-repos +++ b/bin/update-all-git-repos @@ -6,7 +6,7 @@ set -o errexit set -o nounset -dirs=$(find "$REPOS" -mindepth 1 -maxdepth 2 -type d -name .git -not -path '*/*.old/*') +dirs=$(find "$XDG_REPOS_DIR" -mindepth 1 -maxdepth 2 -type d -name .git -not -path '*/*.old/*') for dir in $dirs; do repo_path="${dir%/.git}" diff --git a/nix/home/opdavies/default.nix b/nix/home/opdavies/default.nix index fd29b0a4..c4b97506 100644 --- a/nix/home/opdavies/default.nix +++ b/nix/home/opdavies/default.nix @@ -70,8 +70,8 @@ in "./node_modules/.bin" ]; PULUMI_SKIP_UPDATE_CHECK = "true"; - REPOS = "$HOME/Code"; XDG_CONFIG_HOME = "${config.xdg.configHome}"; XDG_DATA_HOME = "${config.xdg.dataHome}"; + XDG_REPOS_DIR = "$HOME/Code"; }; } diff --git a/nix/modules/home-manager/cli/git.nix b/nix/modules/home-manager/cli/git.nix index 3b046c61..237ed745 100644 --- a/nix/modules/home-manager/cli/git.nix +++ b/nix/modules/home-manager/cli/git.nix @@ -29,7 +29,7 @@ includes = [ { - condition = "gitdir:~/Code/tfw"; + condition = "gitdir:${config.home.sessionVariables.XDG_REPOS_DIR}/tfw"; contents.user.email = "oliver.davies@tfw.wales"; } ]; diff --git a/nix/modules/home-manager/cli/tmux-sessionizer.nix b/nix/modules/home-manager/cli/tmux-sessionizer.nix index 2927781b..e8005681 100644 --- a/nix/modules/home-manager/cli/tmux-sessionizer.nix +++ b/nix/modules/home-manager/cli/tmux-sessionizer.nix @@ -25,7 +25,7 @@ with lib; set +o errexit set +o nounset - if [[ "$PWD" == "$REPOS/os" || "$PWD" == "$REPOS/personal" ]]; then + if [[ "$PWD" == "$XDG_REPOS_DIR/os" || "$PWD" == "$XDG_REPOS_DIR/personal" ]]; then clear return diff --git a/nix/modules/home-manager/cli/zsh.nix b/nix/modules/home-manager/cli/zsh.nix index eec1fb43..8da91cf3 100644 --- a/nix/modules/home-manager/cli/zsh.nix +++ b/nix/modules/home-manager/cli/zsh.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ config, pkgs, ... }: { programs.zsh = { @@ -12,8 +12,8 @@ abbreviations = import ./zsh/abbreviations.nix; }; - cdpath = [ "~/Code" ]; - dotDir = ".config/zsh"; + cdpath = [ "$HOME/Code" ]; + dotDir = "${config.xdg.configHome}/zsh"; shellAliases = (import ./zsh/aliases.nix); diff --git a/nix/modules/home-manager/cli/zsh/aliases.nix b/nix/modules/home-manager/cli/zsh/aliases.nix index fe7de689..0b362271 100644 --- a/nix/modules/home-manager/cli/zsh/aliases.nix +++ b/nix/modules/home-manager/cli/zsh/aliases.nix @@ -1,3 +1,5 @@ +{ config, ... }: + { "$" = ""; "-" = "cd -"; @@ -8,6 +10,6 @@ s = "secrets"; secrets = ''doppler --project "$(whoami)" run''; tag = "tag-release"; - vss = "LC_ALL=C sort --unique $REPOS/dotfiles/nvim/spell/en.utf-8.add --output $REPOS/dotfiles/nvim/spell/en.utf-8.add"; + vss = "LC_ALL=C sort --unique ${config.home.sessionVariables.XDG_REPOS_DIR}/dotfiles/nvim/spell/en.utf-8.add --output ${config.home.sessionVariables.XDG_REPOS_DIR}/dotfiles/nvim/spell/en.utf-8.add"; wt = "git worktree"; }