Compare commits

...

2 commits

Author SHA1 Message Date
5369a89b4b feat(shell): modernize default Zsh seed and login environment
Some checks are pending
ci / test (push) Waiting to run
Fixes the %F{ yellow } color bug (Phoebus Gold 214), drops the no-op
site-functions probe, puts fpath before a cached compinit (full audit at
most once per 24h), adds Kitty/application-mode keybindings, replaces
cross-tab SHARE_HISTORY with INC_APPEND_HISTORY, and adds a builtin
vcs_info git branch plus an exit-status prompt arrow. New ZSH_ZPROFILE
bridges /etc/profile (env-update paths, Nix/Flatpak profile.d) into Zsh
login sessions and adds ~/.local/bin to PATH. Seeding stays once-only;
root stays on Bash; /bin/sh untouched.

Verified: cargo fmt --check, clippy --workspace --all-targets -- -D
warnings, cargo test --workspace 757/757, zsh -n on both files plus an
interactive startup smoke test on host zsh 5.9. Installed-session
behavior awaits the disposable VM.
2026-09-26 15:31:10 -07:00
962e125208 docs(dual-boot): safe GRUB chainload of systemd-boot plus login notes
Phoebus stays systemd-boot + BLS (proven baseline, ADR 0002); external GRUB
chainloads EFI/systemd/systemd-bootx64.efi so sys undo BLS rewrites (ADR
0007) keep working and LUKS2/Argon2id is never exposed to GRUB cryptodisk.
The direct-kernel alternative is documented as fragile with the correct
rd.luks.name command line. No installer change.
2026-09-26 15:31:06 -07:00
6 changed files with 224 additions and 13 deletions

View file

@ -205,7 +205,9 @@ the actual execution, so the UI cannot diverge from the backend.
stays explicit.
- **Kernel/boot**: `sys-kernel/gentoo-kernel-bin` (safe) or `gentoo-kernel`
(optimized), dracut initramfs, systemd-boot BLS entries, plus a snapshot-based
recovery entry that does not depend on the live root.
recovery entry that does not depend on the live root. For running Phoebus
alongside other OSes, chainload this systemd-boot from the other OS's GRUB;
see `docs/DUAL-BOOT.md` (GRUB is never installed into the Phoebus target).
## Desktop assistant and administration architecture

View file

