FROM archlinux:latest


#
# General boiler plate
#


# Add mock non-root user for AUR package compilation

RUN useradd --no-create-home --shell=/bin/false build && usermod -L build
RUN echo 'build ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
 
# Ready image for installation

RUN pacman-key --init
RUN pacman-key --populate archlinux
RUN pacman -Sy archlinux-keyring --noconfirm && pacman -Su --noconfirm
RUN pacman -Syu --noconfirm

# Install generic dependencies

RUN pacman -S git wget sudo base-devel --noconfirm


#
# Neovim specific
#


# Install nvim

RUN pacman -S neovim --noconfirm

# Install nvim module dependencies

RUN pacman -S python-pynvim --noconfirm               # python3 provider
RUN pacman -S npm --noconfirm                         # mason requirements
RUN pacman -S fd ripgrep --noconfirm                  # Telescope requirements
RUN pacman -S powerline-fonts --noconfirm             # vim-airline requirements
#RUN pacman -S autopep8 texlive-binextra \
#        perl-yaml-tiny perl-file-homedir --noconfirm  # neoformat requirements

WORKDIR /tmp

USER build
ARG HOME=/tmp
RUN wget https://aur.archlinux.org/cgit/aur.git/snapshot/neovim-remote.tar.gz
RUN tar xzvf neovim-remote.tar.gz
RUN cd neovim-remote && makepkg -s --noconfirm

USER root
RUN pacman -U neovim-remote/*.pkg.tar.zst --noconfirm  # vimtex requirements

WORKDIR /

# Copy configuration

RUN mkdir -p /root/.config/nvim
COPY . /root/.config/nvim

