refactor: move neovim-config to different repo and mount whole home as volume
This commit is contained in:
@@ -13,19 +13,13 @@ RUN dnf update -y && \
|
||||
git go npm
|
||||
|
||||
# === setup container user ===
|
||||
RUN useradd -ms /bin/bash user && usermod -aG wheel user && sed -i '/NOPASSWD/s/^#//g' /etc/sudoers
|
||||
RUN mkdir /run/user/1000 && chown user:user /run/user/1000
|
||||
RUN useradd -ms /bin/bash user && usermod -aG wheel user && sed -i '/NOPASSWD/s/^#//g' /etc/sudoers # setup passwordless sudo
|
||||
RUN mkdir /run/user/1000 && chown user:user /run/user/1000 # create empty /run/user/1000 dir for mounting sockets
|
||||
USER user
|
||||
WORKDIR /home/user
|
||||
COPY config/user/bashrc /home/user/.bashrc
|
||||
COPY config/user/profile /home/user/.bash_profile
|
||||
|
||||
# === setup neovim ===
|
||||
RUN git clone --depth 1 https://github.com/LazyVim/starter ~/.config/nvim
|
||||
COPY --chown=user:user config/nvim/plugins /home/user/.config/nvim/lua/plugins
|
||||
COPY --chown=user:user config/nvim/config /home/user/.config/nvim/lua/config
|
||||
COPY --chown=user:user config/nvim/lazyvim.json /home/user/.config/nvim/lazyvim.json
|
||||
RUN mkdir .config .local .cache # create empty user dirs
|
||||
COPY --chown=user:user config/bashrc .bashrc # copy config into container
|
||||
|
||||
# === setup container ===
|
||||
ENV TZ="Europe/Amsterdam"
|
||||
VOLUME /home/user/.local /home/user/.cache
|
||||
ENV TZ="Europe/Amsterdam" # set timezone inside container
|
||||
VOLUME /home/user
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
-- Configure custom keymaps.
|
||||
local keymap = vim.keymap.set
|
||||
local delkeymap = vim.keymap.del
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
-- Improved line start/end
|
||||
keymap({ "n", "v" }, "H", "^", opts)
|
||||
keymap({ "n", "v" }, "L", "$", opts)
|
||||
|
||||
-- Improved escape
|
||||
keymap("n", "<ESC>", "<ESC>:noh<CR>", opts)
|
||||
keymap("t", "<ESC><ESC>", "<C-\\><C-n>", opts)
|
||||
|
||||
-- Disable alt j/k to move lines (conflict with default vim motions)
|
||||
delkeymap({ "i", "v" }, "<A-j>")
|
||||
delkeymap({ "i", "v" }, "<A-k>")
|
||||
@@ -1,43 +0,0 @@
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
|
||||
{ import = "plugins" },
|
||||
},
|
||||
defaults = {
|
||||
lazy = false,
|
||||
version = false,
|
||||
},
|
||||
install = {},
|
||||
checker = {
|
||||
enabled = true,
|
||||
notify = true,
|
||||
},
|
||||
performance = {
|
||||
rtp = {
|
||||
disabled_plugins = {
|
||||
"gzip",
|
||||
"netrwPlugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
"tutor",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -1,15 +0,0 @@
|
||||
-- Set some custom options.
|
||||
local opt = vim.o
|
||||
local global = vim.g
|
||||
|
||||
-- Set target text width for gww to 60.
|
||||
opt.tw = 60
|
||||
|
||||
-- Use the internal clipboard.
|
||||
opt.clipboard = ""
|
||||
|
||||
-- Use original gruvbox theme.
|
||||
global.gruvbox_material_foreground = "original"
|
||||
|
||||
-- Disable snack animations.
|
||||
global.snacks_animate = false
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"extras": [
|
||||
"lazyvim.plugins.extras.ai.copilot",
|
||||
"lazyvim.plugins.extras.dap.core",
|
||||
"lazyvim.plugins.extras.lang.go",
|
||||
"lazyvim.plugins.extras.lang.svelte",
|
||||
"lazyvim.plugins.extras.lang.tailwind",
|
||||
"lazyvim.plugins.extras.lang.typescript",
|
||||
"lazyvim.plugins.extras.test.core"
|
||||
],
|
||||
"version": 7
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
-- Configure rose-pine and gruvbox-material colorschemes.
|
||||
return {
|
||||
{ "rose-pine/neovim", name = "rose-pine" },
|
||||
{ "sainnhe/gruvbox-material" },
|
||||
{
|
||||
"LazyVim/LazyVim",
|
||||
opts = { colorscheme = "rose-pine-dawn" },
|
||||
},
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
-- Disable unused plugins and functionality.
|
||||
return {
|
||||
{
|
||||
-- Disable the dashboard.
|
||||
"folke/snacks.nvim",
|
||||
opts = {
|
||||
dashboard = { enabled = false },
|
||||
notifier = { level = vim.log.levels.WARN },
|
||||
},
|
||||
},
|
||||
{
|
||||
-- Disable inline hints by default.
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
inlay_hints = { enabled = false },
|
||||
},
|
||||
},
|
||||
|
||||
-- Disable unused plugins.
|
||||
{ "folke/flash.nvim", enabled = false },
|
||||
{ "folke/todo-comments.nvim", enabled = false },
|
||||
{ "folke/trouble.nvim", enabled = false },
|
||||
{ "MagicDuck/grug-far.nvim", enabled = false },
|
||||
{ "akinsho/bufferline.nvim", enabled = false },
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
. ~/.bashrc
|
||||
|
||||
# === persist copilot auth files inside .local volume ===
|
||||
if [ ! -d ~/.config/github-copilot ]; then
|
||||
mkdir -p ~/.local/share/github-copilot
|
||||
ln -s ~/.local/share/github-copilot ~/.config
|
||||
fi
|
||||
29
enter.sh
29
enter.sh
@@ -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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user