143 lines
3.6 KiB
Bash
143 lines
3.6 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
echo "Initializing development environment..."
|
|
|
|
export DEV_HOME="$HOME"
|
|
export DEV_USER="$(basename "$DEV_HOME")"
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Software directories
|
|
# -----------------------------------------------------------------------------
|
|
|
|
mkdir -p /opt/rustup /opt/cargo /opt/aseprite
|
|
chown "$DEV_USER:$DEV_USER" /opt/rustup /opt/cargo /opt/aseprite
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Fish configuration
|
|
# -----------------------------------------------------------------------------
|
|
|
|
mkdir -p /etc/fish/conf.d
|
|
mkdir -p /etc/fish/completions
|
|
|
|
tee /etc/fish/conf.d/rust.fish >/dev/null <<'EOF'
|
|
set -gx RUSTUP_HOME /opt/rustup
|
|
set -gx CARGO_HOME /opt/cargo
|
|
fish_add_path $CARGO_HOME/bin
|
|
EOF
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Rustup
|
|
# -----------------------------------------------------------------------------
|
|
|
|
export RUSTUP_HOME=/opt/rustup
|
|
export CARGO_HOME=/opt/cargo
|
|
|
|
echo "Installing rustup..."
|
|
|
|
curl \
|
|
--proto '=https' \
|
|
--tlsv1.2 \
|
|
-sSf \
|
|
https://sh.rustup.rs \
|
|
| sh -s -- -y --no-modify-path
|
|
|
|
# Rust toolchain
|
|
echo "Installing stable Rust toolchain..."
|
|
|
|
/opt/cargo/bin/rustup default stable
|
|
|
|
# Fish completions
|
|
echo "Installing rustup Fish completion..."
|
|
|
|
/opt/cargo/bin/rustup completions fish \
|
|
| tee /etc/fish/completions/rustup.fish >/dev/null
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Aseprite
|
|
# -----------------------------------------------------------------------------
|
|
echo "Building Aseprite..."
|
|
git clone --recursive https://github.com/aseprite/aseprite.git /opt/aseprite
|
|
cd /opt/aseprite
|
|
./build.sh --auto --norun
|
|
|
|
echo "Creating Aseprite desktop entry..."
|
|
cat > /opt/aseprite/aseprite.desktop <<'EOF'
|
|
[Desktop Entry]
|
|
Name=Aseprite
|
|
Comment=Animated sprite editor
|
|
Exec=/opt/aseprite/build/bin/aseprite %F
|
|
Icon=/opt/aseprite/build/bin/data/icons/ase.ico
|
|
Terminal=false
|
|
Type=Application
|
|
Categories=Graphics;2DGraphics;
|
|
EOF
|
|
|
|
echo "Exporting Aseprite desktop entry..."
|
|
sudo -u "$DEV_USER" env HOME="$DEV_HOME" distrobox-export --app /opt/aseprite/aseprite.desktop
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Export development tools to the host
|
|
# -----------------------------------------------------------------------------
|
|
export PATH="/opt/cargo/bin:$PATH"
|
|
echo "Exporting development tools..."
|
|
|
|
export_bin() {
|
|
local binary="$1"
|
|
|
|
if command -v "$binary" >/dev/null 2>&1; then
|
|
echo " exporting $binary"
|
|
sudo -u "$DEV_USER" \
|
|
env HOME="$DEV_HOME" \
|
|
distrobox-export \
|
|
--bin "$(command -v "$binary")" \
|
|
--export-path "$DEV_HOME/.local/bin"
|
|
else
|
|
echo " warning: $binary not found"
|
|
fi
|
|
}
|
|
|
|
# Rust
|
|
for binary in \
|
|
cargo \
|
|
cargo-clippy \
|
|
cargo-fmt \
|
|
cargo-miri \
|
|
clippy-driver \
|
|
rls \
|
|
rust-analyzer \
|
|
rustc \
|
|
rustdoc \
|
|
rustfmt \
|
|
rust-gdb \
|
|
rust-gdbgui \
|
|
rust-lldb \
|
|
rustup
|
|
do
|
|
export_bin "$binary"
|
|
done
|
|
|
|
# Native toolchain
|
|
export_bin clang
|
|
export_bin clang++
|
|
export_bin cmake
|
|
export_bin ninja
|
|
export_bin lld
|
|
export_bin ld.lld
|
|
export_bin gdb
|
|
export_bin strace
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Done
|
|
# -----------------------------------------------------------------------------
|
|
|
|
echo
|
|
echo "Development environment initialized successfully."
|
|
echo
|
|
echo "Rust:"
|
|
/opt/cargo/bin/rustc --version
|
|
/opt/cargo/bin/cargo --version
|
|
/opt/cargo/bin/rustup --version
|