Files

57 lines
3.5 KiB
Bash

#!/usr/bin/env bash
# Evaluate profile boundaries without installing or switching a desktop.
set -euo pipefail
cd "$(dirname "$0")/.."
for profile in full full-work headless; do
nix eval --impure --json ".#homeConfigurations.$profile.config" --apply 'c: {
packages = map (p: p.pname or p.name) c.home.packages;
activities = if c.dotfiles.gui then builtins.fromJSON c.xdg.configFile."dotfiles/activities.json".text else null;
theme = if c.dotfiles.gui then c.programs.plasma.configFile.kdeglobals.Sounds.Theme.value else null;
vesktop = builtins.hasAttr ".var/app/dev.vencord.Vesktop/config/vesktop/settings.json" c.home.file;
claudeSettings = builtins.hasAttr ".claude/settings.json" c.home.file;
claudeInstructions = builtins.hasAttr ".claude/CLAUDE.md" c.home.file;
gitEmail = c.programs.git.settings.user.email;
credentialStore = c.programs.git.settings.credential.credentialStore;
githubAuth = c.programs.git.settings.credential."https://github.com".gitHubAuthModes;
guiPrompt = c.programs.git.settings.credential.guiPrompt;
}' | jq -e --arg p "$profile" '
if $p == "full" then
(.packages | index("codex") != null and index("defguard-client") != null and index("build-sound-theme") != null) and
(.activities.activities | keys == ["Personal", "Work"]) and .theme == "portal2" and .vesktop and .claudeSettings and .claudeInstructions and
(.packages | index("sourcegit") != null) and .gitEmail == "anonymous0programmer@gmail.com" and .credentialStore == "secretservice" and .guiPrompt and .githubAuth == "browser"
elif $p == "full-work" then
(.packages | index("codex") == null and index("defguard-client") == null and index("build-sound-theme") == null and index("notification-sounds") != null) and
(.activities.activities | keys == ["Work"]) and .activities.workOnly and .theme == "ocean" and (.vesktop | not) and (.claudeSettings | not) and (.claudeInstructions | not) and
(.packages | index("sourcegit") != null) and .gitEmail == "ziad.arafat@etvamerica.com" and .credentialStore == "secretservice" and .guiPrompt
else (.packages | index("codex") == null and index("sourcegit") == null) and .activities == null and .claudeSettings and .claudeInstructions and
.credentialStore == "cache" and (.guiPrompt | not) and .githubAuth == "pat" end
'
done
# Exercise the same manifest selector used by apps and doctor in an isolated HOME.
export HOME="$(mktemp -d)"
trap 'rm -rf "$HOME"' EXIT
export DOTFILES_DIR="$PWD"
source <(sed '$d' bin/dot)
cmd_profile full-work
work_apps="$(flatpak_apps)"
! rg -q '^(com.google.Chrome|org.telegram.desktop|dev.vencord.Vesktop|org.kde.krita)$' <<<"$work_apps"
rg -q '^com.microsoft.Edge$' <<<"$work_apps"
# Work rendering must neither overwrite an existing Claude configuration nor
# create one on a fresh machine; other rendered agent configuration still works.
printf 'GITHUB_ACCESS_TOKEN=fixture-not-a-real-token\n' >"$SECRETS_ENV"
printf 'fixture: keep existing private data\n' >"$HOME/.git-credentials"
printf '{"fixture":"preserve"}\n' >"$HOME/.claude.json"
secrets_render
jq -e '.fixture == "preserve" and (has("mcpServers") | not)' "$HOME/.claude.json"
[ -s "$HOME/.pi/agent/mcp.json" ]
grep -qx 'fixture: keep existing private data' "$HOME/.git-credentials"
mv "$HOME/.claude.json" "$HOME/.claude.json.saved"
secrets_render
[ ! -e "$HOME/.claude.json" ]
cmd_profile full
full_apps="$(flatpak_apps)"
rg -q '^com.google.Chrome$' <<<"$full_apps"
secrets_render
jq -e '.mcpServers | length > 0' "$HOME/.claude.json"
echo 'Profile checks passed'