Skip to content

Commit

Permalink
Bring dotfiles into container
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavspi committed Jan 18, 2024
1 parent ae2f455 commit 82782ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ RUN grep -v '^#' /packages | xargs zypper --non-interactive install
RUN rm /packages
WORKDIR /

COPY / /opt/dotfiles
RUN chmod 775 /opt/dotfiles
RUN sh /opt/dotfiles/install.sh

# Convience symlinks
RUN ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/docker && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/flatpak && \
Expand Down
30 changes: 30 additions & 0 deletions chezmoi-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# -e: exit on error
# -u: exit on unset variables
set -eu

if ! chezmoi="$(command -v chezmoi)"; then
bin_dir="${HOME}/.local/bin"
chezmoi="${bin_dir}/chezmoi"
echo "Installing chezmoi to '${chezmoi}'" >&2
if command -v curl >/dev/null; then
chezmoi_install_script="$(curl -fsSL get.chezmoi.io)"
elif command -v wget >/dev/null; then
chezmoi_install_script="$(wget -qO- get.chezmoi.io)"
else
echo "To install chezmoi, you must have curl or wget installed." >&2
exit 1
fi
sh -c "${chezmoi_install_script}" -- -b "${bin_dir}"
unset chezmoi_install_script bin_dir
fi

# POSIX way to get script's dir: https://stackoverflow.com/a/29834779/12156188
script_dir="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)"

set -- init --apply --source="${script_dir}"

echo "Running 'chezmoi $*'" >&2
# exec: replace current process with chezmoi
exec "$chezmoi" "$@"

0 comments on commit 82782ee

Please sign in to comment.