@ -62,6 +62,18 @@ this file is the curated, human-readable summary.
cases (non-root privilege refusals + root-safe Brave/unknown refusals).
Gates: `cargo fmt --check`, `clippy --workspace --all-targets -- -D
warnings`, release build, `test_vmsafety.py` 18/18, shellcheck clean.
- **Zsh defaults modernization (seeded once, user-owned afterwards).**
`ZSH_SKEL_RC` fixes the `%F{ yellow }` color bug (now Phoebus Gold 214),
drops the no-op site-functions probe, puts `fpath` before a cached
`compinit` (full audit at most once per 24h via `.zcompdump`), adds
Kitty/application-mode keybindings (Up/Down prefix search, Home/End/
Delete, word jumps), replaces cross-tab `SHARE_HISTORY` with
`INC_APPEND_HISTORY`, and adds a builtin `vcs_info` git branch plus an
exit-status prompt arrow. New `ZSH_ZPROFILE` bridges `/etc/profile`
(Gentoo `env-update` paths, Nix/Flatpak `profile.d`) into Zsh login
sessions and adds `~/.local/bin` to `PATH`. Verified: `zsh -n` clean on
both files, interactive startup smoke test, 757 workspace tests green;
installed-session behavior awaits the disposable VM.
- **Not VM-verified this session.** A fresh ISO was built from the
fast-defaults commit and content-verified (`fastdefaults.iso`, 1.6 GiB,
`ad9cddb2…`, build `20260926T145700Z` from `e747baf`; embedded

89
docs/DUAL-BOOT.md Normal file
View file

@ -0,0 +1,89 @@
# Dual-booting Phoebus OS with GRUB (chainload, safe)
Phoebus OS installs and boots with **systemd-boot + BLS entries** on the ESP.
That is the proven baseline (`docs/STATUS.md`, ADR 0002) and the layout that
`sys undo` rewrites on rollback (ADR 0007). **Do not replace it with GRUB
inside Phoebus.**
To run Phoebus alongside Windows or another Linux distribution whose boot menu
is GRUB 2, **chainload Phoebus's `systemd-boot` from GRUB**. This preserves the
verified boot path, keeps snapshot rollbacks coherent, and avoids GRUB's
LUKS2/Argon2id limitations entirely (kernels stay on the FAT32 ESP; dracut
unlocks LUKS2 with the kernel's native crypto).
## Login manager (already canonical, no change)
`greetd` + `tuigreet` is the installed login stack (`vt = 7`, `greeter` user,
default session `/usr/local/bin/phoebus-session-mango` launching Mango +
DankMaterialShell). Implemented in `phoebus-core::system::greetd_config` and
`phoebus-executor::desktop::configure_login`; VM-verified through greeter
startup and seated PAM authentication. Dual-boot changes nothing here.
## Recommended: GRUB chainloads systemd-boot
On the system that owns GRUB, add to `/etc/grub.d/40_custom`:
```grub
menuentry "Phoebus OS" --class phoebus --class os {
insmod part_gpt
insmod fat
insmod chain
# ESP filesystem UUID where Phoebus installed systemd-boot.
# Find it with: lsblk -f (or blkid) on the FAT32 ESP.
search --no-floppy --fs-uuid --set=root <ESP-UUID-HERE>
chainloader /EFI/systemd/systemd-bootx64.efi
}
```
Then regenerate:
```bash
sudo grub-mkconfig -o /boot/grub/grub.cfg
```
Verify on the ESP (mounted at `/efi` on Phoebus) that
`EFI/systemd/systemd-bootx64.efi` (plus the `EFI/BOOT/BOOTX64.EFI` fallback)
exists before rebooting.
## Alternative (fragile): direct kernel boot from GRUB
Prefer chainloading. A direct entry bypasses the systemd-boot menu and **drifts
out of sync** whenever `sys undo`, a kernel update, or a tuned-kernel install
rewrites `/loader/entries/*.conf`. If you use one anyway, never hand-write the
command line: copy the `linux`, `initrd`, and `options` lines verbatim from the
current Phoebus BLS entry (`/efi/loader/entries/*.conf`).
Reference shape (values differ per install; copy yours exactly):
```grub
menuentry "Phoebus OS (Direct)" --class phoebus --class gnu-linux {
insmod part_gpt
insmod fat
search --no-floppy --fs-uuid --set=root <ESP-UUID-HERE>
# Copy these three lines from your BLS entry. Note: Phoebus uses
# rd.luks.name=<LUKS-UUID>=cryptroot (not rd.luks.uuid), plus
# rootfstype=btrfs rootflags=subvol=@.
linux /<machine-id>/<kver>/linux rd.luks.name=<LUKS-UUID>=cryptroot root=/dev/mapper/cryptroot rootfstype=btrfs rootflags=subvol=@ rw quiet
initrd /<machine-id>/<kver>/initrd
}
```
Re-copy after every kernel/rollback change, or switch back to chainloading.
## Verification
1. `lsblk -f` / `blkid`: record the FAT32 ESP UUID.
2. Confirm `EFI/systemd/systemd-bootx64.efi` is present on that ESP.
3. Make GRUB the default UEFI boot target; select **Phoebus OS**.
4. Expect the systemd-boot menu (or direct kernel load), then the dracut LUKS
passphrase prompt, then `greetd`/`tuigreet` on VT 7.
5. Log in and confirm Mango + DankMaterialShell start.
## Non-goals / rules
- The Phoebus installer does not install GRUB into the target and does not
support `bootloader = "grub"` (`InstallConfig` accepts `systemd-boot` only).
- Never enable GRUB `cryptodisk` against the Phoebus LUKS2 container as the
primary boot path (Argon2id incompatibility / CPU cost).
- Never share or reformat the Phoebus ESP destructively; destructive testing
stays on a disposable qcow2 image, never `/dev/*` (AGENTS.md rule 1).

View file

@ -3,6 +3,16 @@
Rolling note between work sessions. **Update this file before you finish**, then
commit it. It should be short and current; use `git log` for detail.
- **Zsh modernization (2026-09-26, IMPLEMENTED + UNIT-TESTED, VM NOT RUN):**
rewrote `ZSH_SKEL_RC` (color fix, cached compinit, Kitty keybindings,
`INC_APPEND_HISTORY`, vcs_info git branch, exit-status prompt) and added
`ZSH_ZPROFILE` (`/etc/profile` bridge + `~/.local/bin`); `seed_default_zsh`
uses the new const. Gates: fmt, clippy `--workspace --all-targets -- -D
warnings`, 757/757 tests, `zsh -n` + interactive startup smoke on host zsh
5.9. Seeding is once-only (existing `~/.zshrc` preserved). Installed-session
behavior (login env, Nix paths, prompt/git/keys in Kitty) awaits the
disposable VM. Uncommitted; `docs/DUAL-BOOT.md` from the prior session also
still uncommitted.
- **Fast-defaults follow-up (2026-09-26, ISO BUILT + CONTENT-VERIFIED, VM NOT RUN):**
audited the `e747baf` fast-defaults tree against the prompt (all lanes
covered, no code changes needed), re-ran gates green (fmt, clippy -D,

View file

@ -337,29 +337,110 @@ pub fn cupsd_local_conf() -> String {
/// history search and a readable prompt. Existing users' files are never
/// overwritten (seeded only when absent).
pub const ZSH_SKEL_RC: &str = r#"# Phoebus default Zsh configuration (seeded once; user-owned afterwards).
autoload -Uz compinit && compinit
# --- 1. Completion paths (must precede compinit) ---------------------------
# Plain assignments (no duplicates handling needed here): entries that do not
# exist are ignored by compinit.
fpath=(
/usr/share/zsh/site-functions
$HOME/.local/share/zsh/site-functions
$fpath
)
# Fast cached completion init: full fpath audit at most once per 24h, cache
# (`-C`, no audit) otherwise. The audit is a security check (world-writable
# fpath entries), so it is deferred, never disabled.
autoload -Uz compinit
_zcompdump="${ZDOTDIR:-$HOME}/.zcompdump"
if [[ ! -f "$_zcompdump" ]] \
|| ! command -v find >/dev/null 2>&1 \
|| [[ -n $(find "${_zcompdump%/*}" -maxdepth 1 -name "${_zcompdump##*/}" -mtime +0 2>/dev/null) ]]; then
compinit -d "$_zcompdump"
else
compinit -C -d "$_zcompdump"
fi
unset _zcompdump
# --- 2. Keybindings (Emacs baseline + Kitty/application-mode compat) --------
bindkey -e
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
# Up/Down: history prefix search (both normal `^[[A` and application `^[OA`
# sequences; Kitty switches between them with smkx/rmkx).
bindkey '^[[A' up-line-or-beginning-search
bindkey '^[OA' up-line-or-beginning-search
bindkey '^[[B' down-line-or-beginning-search
bindkey '^[OB' down-line-or-beginning-search
bindkey '^R' history-incremental-search-backward
HISTSIZE=10000
SAVEHIST=10000
# Home/End/Delete/word jumps.
bindkey '^[[H' beginning-of-line
bindkey '^[OH' beginning-of-line
bindkey '^[[F' end-of-line
bindkey '^[OF' end-of-line
bindkey '^[[3~' delete-char
bindkey '^[[1;5C' forward-word
bindkey '^[[1;5D' backward-word
# --- 3. History (immediate write, no cross-session navigation) --------------
HISTFILE=~/.zsh_history
setopt APPEND_HISTORY SHARE_HISTORY HIST_IGNORE_DUPS HIST_IGNORE_SPACE
HISTSIZE=50000
SAVEHIST=50000
# INC_APPEND_HISTORY (not SHARE_HISTORY): each command hits the file at once
# so nothing is lost on crash, but Up/Down stays local to the session instead
# of pulling in commands from other tabs.
setopt EXTENDED_HISTORY INC_APPEND_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST HIST_IGNORE_DUPS HIST_FIND_NO_DUPS
setopt HIST_IGNORE_SPACE HIST_REDUCE_BLANKS
# --- 4. Ergonomics ----------------------------------------------------------
setopt AUTO_CD AUTO_PUSHD PUSHD_IGNORE_DUPS CORRECT
zstyle ':completion:*' menu select
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
[ -r /usr/share/zsh/site-functions ] || true
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' 'r:|[._-]=* r:|=*'
[[ -n ${LS_COLORS:-} ]] && zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
# Git branch via the vcs_info builtin (no external dependency); limited to
# git so prompt rendering stays fast. Appended to precmd_functions so a user
# precmd of their own keeps working.
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git:*' formats ' %F{242}(%F{214}%b%F{242})%f'
phoebus_vcs_precmd() { vcs_info; }
precmd_functions+=(phoebus_vcs_precmd)
# --- 5. Prompt (Phoebus Gold 214; arrow shows last exit status) --------------
setopt PROMPT_SUBST
PROMPT='%F{214}%n@%m%f %F{39}%~%f${vcs_info_msg_0_} %(?.%F{118}❯%f.%F{196}❯%f) '
RPROMPT='%F{242}%*%f'
# --- 6. Safe color aliases ---------------------------------------------------
alias ls='ls --color=auto'
alias ll='ls -la --color=auto'
alias grep='grep --color=auto'
alias diff='diff --color=auto'
# --- 7. Packaged plugins (highlighting last: it wraps prior widgets) --------
if [ -r /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then
source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
fi
if [ -r /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi
PROMPT='%F{ yellow }%n@%m%f %F{ blue }%~%f %# '
RPROMPT='%F{240}%*%f'
"#;
/// Zsh login environment (`/etc/zsh/zprofile`, generated).
/// Zsh login shells read this file and NOT `/etc/profile`, so without the
/// bridge below Gentoo's `env-update` paths and `/etc/profile.d/*.sh`
/// (Nix, Flatpak) would be missing from Zsh login sessions.
pub const ZSH_ZPROFILE: &str = r#"# /etc/zsh/zprofile - Phoebus Zsh login environment (generated).
# Bridge Gentoo's standard profile (profile.env, profile.d: Nix, Flatpak).
if [ -r /etc/profile ]; then
emulate sh -c 'source /etc/profile'
fi
# User-local binaries on PATH.
if [ -d "$HOME/.local/bin" ] && [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
export PATH="$HOME/.local/bin:$PATH"
fi
"#;
/// Login shell for newly created users. Root keeps `/bin/bash`;
@ -2720,9 +2801,26 @@ mod tests {
assert_eq!(USER_LOGIN_SHELL, "/bin/zsh");
assert_eq!(ROOT_LOGIN_SHELL, "/bin/bash");
assert!(ZSH_SKEL_RC.contains("compinit"));
assert!(ZSH_SKEL_RC.contains("compinit -C"));
assert!(ZSH_SKEL_RC.contains("zsh-autosuggestions"));
assert!(ZSH_SKEL_RC.contains("zsh-syntax-highlighting"));
assert!(ZSH_SKEL_RC.contains("up-line-or-beginning-search"));
// No `%F{<space>name<space>}`: zsh color names take no spaces.
assert!(!ZSH_SKEL_RC.contains("%F{ "));
assert!(!ZSH_SKEL_RC.contains(" }%"));
// Completion paths precede compinit; the old no-op probe is gone.
assert!(
ZSH_SKEL_RC.find("fpath=(").unwrap()
< ZSH_SKEL_RC.find("autoload -Uz compinit").unwrap()
);
assert!(!ZSH_SKEL_RC.contains("[ -r /usr/share/zsh/site-functions ] || true"));
// History is session-local (immediate write, no cross-tab pull).
assert!(ZSH_SKEL_RC.contains("setopt EXTENDED_HISTORY INC_APPEND_HISTORY"));
assert!(!ZSH_SKEL_RC.contains("APPEND_HISTORY SHARE_HISTORY"));
// Kitty/application-mode keybindings and the login-env bridge.
assert!(ZSH_SKEL_RC.contains("'^[OA'"));
assert!(ZSH_ZPROFILE.contains("emulate sh -c 'source /etc/profile'"));
assert!(ZSH_ZPROFILE.contains("$HOME/.local/bin"));
}
#[test]

View file

@ -167,10 +167,7 @@ fn ensure_root_shell_bash(exec: &Exec, root: &Path) -> Result<()> {
/// `~/.zshrc` from the maintained default, preserving existing custom files.
fn seed_default_zsh(exec: &Exec, config: &InstallConfig) -> Result<()> {
let target = exec.target();
target.write(
"etc/zsh/zprofile",
"# Phoebus Zsh login defaults (generated).\n",
)?;
target.write("etc/zsh/zprofile", phoebus_core::system::ZSH_ZPROFILE)?;
// Skeleton for future users; never overwrite customization.
if !target.exists("etc/skel/.zshrc") {
target.write("etc/skel/.zshrc", phoebus_core::system::ZSH_SKEL_RC)?;
@ -312,6 +309,9 @@ mod tests {
assert!(skel.contains("zsh-autosuggestions"));
let user_rc = std::fs::read_to_string(exec.root.join("home/ada/.zshrc")).unwrap();
assert!(user_rc.contains("up-line-or-beginning-search"));
// Login shells bridge Gentoo's /etc/profile (env-update, Nix).
let zprofile = std::fs::read_to_string(exec.root.join("etc/zsh/zprofile")).unwrap();
assert!(zprofile.contains("source /etc/profile"));
}
#[test]