Skip to content

Commit 1499344

Browse files
committed
opencode: add to sandbox and common
1 parent f1d7521 commit 1499344

4 files changed

Lines changed: 39 additions & 0 deletions

File tree

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ PROJECT_FILES=(
4040
"src/sandbox/log.sh"
4141
"src/sandbox/name.sh"
4242
"src/sandbox/nix.sh"
43+
"src/sandbox/opencode.sh"
4344
"src/sandbox/ping.sh"
4445
"src/sandbox/pipewire.sh"
4546
"src/sandbox/pulseaudio.sh"

data/common/opencode

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-FileCopyrightText: Andrew Hayzen <ahayzen@gmail.com>
2+
#
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
# Note this assumes you have installed tar, wget and xz-utils
6+
7+
RUN wget https://github.com/anomalyco/opencode/releases/download/${OPENCODE_VERSION:-v1.3.0}/opencode-linux-x64.tar.gz \
8+
&& mkdir -p /usr/local/bin/opencode-${OPENCODE_VERSION:-v1.3.0} \
9+
&& tar -xf opencode-linux-x64.tar.gz -C /usr/local/bin/opencode-${OPENCODE_VERSION:-v1.3.0}/ \
10+
&& rm opencode-linux-x64.tar.gz \
11+
&& echo "export PATH=\"/usr/local/bin/opencode-${OPENCODE_VERSION:-v1.3.0}:\$PATH\"" > /etc/profile.d/90-opencode-${OPENCODE_VERSION:-v1.3.0}.sh
12+

src/sandbox/main.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ function sandbox_setup() {
2727
sandbox_setup_language
2828
printf "\r(%s) Finding Log ..." "$TAG_NAME"
2929
sandbox_setup_log
30+
printf "\r(%s) Finding Opencode ..." "$TAG_NAME"
31+
sandbox_setup_opencode
3032
printf "\r(%s) Finding Nix ..." "$TAG_NAME"
3133
sandbox_setup_nix
3234
printf "\r(%s) Finding ping ... " "$TAG_NAME"

src/sandbox/opencode.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-FileCopyrightText: Andrew Hayzen <ahayzen@gmail.com>
2+
#
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
function sandbox_setup_opencode() {
6+
# If there is an opencode config then mount it into the container
7+
if [ -f "$HOME/.config/opencode/opencode.json" ]; then
8+
# Ensure parent of mounted opencode folder exists
9+
# otherwise .config is root in the container
10+
mkdir -p "$PERSIST_FOLDER/home/.config/opencode"
11+
12+
CONTAINER_RUN_ARGS+=(--volume="$HOME/.config/opencode/opencode.json":"$HOME/.config/opencode/opencode.json":ro)
13+
fi
14+
15+
# If there is an opencode tui config then mount it into the container
16+
if [ -f "$HOME/.config/opencode/tui.json" ]; then
17+
# Ensure parent of mounted opencode folder exists
18+
# otherwise .config is root in the container
19+
mkdir -p "$PERSIST_FOLDER/home/.config/opencode"
20+
21+
CONTAINER_RUN_ARGS+=(--volume="$HOME/.config/opencode/tui.json":"$HOME/.config/opencode/tui.json":ro)
22+
fi
23+
}
24+

0 commit comments

Comments
 (0)