# SPDX-FileCopyrightText: Stefan Tatschner
# SPDX-License-Identifier: MIT

FROM docker.io/debian:trixie

LABEL org.opencontainers.image.authors="stefan@rumpelsepp.org"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.title="Debian Devman"
LABEL org.opencontainers.image.base.name="docker.io/debian:trixie"

RUN apt-get update

# Cache as much as possible here.
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y devscripts
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y dh-make
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y xindy
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y atuin
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y apt-utils
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y bat
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y clang
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y clangd
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y catatonit
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y cmake
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y curl
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y desktop-file-utils
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y dialog
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y evince
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y fd-find
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y fish
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y fzf
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gh
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y git
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y git-delta
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y golang-go
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gopls
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y htop
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y iproute2
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y just
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libbpf-tools
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y kitty
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y locales
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y locales-all
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y meson
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y neovim
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y netcat-openbsd
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y npm
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y pipx
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3-poetry
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y ripgrep
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y rustup
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y pre-commit
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y pre-commit-hooks
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y screen
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y shellcheck
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y shfmt
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y socat
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y strace
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y sudo 
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tmux
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y valgrind
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gettext
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y wireshark

ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

RUN ln -s -f /usr/share/zoneinfo/Europe/Berlin /etc/localtime

RUN groupadd wheel
RUN useradd -m -G wheel dev
RUN echo '%wheel ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y

RUN git clone https://github.com/neovim/neovim
RUN git -C neovim checkout stable
RUN cd neovim && make CMAKE_BUILD_TYPE=RelWithDebInfo
RUN cd neovim && sudo make install
RUN rm -rf neovim

USER dev

ENV TERM=xterm-256color
ENV PATH=/home/dev/.local/bin:/home/dev/.local/npm-packages/bin:/home/dev/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

RUN pipx install ruff uv
RUN npm install --prefix /home/dev/.local/npm-packages -g bash-language-server
RUN rustup toolchain install stable

RUN cargo install texlab
