diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 1354800..ef48c23 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -147,3 +147,6 @@ Done: `offer_desktop()` (desktop [Y/n] → RDP [Y/n], WSL → [y/N] + hint), `co ## 2026-10-12 — WSL DNS confirmed + sshd hardening abort fixed Done: WSL DNS root cause confirmed (ubuntu-desktop-minimal → systemd-resolved/NetworkManager rewrote resolv.conf); repair runbook (disable both, rm resolv.conf, `wsl --shutdown`) worked. Then install aborted at harden_sshd: `systemctl reload ssh` on inactive unit + `set -e`. Fix 64f06bb on bugfix/sshd-reload-inactive: `is-active` guard + `try-reload-or-restart`, `/run/sshd` created before `sshd -t` (Ubuntu 24.04: privsep dir exists only while ssh.service runs — challenge correctness MAJOR). Stub smoke both branches, shellcheck, semgrep PASS. Not merged. + +## 2026-10-12 (2) — Rust toolchain at install +Done: `install_rust()` (rustup official script, user-level, stable + default profile + rust-analyzer/rust-src, `rustup update` on re-run, `--no-modify-path`), `libssl-dev`/`openssl@3`, 3 rc files source `~/.cargo/env` (if form, rc 0 when absent). Trigger: `~/.cargo` existed on this machine, nothing on PATH. Stub harness 2 paths + PATH dedup OK, shellcheck clean. Commit 7d62da4 on feature/rust-toolchain, pushed, not merged. zsh snippet untested (no zsh here), POSIX syntax. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 20861bf..e7cb48d 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -165,3 +165,12 @@ after ubuntu-desktop-minimal (hypothesis: NetworkManager/systemd-resolved rewrot - [x] install.sh: `offer_desktop()` — desktop [Y/n] then RDP [Y/n]; WSL → both default n with hint - [x] README step 11 + table + packages line; CHANGELOG Unreleased - [x] shellcheck + bash -n + stub harness for confirm defaults / WSL branch + +## Feature — Rust toolchain installed at install (2026-10-12) +Branch: feature/rust-toolchain (off develop). rustup official script, both OSes, as the user, +`--no-modify-path` (the rc files source `~/.cargo/env` themselves); apt rustc too old, brew rust has no rustup. +- [x] install.sh: `install_rust()` — rustup install (stable, default profile) or `rustup update` when present; `component add rust-analyzer rust-src` +- [x] install.sh: `libssl-dev` (apt) / `openssl@3` (brew) so openssl-sys crates build +- [x] bash/bashrc-linux, bash/bashrc-osx, zsh/zshrc-osx: source `~/.cargo/env` when present (PATH, dedup inside) +- [x] README (step, packages lines, table), CHANGELOG Unreleased, CLAUDE.md layout line +- [x] shellcheck + bash -n + stub harness (fresh HOME: install path, re-run path); commit on the branch, no finish without signal diff --git a/CHANGELOG.md b/CHANGELOG.md index b284f51..2d11a30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versioning: se ## [Unreleased] ### Added +- `install.sh` installs the Rust toolchain on both OSes with the official `rustup` script (`stable`, default profile + `rust-analyzer` `rust-src`, `rustup update` on a re-run, `--no-modify-path`); the deployed bashrc/zshrc source `~/.cargo/env`. `libssl-dev` (apt) / `openssl@3` (brew) added for `openssl-sys` crates. - `install.sh` asks the gitflow push mode (`gitflow.autopush`, exactly `true` or `false`, Enter = `true`) and writes it to `~/.gitconfig`; an existing value is reused, `DOTFILES_GITFLOW_AUTOPUSH` presets it, any other preset aborts the install. - `gitconfig`: fixed `core.hooksPath = ~/.claude/githooks`. - `tmux.conf`: move panes between windows — `J`/`L` join the marked pane below/beside, `S` swaps it with the current one, `(`/`)` (repeatable) move the pane to the previous/next slot. diff --git a/CLAUDE.md b/CLAUDE.md index b5fafac..36db45b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -51,6 +51,9 @@ code-server/mariadb, `~/.bash_profile` → `~/.bashrc`), asks zsh or bash (zsh b items it skipped. Keep `bashrc-osx` = `bashrc-linux` + macOS deltas only, and the zsh files in step with them (same env, aliases, prompt). +Rust comes from the official rustup script (`install_rust`, user-level, `--no-modify-path`); the +rc files source `~/.cargo/env`. Never add `rustc`/`cargo` to the apt or brew lists. + `pymupdf`/`markdown_py` are NOT tracked — they are pipx entry-point shims, recreated by `pipx install PyMuPDF Markdown` in install.sh. `claude-provider` reads `$OPENROUTER_API_KEY` from the env — never hardcode it (the diff --git a/README.md b/README.md index 861c32f..7fd1c84 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/main/remote-install. | Path | Purpose | | -------------------- | -------------------------------------------------------------- | -| `install.sh` | Linux: installs apt packages + Docker + code-server, offers the GNOME desktop + RDP (gnome-remote-desktop; default no on WSL), backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts, pipx tools and a low-disk login warning; ends by offering four extras (`/tmp` on disk, SSH memory guard, the `cloudpex` NAS mount helper, rootless Docker). macOS: same tooling through Homebrew (see [macOS](#macos)), deploys the tmux config, then prints what was not installed compared with Linux. | +| `install.sh` | Linux: installs apt packages + Docker + code-server, offers the GNOME desktop + RDP (gnome-remote-desktop; default no on WSL), backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts, pipx tools, the Rust toolchain (rustup) and a low-disk login warning; ends by offering four extras (`/tmp` on disk, SSH memory guard, the `cloudpex` NAS mount helper, rootless Docker). macOS: same tooling through Homebrew (see [macOS](#macos)), deploys the tmux config, then prints what was not installed compared with Linux. | | `tmux.conf` | tmux config (vi keys, mouse, status bar, tpm plugins: resurrect + continuum session restore, window-name). Deployed on both OSes to `~/.config/tmux/tmux.conf` (tmux ≥ 3.1). | | `cloudpex/` | On-demand SMB mount of a NAS share (`cloudpex` command + its installer, offered `[y/N]` at the end of a Linux install). Site values (host, share, SMB user, mount point, SMB version) are prompted at install and stored in `/etc/cloudpex.conf`, never in the script. French README inside. | | `etc/tmpfiles.d/tmp.conf` | Cleanup rules for a disk-backed `/tmp` (wiped at boot, 10-day purge). Deployed by the `/tmp` on disk offer. | @@ -69,7 +69,7 @@ What it does: 4. Clones the `syntastic` and `nerdtree` vim plugins into `~/.vim/bundle/`. 5. Copies the tracked vim files into `~/.vim` and symlinks `~/.vimrc`. 6. Picks the bashrc by OS: macOS → `bashrc-osx` (falls back to `bashrc-linux` if missing), everything else → `bashrc-linux`. Renders it into `~/.bashrc` with the identity asked at the very start: a name and an email for git commits and vim headers. An `export USER=` / `export EMAIL=` already present in `~/.bashrc` or `~/.zshrc` is reused without asking, so a re-run never prompts twice; `IDENTITY_USER` / `IDENTITY_EMAIL` preset them; with no terminal attached it falls back to the login name and an empty email. The values live only in the deployed files, never in the repo. Then renders `gitconfig` into `~/.gitconfig` with the same name and email (skipped, push mode included, when the name or email is empty, e.g. a first install with no terminal and no `IDENTITY_EMAIL`). The installer asks once whether the gitflow hooks push every commit and merge (`true` or `false` exactly, Enter = `true`); a `true`/`false` already in `~/.gitconfig` is reused without asking and survives the redeploy; `DOTFILES_GITFLOW_AUTOPUSH=true|false` presets it for a non-interactive install, an existing `~/.gitconfig` value still winning (no terminal and no preset gives `true`; any other preset aborts the install); the render refuses to write a file where `@AUTOPUSH@` leaked, since a non-boolean value blocks every push. To switch later: `git config --global gitflow.autopush true|false`. A different existing `~/.gitconfig` is saved as `~/.gitconfig.backup-`; an identical one is left alone. It is the global level only: a repo's own `.git/config` still overrides it. `core.excludesfile` points at `~/.gitignore`, ignored by git when the file does not exist. `core.hooksPath` is fixed to `~/.claude/githooks`, the gitflow hooks created by `make link` in the claude-config repo; the installer neither creates nor checks that directory. Being global, it makes git ignore each repo's `.git/hooks/` unless that repo sets its own `core.hooksPath`. Then deploys `tmux.conf` to `~/.config/tmux/tmux.conf` (both OSes, tmux ≥ 3.1: Ubuntu 22.04+, brew), clones [tpm](https://github.com/tmux-plugins/tpm) and fetches the listed plugins headlessly; details under [macOS](#macos) step 6, the step is the same. On Linux, `y` copies into tmux's buffer and the terminal clipboard through OSC 52; macOS uses `pbcopy`/`pbpaste`. -7. Installs Python CLIs via `pipx` (`PyMuPDF` → `pymupdf`, `Markdown` → `markdown_py`) — skipped if `pipx` is absent. +7. Installs Python CLIs via `pipx` (`PyMuPDF` → `pymupdf`, `Markdown` → `markdown_py`) — skipped if `pipx` is absent. Then installs the **Rust toolchain** on both OSes with the official `rustup` script, as you, never `sudo`: `stable` toolchain, default profile (`rustc cargo rust-std rust-docs rustfmt clippy`) plus `rust-analyzer` and `rust-src` for IDE support. On a re-run an existing `rustup` is updated (`rustup update`) instead of reinstalled. The script runs with `--no-modify-path`: the deployed bashrc/zshrc source `~/.cargo/env` when it exists, which puts `~/.cargo/bin` on `PATH` once. `CARGO_HOME` and `RUSTUP_HOME` keep their defaults (`~/.cargo`, `~/.rustup`). `libssl-dev` (apt) / `openssl@3` (brew) are installed so crates on `openssl-sys` build. 8. Copies the `bin/` scripts (`dt`, `dtach-router`, `claude-provider`, `repo-sync`, `tmux-copy-exit-keys`) into `~/.local/bin`. The dtach session-resume menu ships in the deployed bashrc (both OSes), so every interactive shell offers it — including VS Code Remote-SSH terminals, which are non-login and never read `~/.profile`. The installer also strips any older dtach block left in `~/.profile` so a plain SSH login doesn't prompt twice. 9. On Linux, installs `etc/profile.d/disk-usage-warning.sh` to `/etc/profile.d/` (needs `sudo`) so each login warns when `/` or `/home` cross 85% usage. 10. On Linux, installs **code-server** (VS Code in the browser) via its vendor script — skipped if already present — and enables the `code-server@` systemd service (login from `id -un`: the bashrc overrides `$USER`). @@ -83,7 +83,7 @@ What it does: ### Packages installed (apt) - **Build / VCS / C dev**: `vim git git-lfs git-filter-repo gitleaks gcc make pkg-config dkms valgrind shellcheck gh git-delta` (`git-delta` = `delta`, the pager set in `gitconfig`) -- **Net / security / transport**: `curl gnupg ca-certificates apt-transport-https net-tools openssh-server cifs-utils lftp ftp` +- **Net / security / transport**: `curl gnupg ca-certificates apt-transport-https libssl-dev net-tools openssh-server cifs-utils lftp ftp` (`libssl-dev`: build dependency of the `openssl-sys` Rust crate) - **Shell tooling**: `unzip tree tmux fzf dtach` - **Runtimes**: `nodejs python3-pip pipx php-cli` - **Web stack (local WordPress/LAMP)**: `mariadb-server imagemagick php-mysql php-gd php-imagick php-mbstring php-xml php-intl php-curl` (unversioned `php-*` metapackages, so they follow the distro's PHP) @@ -92,6 +92,7 @@ What it does: - **Desktop / GPU**: `ubuntu-desktop-minimal` (offered, Linux; default yes, no on WSL) + the distro-recommended NVIDIA driver via `ubuntu-drivers install` (only when an NVIDIA GPU is detected) - **Remote access**: `gnome-remote-desktop openssl` (apt, offered after the desktop) + `code-server` (via its vendor install script, not apt) — RDP remote login + browser VS Code - **pipx**: `PyMuPDF` (`pymupdf`), `Markdown` (`markdown_py`) +- **Rust (rustup, not apt)**: `stable` toolchain, default profile + `rust-analyzer rust-src` - **Security baseline (Linux, always)**: `fail2ban nftables unattended-upgrades` - **Optional (end-of-install offer, Linux)**: `earlyoom`; `uidmap dbus-user-session slirp4netns` (rootless Docker) @@ -104,7 +105,7 @@ The script is re-runnable: each run re-backs up to `~/Oldconfig` (overwriting th The same `./install.sh` detects macOS and replaces `apt-get` with Homebrew. After the identity and push-mode questions, it asks which login shell you want, **zsh** or **bash** (`[zsh]` by default; answer in advance with `MACOS_SHELL=bash ./install.sh`, and with no terminal attached it picks zsh): 1. Installs Homebrew with its official script when `brew` is missing (this also pulls the Xcode Command Line Tools: clang, make, git), then `brew update` + `brew upgrade`. -2. Installs the apt list mapped to formulae: `vim git git-lfs git-filter-repo gitleaks pkgconf shellcheck gh git-delta curl gnupg lftp inetutils unzip tree tmux fzf dtach node python pipx php mariadb imagemagick ffmpeg weasyprint poppler qpdf webp libavif bash`. Brew's `php` already ships gd, mbstring, xml, intl, curl and mysql. +2. Installs the apt list mapped to formulae: `vim git git-lfs git-filter-repo gitleaks pkgconf shellcheck gh git-delta curl gnupg lftp inetutils openssl@3 unzip tree tmux fzf dtach node python pipx php mariadb imagemagick ffmpeg weasyprint poppler qpdf webp libavif bash`. Brew's `php` already ships gd, mbstring, xml, intl, curl and mysql. 3. Docker: `colima` (the Linux VM) + `docker docker-compose docker-buildx`. Writes `~/.docker/config.json` with `cliPluginsExtraDirs` so `docker compose` works, only when that file does not exist yet (otherwise prints the line to add). 4. Starts `colima`, `code-server` and `mariadb` as `brew services` (the `systemctl enable --now` equivalent), skipping any already started. 5. Deploys `bashrc-osx`, then appends one line to `~/.bash_profile` that sources `~/.bashrc`: macOS terminals open login shells, which never read `~/.bashrc` on their own. Done for both choices, so `bash` stays usable. diff --git a/bash/bashrc-linux b/bash/bashrc-linux index af10fd1..60c8809 100644 --- a/bash/bashrc-linux +++ b/bash/bashrc-linux @@ -16,6 +16,12 @@ case ":$PATH:" in *) export PATH="$HOME/.local/bin:$PATH" ;; esac +# Rust toolchain (install.sh, rustup): puts ~/.cargo/bin on PATH, dedup done by the env file. +if [ -f "$HOME/.cargo/env" ]; then + # shellcheck source=/dev/null + . "$HOME/.cargo/env" +fi + # Rootless Docker (install.sh offer): tools that ignore the CLI context (docker-py, # testcontainers...) need DOCKER_HOST; only set when the user daemon's socket exists. if [ -S "${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/docker.sock" ]; then diff --git a/bash/bashrc-osx b/bash/bashrc-osx index 5ee3e07..6e38d42 100644 --- a/bash/bashrc-osx +++ b/bash/bashrc-osx @@ -26,6 +26,12 @@ case ":$PATH:" in *) export PATH="$HOME/.local/bin:$PATH" ;; esac +# Rust toolchain (install.sh, rustup): puts ~/.cargo/bin on PATH, dedup done by the env file. +if [ -f "$HOME/.cargo/env" ]; then + # shellcheck source=/dev/null + . "$HOME/.cargo/env" +fi + # Set history size to unlimited if [[ $EUID == 0 ]] ; then export HISTSIZE=0 diff --git a/install.sh b/install.sh index ac23fc2..bf65cdb 100755 --- a/install.sh +++ b/install.sh @@ -386,7 +386,7 @@ install_brew_packages() { brew upgrade brew install \ vim git git-lfs git-filter-repo gitleaks pkgconf shellcheck gh git-delta \ - curl gnupg lftp inetutils jq \ + curl gnupg lftp inetutils jq openssl@3 \ unzip tree tmux fzf dtach \ node python pipx php \ mariadb imagemagick \ @@ -394,6 +394,24 @@ install_brew_packages() { bash } +# Rust toolchain via rustup, as the user (never sudo), on both OSes: the apt rustc lags +# stable by months and brew's rust ships no rustup. --no-modify-path: the rc files this +# repo deploys source ~/.cargo/env themselves. Idempotent: an existing rustup is updated +# instead of reinstalled; a component already present is a no-op. +install_rust() { + local cargo_bin="$HOME/.cargo/bin" + if [ -x "$cargo_bin/rustup" ]; then + echo "Updating Rust toolchain (rustup update)" + "$cargo_bin/rustup" update + else + echo "Installing Rust toolchain (rustup, stable, default profile)" + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ + | sh -s -- -y --no-modify-path --default-toolchain stable --profile default + fi + # default profile = rustc cargo rust-std rust-docs rustfmt clippy; add the IDE pair. + "$cargo_bin/rustup" component add rust-analyzer rust-src +} + # Start a Homebrew service at login, like systemctl enable --now. Skipped when # already started, so a re-run never restarts a running database or VM. start_brew_service() { @@ -731,7 +749,7 @@ if command -v apt-get >/dev/null 2>&1; then # follow the distro's PHP version instead of pinning php8.x-*. sudo apt-get install -y \ vim git git-lfs git-filter-repo gitleaks gcc make pkg-config dkms valgrind shellcheck git-delta \ - curl gnupg ca-certificates apt-transport-https jq \ + curl gnupg ca-certificates apt-transport-https jq libssl-dev \ unzip tree tmux fzf dtach net-tools \ openssh-server cifs-utils lftp ftp \ nodejs python3-pip pipx php-cli \ @@ -831,6 +849,9 @@ if command -v pipx >/dev/null 2>&1; then pipx ensurepath >/dev/null fi +# Rust toolchain (rustup, user-level, both OSes). +install_rust + # Deploy personal CLI scripts to ~/.local/bin (dt, dtach-router, claude-provider, repo-sync, # tmux-copy-exit-keys). echo "Deploying CLI scripts to ~/.local/bin" diff --git a/zsh/zshrc-osx b/zsh/zshrc-osx index 97c37a9..177e266 100644 --- a/zsh/zshrc-osx +++ b/zsh/zshrc-osx @@ -35,6 +35,12 @@ case ":$PATH:" in *) export PATH="$HOME/.local/bin:$PATH" ;; esac +# Rust toolchain (install.sh, rustup): puts ~/.cargo/bin on PATH, dedup done by the env file. +if [ -f "$HOME/.cargo/env" ]; then + # shellcheck source=/dev/null + . "$HOME/.cargo/env" +fi + # History: none for root, near-unlimited otherwise (zsh has no -1 = unlimited). if [[ $EUID == 0 ]] ; then HISTSIZE=0