From 6018cc6f1dada7aab9499c6b409111d1dd38efce Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sun, 31 May 2026 21:00:50 -0700 Subject: [PATCH] Make dotfiles worktree follow flake checkout --- dotfiles/gitconfig | 1 + nixos/environment.nix | 20 ++++++++++++++++---- nixos/justfile | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/dotfiles/gitconfig b/dotfiles/gitconfig index a8b35020..3ba11371 100644 --- a/dotfiles/gitconfig +++ b/dotfiles/gitconfig @@ -116,3 +116,4 @@ directory = /tmp/tmp.zfvv44RquC/runtime/data/org directory = /tmp/tmp.zFdvVnKk4B/runtime/data/org directory = /tmp/tmp.PQTdI3UzS3/runtime/data/org + directory = /srv/dotfiles/dotfiles/config/taffybar/taffybar diff --git a/nixos/environment.nix b/nixos/environment.nix index d89df995..d97494a1 100644 --- a/nixos/environment.nix +++ b/nixos/environment.nix @@ -6,7 +6,16 @@ inputs, ... }: let + envDotfilesWorktree = builtins.getEnv "DOTFILES_WORKTREE"; + defaultDotfilesWorktree = + if envDotfilesWorktree != "" + then envDotfilesWorktree + else "/srv/dotfiles"; libDir = "${config.dotfiles-worktree}/dotfiles/lib"; + zshLibDir = builtins.path { + path = ../dotfiles/lib; + name = "dotfiles-zsh-lib"; + }; machineFilenames = builtins.attrNames (builtins.readDir ./machines); machineNameFromFilename = filename: builtins.head (builtins.split "\\." filename); machineNames = map machineNameFromFilename machineFilenames; @@ -28,7 +37,10 @@ in }; dotfiles-worktree = mkOption { type = types.str; - default = "/srv/dotfiles"; + default = defaultDotfilesWorktree; + defaultText = literalExpression '' + builtins.getEnv "DOTFILES_WORKTREE" or "/srv/dotfiles" + ''; description = '' Runtime path to the shared, editable dotfiles checkout. Home Manager uses this for out-of-store symlink targets so links are stable across @@ -59,9 +71,9 @@ in plugins = ["git" "sudo" "pip"]; }; shellInit = '' - fpath=("$HOME/.lib/completions" "${libDir}/completions" $fpath) - fpath+="${libDir}/functions" - for file in "${libDir}/functions/"* + fpath=("${zshLibDir}/completions" $fpath) + fpath+="${zshLibDir}/functions" + for file in "${zshLibDir}/functions/"*(N) do autoload "''${file##*/}" done diff --git a/nixos/justfile b/nixos/justfile index 8e76a321..0fbe6c80 100644 --- a/nixos/justfile +++ b/nixos/justfile @@ -2,8 +2,8 @@ switch-substituters := "https://cache.nixos.org https://cache.nixos-cuda.org htt switch-trusted-public-keys := "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.nixos-cuda.org:74DUi4Ye579gUqzH4ziL9IyiJBlDpMRn9MBN8oNan9M= cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E= ai.cachix.org-1:N9dzRK+alWwoKXQlnn0H6aUx0lU/mspIoz8hMvGvbbc= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ik6cQjb41X0iXVXeHigGmycPPE= colonelpanic8-dotfiles.cachix.org-1:O6GF3nptpeMFapX29okzO92eSWXR36zqW6ZF2C8P0eQ= taffybar.cachix.org-1:beZotJ1nVEsAnJxa3lWn0zwzZM7oeXmGh4ADRpHeeIo= codex-cli.cachix.org-1:1Br3H1hHoRYG22n//cGKJOk3cQXgYobUel6O8DgSing= claude-code.cachix.org-1:YeXf2aNu7UTX8Vwrze0za1WEDS+4DuI2kVeWEE4fsRk=" switch *args: - case "$(systemctl show -P ActiveState nixos-upgrade.service 2>/dev/null)" in active|activating|reloading) /run/wrappers/bin/sudo systemctl stop nixos-upgrade.service;; esac - /run/wrappers/bin/sudo nixos-rebuild switch --flake ".#" --impure --option substituters '{{switch-substituters}}' --option trusted-public-keys '{{switch-trusted-public-keys}}' {{args}} + case "$(/run/current-system/sw/bin/systemctl show -P ActiveState nixos-upgrade.service 2>/dev/null)" in active|activating|reloading) /run/wrappers/bin/sudo /run/current-system/sw/bin/systemctl stop nixos-upgrade.service;; esac + dotfiles_worktree="$(/run/current-system/sw/bin/readlink -f "$PWD/..")"; /run/wrappers/bin/sudo env DOTFILES_WORKTREE="$dotfiles_worktree" PATH=/run/current-system/sw/bin:/nix/var/nix/profiles/system/sw/bin:/etc/profiles/per-user/root/bin:/usr/bin:/bin /run/current-system/sw/bin/nixos-rebuild switch --flake ".#" --impure --option substituters '{{switch-substituters}}' --option trusted-public-keys '{{switch-trusted-public-keys}}' {{args}} populate-cachix cache="colonelpanic8-dotfiles" host=`hostname` *args: store_path="$(nix build --no-link --print-out-paths ".#nixosConfigurations.{{host}}.config.system.build.toplevel" --impure --option warn-dirty false {{args}})" && cachix push {{cache}} "$store_path"