Compare commits

..
2 Commits
Author SHA1 Message Date
fe5hua 99422bc415 dev container and git config 2026-10-09 06:19:05 +02:00
fe5hua 596b5873e6 made init hooks script idemptent 2026-09-15 06:24:20 +02:00
3 changed files with 94 additions and 23 deletions
+5 -1
View File
@@ -40,7 +40,11 @@ function dev
alsa-lib-devel \
systemd-devel \
libxkbcommon \
libxkbcommon-devel
libxkbcommon-devel \
libappindicator-gtk3-devel \
librsvg2-devel \
libxdo-devel \
nodejs24
if distrobox list --no-color | string match -q "*| $name *"
distrobox enter $name
+5
View File
@@ -0,0 +1,5 @@
[user]
name = fe5hua
email = git@fe5hua.de
[init]
defaultBranch = main
+84 -22
View File
@@ -11,8 +11,9 @@ 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
mkdir -p /opt/rustup /opt/cargo /opt/aseprite /opt/dx /opt/npm-global
chown -R "$DEV_USER:$DEV_USER" /opt/rustup /opt/cargo /opt/aseprite /opt/dx /opt/npm-global
# TODO basically all commamd from here on need to run as $DEV_USER, but scrpt runs as root
# -----------------------------------------------------------------------------
# Fish configuration
@@ -34,19 +35,23 @@ EOF
export RUSTUP_HOME=/opt/rustup
export CARGO_HOME=/opt/cargo
echo "Installing rustup..."
if [[ ! -x /opt/cargo/bin/rustup ]]; then
echo "Installing rustup..."
curl \
--proto '=https' \
--tlsv1.2 \
-sSf \
https://sh.rustup.rs \
| sh -s -- -y --no-modify-path
curl \
--proto '=https' \
--tlsv1.2 \
-sSf \
https://sh.rustup.rs \
| sh -s -- -y --no-modify-path
else
echo "rustup is already installed."
fi
# Rust toolchain
echo "Installing stable Rust toolchain..."
/opt/cargo/bin/rustup default stable
/opt/cargo/bin/rustup default nightly
# Fish completions
echo "Installing rustup Fish completion..."
@@ -55,16 +60,47 @@ echo "Installing rustup Fish completion..."
| tee /etc/fish/completions/rustup.fish >/dev/null
# Dioxus CLI
export DX_INSTALL=/opt/dx
if [[ ! -x /opt/cargo/bin/dx ]]; then
echo "Installing dioxus cli..."
# TODO needs to run as user, not root
curl -sSL https://dioxus.dev/install.sh | bash
else
echo "dioxus cli is already installed."
fi
# -----------------------------------------------------------------------------
# NodeJS and NPM
# -----------------------------------------------------------------------------
npm config set prefix '/opt/npm-global'
# -----------------------------------------------------------------------------
# Aseprite
# -----------------------------------------------------------------------------
echo "Building Aseprite..."
git clone --recursive https://github.com/aseprite/aseprite.git /opt/aseprite
cd /opt/aseprite
./build.sh --auto --norun
if [[ -f /opt/aseprite/aseprite.desktop ]]; then
echo "Aseprite desktop entry already exists; skipping installation."
else
if [[ ! -d /opt/aseprite ]]; then
echo "Cloning Aseprite..."
git clone --recursive https://github.com/aseprite/aseprite.git /opt/aseprite
else
echo "Aseprite source already exists."
fi
echo "Creating Aseprite desktop entry..."
cat > /opt/aseprite/aseprite.desktop <<'EOF'
cd /opt/aseprite
if [[ ! -x /opt/aseprite/build/bin/aseprite ]]; then
git submodule update --init --recursive
echo "Building Aseprite..."
./build.sh --auto --norun
else
echo "Aseprite is already built."
fi
echo "Creating Aseprite desktop entry..."
cat > /opt/aseprite/aseprite.desktop <<'EOF'
[Desktop Entry]
Name=Aseprite
Comment=Animated sprite editor
@@ -74,9 +110,16 @@ Terminal=false
Type=Application
Categories=Graphics;2DGraphics;
EOF
fi
echo "Exporting Aseprite desktop entry..."
sudo -u "$DEV_USER" env HOME="$DEV_HOME" distrobox-export --app /opt/aseprite/aseprite.desktop
if sudo -u "$DEV_USER" env HOME="$DEV_HOME" distrobox-export --list-apps 2>/dev/null |
grep -Fq "aseprite"
then
echo "Aseprite desktop entry is already exported."
else
echo "Exporting Aseprite desktop entry..."
sudo -u "$DEV_USER" env HOME="$DEV_HOME" distrobox-export --app /opt/aseprite/aseprite.desktop
fi
# -----------------------------------------------------------------------------
# Export development tools to the host
@@ -87,15 +130,31 @@ echo "Exporting development tools..."
export_bin() {
local binary="$1"
if command -v "$binary" >/dev/null 2>&1; then
if ! command -v "$binary" >/dev/null 2>&1; then
echo " warning: $binary not found"
elif sudo -u "$DEV_USER" env HOME="$DEV_HOME" \
distrobox-export \
--list-binaries \
--export-path "$DEV_HOME/.local/bin" 2>/dev/null |
awk -F'|' -v binary="$binary" '
{
name = $1
gsub(/^[[:space:]]+|[[:space:]]+$/, "", name)
if (name == binary) {
found = 1
}
}
END { exit !found }
'
then
echo " $binary is already exported."
else
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
}
@@ -114,7 +173,10 @@ for binary in \
rust-gdb \
rust-gdbgui \
rust-lldb \
rustup
rustup \
dx \
npm \
node
do
export_bin "$binary"
done