Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a8e824941 | ||
|
|
07b3bfefad | ||
|
|
083f8dd16c |
@@ -0,0 +1,3 @@
|
|||||||
|
function dev-remove
|
||||||
|
distrobox rm --force dev
|
||||||
|
end
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
function dev
|
||||||
|
set -l name dev
|
||||||
|
set -l image fedora:44
|
||||||
|
|
||||||
|
set -l packages \
|
||||||
|
git \
|
||||||
|
gcc \
|
||||||
|
gcc-c++ \
|
||||||
|
make \
|
||||||
|
pkg-config \
|
||||||
|
openssl-devel \
|
||||||
|
clang \
|
||||||
|
llvm \
|
||||||
|
cmake \
|
||||||
|
lld \
|
||||||
|
gdb \
|
||||||
|
strace \
|
||||||
|
curl \
|
||||||
|
which \
|
||||||
|
file \
|
||||||
|
jq \
|
||||||
|
zoxide \
|
||||||
|
fzf \
|
||||||
|
eza \
|
||||||
|
ripgrep \
|
||||||
|
du-dust \
|
||||||
|
tldr \
|
||||||
|
cheat \
|
||||||
|
pv \
|
||||||
|
age
|
||||||
|
|
||||||
|
if distrobox list --no-color | string match -q "*| $name *"
|
||||||
|
distrobox enter $name
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "Creating Distrobox container '$name'..."
|
||||||
|
|
||||||
|
distrobox create \
|
||||||
|
--name $name \
|
||||||
|
--image $image --yes \
|
||||||
|
--additional-packages (string join ' ' $packages) \
|
||||||
|
--init-hooks 'bash "$HOME/.scripts/distrobox-dev-init.sh"'
|
||||||
|
|
||||||
|
if test $status -ne 0
|
||||||
|
echo "Failed to create container '$name'." >&2
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
distrobox enter $name --verbose
|
||||||
|
end
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "Initializing development environment..."
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Rust directories
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
mkdir -p /opt/rustup /opt/cargo
|
||||||
|
chown "$(id -u):$(id -g)" /opt/rustup /opt/cargo
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Export Rust development tools to the host
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
export PATH="/opt/cargo/bin:$PATH"
|
||||||
|
echo "Exporting development tools..."
|
||||||
|
|
||||||
|
DEV_HOME="$HOME"
|
||||||
|
DEV_USER="$(basename "$DEV_HOME")"
|
||||||
|
|
||||||
|
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 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
|
||||||
Reference in New Issue
Block a user