diff --git a/README.md b/README.md index f7eb440..dc9c99b 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ sh ~/nvim-config/bootstrap.sh ```bash sudo mkdir -p /etc/portage/package.use printf '%s\n' 'net-libs/nodejs npm' | sudo tee /etc/portage/package.use/nvim-config-nodejs -sudo emerge --ask dev-vcs/git app-editors/neovim net-libs/nodejs sys-apps/ripgrep sys-apps/fd +sudo emerge --ask dev-vcs/git app-editors/neovim net-libs/nodejs sys-apps/ripgrep ``` Then run: @@ -68,6 +68,8 @@ Then run: sh ~/nvim-config/bootstrap.sh ``` +If `sys-apps/fd` is unavailable or its distfile is broken, the bootstrap script will try `cargo install fd-find` and place `fd` in `/usr/local/bin`. + ## Notes - First run downloads plugins through `lazy.nvim`. @@ -75,3 +77,4 @@ sh ~/nvim-config/bootstrap.sh - Out of the box it covers C, C++, Rust, Bash, Lua, JSON, YAML, Markdown, JavaScript, TypeScript, and GLSL. - Shader extensions like `.vert`, `.frag`, `.comp`, `.geom`, `.rgen`, `.rchit`, `.rmiss`, `.rint`, and `.rcall` are treated as GLSL. - `nodejs`/`npm` are required so Mason can install the JS/TS/YAML/JSON tooling. +- On Gentoo, `fd` is installed by Portage if possible; otherwise the bootstrap script falls back to `cargo install fd-find`. diff --git a/bootstrap.sh b/bootstrap.sh index 0ce6413..bd47aae 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -4,6 +4,30 @@ set -eu repo_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +install_fd() { + if command -v fd >/dev/null 2>&1; then + return + fi + + if command -v emerge >/dev/null 2>&1; then + if sudo emerge --ask sys-apps/fd; then + return + fi + echo 'Gentoo fd package failed; trying cargo fallback.' >&2 + fi + + if command -v cargo >/dev/null 2>&1; then + tmpdir=$(mktemp -d) + cargo install --locked --root "$tmpdir" fd-find + sudo mkdir -p /usr/local/bin + sudo install -m 755 "$tmpdir/bin/fd" /usr/local/bin/fd + rm -rf "$tmpdir" + return + fi + + echo 'fd not installed; install sys-apps/fd or cargo manually.' >&2 +} + install_deps() { if command -v apt-get >/dev/null 2>&1; then sudo apt-get update @@ -19,7 +43,8 @@ install_deps() { if command -v emerge >/dev/null 2>&1; then sudo mkdir -p /etc/portage/package.use printf '%s\n' 'net-libs/nodejs npm' | sudo tee /etc/portage/package.use/nvim-config-nodejs >/dev/null - sudo emerge --ask dev-vcs/git app-editors/neovim net-libs/nodejs sys-apps/ripgrep sys-apps/fd + sudo emerge --ask dev-vcs/git app-editors/neovim net-libs/nodejs sys-apps/ripgrep + install_fd return fi