refactor: move neovim-config to different repo and mount whole home as volume

This commit is contained in:
Job
2025-01-25 16:03:59 +01:00
parent 8fa4fa1037
commit b6efe55600
10 changed files with 23 additions and 153 deletions

View File

@@ -25,6 +25,10 @@ run_args() {
# clipbard (wl-copy) working.
[ -e "/run/user/$UID/wayland-0" ] && arg "-v /run/user/$UID/wayland-0:/run/user/1000/wayland-0"
# Add a volume for the home directory so it survives
# container upgrades.
arg "-v $name:/home/user:copy"
# Mount the ssh socket, directory and the git config
# directory. This gets the host ssh and git configuration
# working inside the container.
@@ -34,33 +38,32 @@ run_args() {
# Mount host directories with programming projects.
[ -d "$HOME/Code" ] && arg "-v $HOME/Code:/home/user/Code"
[ -d "$HOME/.config/devcontainer" ] && arg "-v $HOME/.config/devcontainer:/home/user/.dev"
# Add volumes for .local and .cache so these survive
# container restarts.
arg "-v $name-local:/home/user/.local"
arg "-v $name-cache:/home/user/.cache"
[ -d "$HOME/.config/devcontainer" ] && arg "-v $HOME/.config/devcontainer:/home/user/.config/devcontainer"
}
### MAIN ###
name="devcontainer"
image="ghcr.io/job79/devcontainer:latest"
fetch=false
image="ghcr.io/job79/devcontainer:main"
force=false
while test $# -gt 0; do
case "$1" in
--image | -i) shift && fetch=true && image="$1" ;;
--fetch | -f) fetch=true ;;
-i) shift && force=true && image="$1" ;;
-f) force=true ;;
-*) log "unknown argument '$1'" 'x' 31 ;;
*) name="$1" ;;
esac
shift
done
if [ "$fetch" = true ] || [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ]; then
if [ "$force" = true ] || [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ]; then
log "fetching devcontainer updates..."
if [ "$(podman pull -q "$image" 2>&1)" != "$(podman container inspect "$name" -f {{.Image}} 2>&1)" ]; then
log "container image downloaded" '✓' 32
if [ "$force" = true ] || [ "$(podman container inspect "$name" -f {{.Image}} 2>&1)" != "$(podman pull -q "$image" 2>&1)" ]; then
if [ $? -eq 0 ]; then
log "container image downloaded" '✓' 32
else
log "failed to download container image" 'x' 31
fi
podman container rm -f -t 1 "$name" 1>/dev/null
podman run -td $(run_args) "$image"
else
@@ -69,4 +72,4 @@ if [ "$fetch" = true ] || [ "$(podman container inspect "$name" -f {{.State.Runn
fi
podman start "$name" 1>/dev/null
podman exec --detach-keys "" -it "$name" bash -l
podman exec --detach-keys "ctrl-q" -it "$name" bash -l