From 95ca15b2c6bf5a194bfe7dcbe9ffb9ff7a8db520 Mon Sep 17 00:00:00 2001 From: Ziad Arafat Date: Fri, 13 Nov 2026 13:20:49 -0700 Subject: [PATCH] Add full-work desktop subset and personal Codex CLI --- README.md | 27 ++++++++++++++++- bin/dot | 61 ++++++++++++++++++++++++++++----------- bootstrap.sh | 2 +- flake.nix | 5 ++-- home/agents.nix | 4 ++- home/default.nix | 1 + home/gui/apps.nix | 4 ++- home/gui/daynight.nix | 7 +++-- home/gui/sounds.nix | 2 +- scripts/daynight-hooks.py | 9 +++++- tests/profiles.sh | 33 +++++++++++++++++++++ 11 files changed, 128 insertions(+), 27 deletions(-) create mode 100644 tests/profiles.sh diff --git a/README.md b/README.md index 8ec059d..73a993b 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,31 @@ dot doctor Manual sign-ins that can't be automated: Edge (work account), Chrome and Firefox (personal account), XPipe (GitHub token for `RustyRaptor/xpipe-sync` on first launch), and the Bitwarden desktop app and browser extension. The extension comes back through browser sync. +## Desktop profiles + +`full` is the personal desktop and includes Codex alongside Claude. Codex is managed by Nix and updated by `dot switch` after updating flake inputs. Sign in with `codex` on first use; credentials stay outside this repository. + +`full-work` inherits the full desktop with these changes: + +- Excludes Chrome and its managed PWAs, Telegram, Vesktop (including its settings), Krita, Defguard and the Portal 2 sound builder. Edge and its work PWAs remain. +- Uses only the Work activity and Ace Combat wallpapers, with light/dark switching. On login, other activities are removed. Wallpaper checkout uses sparse checkout to exclude the personal folder. +- Keeps notification sounds and volume feedback enabled with the default KDE Ocean sound theme. +- Excludes Codex; Claude remains available. + +Apply on a desktop with: + +```bash +dot profile full-work +dot switch +dot system +dot apps +dot wallpapers +``` + +Log out and back in to apply the activity layout. Flatpak installation is additive: switching an existing personal machine does not uninstall previously installed applications or games, or remove their data. A previously installed Defguard root service must be disabled separately. The profile does not install Portal 2 or require its assets. + +For a fresh installation, set `DOTFILES_PROFILE=full-work`. `headless` remains the CLI-only profile. Run `bash tests/profiles.sh` to check the profile boundaries without applying them. + ## Day to day | Command | What | @@ -62,7 +87,7 @@ Manual sign-ins that can't be automated: Edge (work account), Chrome and Firefox | `dot update` | `git pull`, switch, `flatpak update`, `mise upgrade`, `claude update` | | `dot update --inputs` | same, plus bump `flake.lock` (nixpkgs, home-manager, plasma-manager, konsole_daynight) | | `dot switch` | apply after editing Nix files | -| `dot profile headless` / `full` / `auto` | switch layers; then `dot switch` | +| `dot profile headless` / `full` / `full-work` / `auto` | switch layers; then `dot switch` | | `dot secrets push` | upload this machine's secrets.env, SSH keys and WireGuard configs to Bitwarden | | `dot defguard` | preconfigure the Defguard VPN app for the home lab (see below) | | `dot wallpapers --push` | re-sort the wallpapers from the external drive and push them | diff --git a/bin/dot b/bin/dot index f7acadc..5fa92a9 100755 --- a/bin/dot +++ b/bin/dot @@ -57,12 +57,25 @@ flake_attr() { if [ "$p" = headless ] && [ "$(uname -m)" = aarch64 ]; then echo headless-aarch64; else echo "$p"; fi } +is_desktop() { case "$(profile)" in full|full-work) return 0;; *) return 1;; esac; } + +flatpak_apps() { + local app + while read -r app; do + [[ -z "$app" || "$app" == \#* ]] && continue + if [ "$(profile)" = full-work ]; then + case "$app" in com.google.Chrome|org.telegram.desktop|dev.vencord.Vesktop|org.kde.krita) continue;; esac + fi + printf '%s\n' "$app" + done <"$DOTFILES_DIR/config/flatpaks.txt" +} + cmd_profile() { case "${1:-}" in - full|headless) echo "$1" >"$STATE_DIR/profile"; ok "profile set to $1 (run: dot switch)";; + full|full-work|headless) echo "$1" >"$STATE_DIR/profile"; ok "profile set to $1 (run: dot switch)";; auto) rm -f "$STATE_DIR/profile"; ok "profile follows auto-detection ($(detect_profile))";; "") echo "$(profile)$( [ -s "$STATE_DIR/profile" ] || echo ' (auto)')";; - *) die "usage: dot profile [full|headless|auto]";; + *) die "usage: dot profile [full|full-work|headless|auto]";; esac } @@ -110,11 +123,11 @@ install_pkgs() { steamos) return 0 ;; # read-only /usr; SteamOS already ships zsh, podman, distrobox, flatpak, Konsole fedora) local p=(zsh git curl podman distrobox flatpak) - [ "$(profile)" = full ] && p+=(konsole spectacle) + is_desktop && p+=(konsole spectacle) SUDO dnf install -y "${p[@]}" ;; arch|cachyos|endeavouros|manjaro) local p=(zsh git curl podman distrobox flatpak xz) - [ "$(profile)" = full ] && p+=(konsole spectacle kate) + is_desktop && p+=(konsole spectacle kate) SUDO pacman -Sy --needed --noconfirm "${p[@]}" ;; almalinux|rhel|rocky) SUDO dnf install -y zsh git curl podman flatpak ;; @@ -127,6 +140,10 @@ install_pkgs() { browser_policies() { # Flathub Chrome/Edge merge host policies from /run/host/etc/opt//policies. for b in chrome edge; do + if [ "$b" = chrome ] && [ "$(profile)" = full-work ]; then + SUDO rm -f /etc/opt/chrome/policies/managed/dotfiles-pwas.json + continue + fi SUDO install -d -m 0755 "/etc/opt/$b/policies/managed" SUDO install -m 0644 "$DOTFILES_DIR/config/browsers/$b-pwas.json" "/etc/opt/$b/policies/managed/dotfiles-pwas.json" done @@ -168,10 +185,11 @@ defguard_service() { cmd_system() { local skip_pkgs=0 netbird=0 defguard=0 for a in "$@"; do case "$a" in --no-pkgs) skip_pkgs=1;; --netbird) netbird=1;; --defguard) defguard=1;; esac; done - [ "$(profile)" = full ] && { netbird=1; defguard=1; } + is_desktop && netbird=1 + [ "$(profile)" = full ] && defguard=1 step "distro layer for $(os_id) (needs sudo)" [ $skip_pkgs = 1 ] || install_pkgs - if [ "$(profile)" = full ]; then + if is_desktop; then browser_policies fi [ $netbird = 1 ] && netbird_service @@ -189,14 +207,14 @@ cmd_system() { flatpak_has() { flatpak info "$1" >/dev/null 2>&1; } cmd_apps() { - if [ "$(profile)" = full ] && have flatpak; then + if is_desktop && have flatpak; then step "Flatpaks (user scope)" flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo local missing=() while read -r app; do [ -z "$app" ] || [[ "$app" == \#* ]] && continue flatpak_has "$app" || missing+=("$app") - done <"$DOTFILES_DIR/config/flatpaks.txt" + done < <(flatpak_apps) # One at a time: a single failure (e.g. Chrome's extra-data step inside an # unprivileged container) would otherwise abort the whole batch. local failed=() @@ -462,7 +480,7 @@ cmd_wallpapers() { if [ -d "$WALLPAPER_SRC_WORK" ] || [ -d "$WALLPAPER_SRC_PERSONAL" ]; then have wallpaper-sort || die "wallpaper-sort missing (full profile)" [ -d "$WALLPAPER_SRC_WORK" ] && wallpaper-sort "$WALLPAPER_SRC_WORK" "$WALLPAPER_DIR/work" - [ -d "$WALLPAPER_SRC_PERSONAL" ] && wallpaper-sort "$WALLPAPER_SRC_PERSONAL" "$WALLPAPER_DIR/personal" + [ "$(profile)" != full-work ] && [ -d "$WALLPAPER_SRC_PERSONAL" ] && wallpaper-sort "$WALLPAPER_SRC_PERSONAL" "$WALLPAPER_DIR/personal" if [ -d "$WALLPAPER_DIR/.git" ] && [ "${1:-}" = --push ]; then git -C "$WALLPAPER_DIR" add -A && git -C "$WALLPAPER_DIR" commit -qm "wallpapers: resort $(date -I)" && git -C "$WALLPAPER_DIR" push -q || true fi @@ -470,10 +488,17 @@ cmd_wallpapers() { step "cloning wallpapers" local auth=() [ -n "${GITEA_TOKEN:-}" ] && auth=(-c "http.extraHeader=Authorization: token $GITEA_TOKEN") - git "${auth[@]}" clone --depth 1 "$WALLPAPER_REPO" "$WALLPAPER_DIR" || warn "wallpaper clone failed (dot secrets pull for git credentials?)" + git "${auth[@]}" clone --depth 1 --filter=blob:none --sparse "$WALLPAPER_REPO" "$WALLPAPER_DIR" || warn "wallpaper clone failed (dot secrets pull for git credentials?)" else git -C "$WALLPAPER_DIR" pull -q --ff-only || true fi + if [ -d "$WALLPAPER_DIR/.git" ]; then + if [ "$(profile)" = full-work ]; then + git -C "$WALLPAPER_DIR" sparse-checkout set work + else + git -C "$WALLPAPER_DIR" sparse-checkout disable + fi + fi have daynight-hooks && daynight-hooks --once >/dev/null 2>&1 || true } @@ -525,6 +550,7 @@ play_event() { # freedesktop sound name } cmd_sounds() { + [ "$(profile)" != full-work ] || die "full-work uses the default KDE sound theme; Portal 2 sounds are personal-only" case "${1:-build}" in build) have build-sound-theme || die "build-sound-theme missing (full profile)" @@ -555,7 +581,7 @@ cmd_update() { source_nix && nix flake update --flake "$DOTFILES_DIR" fi cmd_switch - [ "$(profile)" = full ] && have flatpak && { step "flatpak update"; flatpak update --user -y --noninteractive || true; } + is_desktop && have flatpak && { step "flatpak update"; flatpak update --user -y --noninteractive || true; } have mise && { step "mise upgrade"; mise upgrade -y || true; } have claude && { step "claude update"; claude update || true; } cmd_apps @@ -572,20 +598,21 @@ cmd_doctor() { chk "uv" "have uv || mise which uv" "dot apps" chk "pi" "have pi || mise which pi" "dot apps" chk "pokemon-go-colorscripts" "have pokemon-go-colorscripts || mise which pokemon-go-colorscripts" "dot apps" + [ "$p" != full ] || chk "codex" "have codex" "dot switch" chk "claude" "[ -x ~/.local/bin/claude ]" "dot apps" chk "podman" "have podman" "dot system" chk "distrobox" "have distrobox" "dot system" chk "ssh key" "[ -f ~/.ssh/id_ed25519 ]" "dot secrets pull" chk "secrets.env" "[ -s $SECRETS_ENV ]" "dot secrets pull" - if [ "$p" = full ]; then + if is_desktop; then chk "flatpak" "have flatpak" "dot system" while read -r app; do [ -z "$app" ] || [[ "$app" == \#* ]] && continue chk "flatpak $app" "flatpak_has $app" "dot apps" - done <"$DOTFILES_DIR/config/flatpaks.txt" - chk "Chrome PWA policy" "[ -f /etc/opt/chrome/policies/managed/dotfiles-pwas.json ]" "dot system" + done < <(flatpak_apps) + [ "$p" != full ] || chk "Chrome PWA policy" "[ -f /etc/opt/chrome/policies/managed/dotfiles-pwas.json ]" "dot system" chk "Edge PWA policy" "[ -f /etc/opt/edge/policies/managed/dotfiles-pwas.json ]" "dot system" - chk "wallpapers" "[ -d $WALLPAPER_DIR/personal ]" "dot wallpapers" + chk "wallpapers" "[ -d $WALLPAPER_DIR/work ]" "dot wallpapers" if has_systemd; then chk "konsole-daynight service" "systemctl --user is-active konsole-daynight" "dot switch, then log in to Plasma" chk "daynight-hooks service" "systemctl --user is-active daynight-hooks" "dot switch, then log in to Plasma" @@ -605,7 +632,7 @@ cmd_bootstrap() { # The new profile puts mise & friends on PATH. export PATH="$HOME/.nix-profile/bin:$HOME/.local/bin:$PATH" cmd_apps - [ "$(profile)" = full ] && { cmd_wallpapers || true; } + is_desktop && { cmd_wallpapers || true; } bw_server || true cat < None: """Create the configured activities; the stock "Default" one becomes the first.""" - names = list(json.loads(CONFIG.read_text())["activities"]) + cfg = json.loads(CONFIG.read_text()) + names = list(cfg["activities"]) am = bus.get("org.kde.ActivityManager", "/ActivityManager/Activities") existing = {am.ActivityName(i): i for i in am.ListActivities()} for name in names: @@ -94,6 +95,12 @@ def ensure_activities(bus) -> None: am.SetActivityName(existing.pop("Default"), name) else: am.AddActivity(name) + if cfg.get("workOnly"): + existing = {am.ActivityName(i): i for i in am.ListActivities()} + am.SetCurrentActivity(existing["Work"]) + for name, activity_id in existing.items(): + if name != "Work": + am.RemoveActivity(activity_id) def main() -> None: diff --git a/tests/profiles.sh b/tests/profiles.sh new file mode 100644 index 0000000..b11921e --- /dev/null +++ b/tests/profiles.sh @@ -0,0 +1,33 @@ +#!/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; + }' | 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 + 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) + else (.packages | index("codex") == null) and .activities == null 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" +cmd_profile full +full_apps="$(flatpak_apps)" +rg -q '^com.google.Chrome$' <<<"$full_apps" +echo 'Profile checks passed'