From b2ead3cf15fa3554a4d042c4470cb136b535337c Mon Sep 17 00:00:00 2001 From: lstmnemodel Date: Thu, 21 May 2026 18:42:57 +0300 Subject: [PATCH] v1 --- nnm/Containerfile | 13 +++++++++++ nnm/config/kitty/kitty.conf | 43 +++++++++++++++++++++++++++++++++++ nnm/config/nvim/init.lua | 2 ++ nnm/config/zsh/.zshrc | 1 + nnm/install.sh | 45 +++++++++++++++++++++++++++++++++++++ nnm/manifest.toml | 2 ++ nnm/nnm | 37 ++++++++++++++++++++++++++++++ nnm/packages.list | 8 +++++++ nnm/pacman.conf | 11 +++++++++ nnm/uninstall.sh | 17 ++++++++++++++ 10 files changed, 179 insertions(+) create mode 100644 nnm/Containerfile create mode 100644 nnm/config/kitty/kitty.conf create mode 100644 nnm/config/nvim/init.lua create mode 100644 nnm/config/zsh/.zshrc create mode 100755 nnm/install.sh create mode 100644 nnm/manifest.toml create mode 100755 nnm/nnm create mode 100644 nnm/packages.list create mode 100644 nnm/pacman.conf create mode 100755 nnm/uninstall.sh diff --git a/nnm/Containerfile b/nnm/Containerfile new file mode 100644 index 0000000..107cd3f --- /dev/null +++ b/nnm/Containerfile @@ -0,0 +1,13 @@ +ARG BASE_IMAGE_DIGEST +FROM archlinux@${BASE_IMAGE_DIGEST} + +ARG ALA_DATE + +COPY pacman.conf /etc/pacman.conf +COPY packages.list /tmp/packages.list +COPY config/ /usr/share/nnm/config/ + +RUN sed "s|\$ala_date|$ALA_DATE|g" -i /etc/pacman.conf && \ + pacman -Syu --noconfirm && \ + pacman -S --noconfirm $(grep -v '^#' /tmp/packages.list | grep -v '^$') && \ + rm -f /tmp/packages.list diff --git a/nnm/config/kitty/kitty.conf b/nnm/config/kitty/kitty.conf new file mode 100644 index 0000000..73d1539 --- /dev/null +++ b/nnm/config/kitty/kitty.conf @@ -0,0 +1,43 @@ +font_family JetBrainsMono Nerd Font +font_size 13.0 +disable_ligatures never +cursor_shape beam +cursor_blink_interval 0.5 +window_padding_width 6 +hide_window_decorations no +background_opacity 0.97 + +foreground #c0caf5 +background #1a1b26 +selection_foreground #1a1b26 +selection_background #c0caf5 +color0 #15161e +color1 #f7768e +color2 #9ece6a +color3 #e0af68 +color4 #7aa2f7 +color5 #bb9af7 +color6 #7dcfff +color7 #a9b1d6 +color8 #414868 +color9 #f7768e +color10 #9ece6a +color11 #e0af68 +color12 #7aa2f7 +color13 #bb9af7 +color14 #7dcfff +color15 #c0caf5 + +map ctrl+grave send_text all \x1b[96;5u + +tab_bar_style powerline +tab_powerline_style slanted +map ctrl+shift+t new_tab_with_cwd + +enabled_layouts splits,stack +map ctrl+shift+\ launch --location=vsplit --cwd=current +map ctrl+shift+- launch --location=hsplit --cwd=current + +scrollback_pager nvim --noplugin -R -c "set nonumber norelativenumber" - + +map ctrl+shift+enter launch --cwd=current --type=window nvim diff --git a/nnm/config/nvim/init.lua b/nnm/config/nvim/init.lua new file mode 100644 index 0000000..080c0a6 --- /dev/null +++ b/nnm/config/nvim/init.lua @@ -0,0 +1,2 @@ +vim.opt.number = true +vim.notify("nnm nvim (stub config)") diff --git a/nnm/config/zsh/.zshrc b/nnm/config/zsh/.zshrc new file mode 100644 index 0000000..b2fcddf --- /dev/null +++ b/nnm/config/zsh/.zshrc @@ -0,0 +1 @@ +PROMPT='%F{green}nnm%f %F{blue}%~%f %# ' diff --git a/nnm/install.sh b/nnm/install.sh new file mode 100755 index 0000000..b1bb627 --- /dev/null +++ b/nnm/install.sh @@ -0,0 +1,45 @@ +#!/bin/bash +set -euo pipefail + +command -v podman >/dev/null 2>&1 || { echo "Error: podman not found"; exit 1; } +command -v distrobox >/dev/null 2>&1 || { echo "Error: distrobox not found"; exit 1; } + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +CONTAINER="nnm" + +ALA_DATE="$(grep '^ala_date' "$SCRIPT_DIR/manifest.toml" | sed 's/.*"\(.*\)"/\1/')" +BASE_DIGEST="$(grep '^base_image_digest' "$SCRIPT_DIR/manifest.toml" | sed 's/.*"\(.*\)"/\1/')" + +TAG_INPUT="$(cat "$SCRIPT_DIR/packages.list" "$SCRIPT_DIR/manifest.toml")" +IMAGE_TAG="nnm:$(echo -n "$TAG_INPUT" | sha256sum | cut -c1-16)" +IMAGE="localhost/$IMAGE_TAG" + +if ! podman image exists "$IMAGE"; then + echo "==> Building image..." + podman build \ + --build-arg "ALA_DATE=$ALA_DATE" \ + --build-arg "BASE_IMAGE_DIGEST=$BASE_DIGEST" \ + -t "$IMAGE" -f "$SCRIPT_DIR/Containerfile" "$SCRIPT_DIR" +fi + +echo "==> Copying configs to ~/.config/nvimnemodel/..." +mkdir -p ~/.config/nvimnemodel +cp -r "$SCRIPT_DIR/config/"* ~/.config/nvimnemodel/ + +if ! distrobox list 2>/dev/null | grep -qw "$CONTAINER"; then + echo "==> Creating distrobox container..." + NVIDIA_FLAG="" + [[ -d /dev/nvidia0 ]] && NVIDIA_FLAG="--nvidia" + distrobox create --name "$CONTAINER" --image "$IMAGE" $NVIDIA_FLAG +else + echo "==> Container '$CONTAINER' already exists." +fi + +echo "==> Installing /usr/local/bin/nnm..." +sudo cp "$SCRIPT_DIR/nnm" /usr/local/bin/nnm +sudo chmod +x /usr/local/bin/nnm + +echo "" +echo "==> nnm installed" +echo " Run 'nnm' to open a container terminal" +echo " Run 'nnm init' to create .envrc for direnv" diff --git a/nnm/manifest.toml b/nnm/manifest.toml new file mode 100644 index 0000000..31420d0 --- /dev/null +++ b/nnm/manifest.toml @@ -0,0 +1,2 @@ +ala_date = "2026/05/17" +base_image_digest = "sha256:445aaca11be510adf10b9ddcf30259d4ae4c8474530a8d5d71ca93199184ee70" diff --git a/nnm/nnm b/nnm/nnm new file mode 100755 index 0000000..2312274 --- /dev/null +++ b/nnm/nnm @@ -0,0 +1,37 @@ +#!/bin/bash +set -euo pipefail + +CONTAINER="nnm" +CONFIG_DIR="$HOME/.config/nvimnemodel" + +case "${1:-}" in + init) + DIR="${2:-$PWD}" + ENVRC="$DIR/.envrc" + if [[ -f "$ENVRC" ]]; then + echo ".envrc already exists at $ENVRC" + else + cat > "$ENVRC" <<-ENVEOF +if [ -z "\${NNM_ACTIVE:-}" ]; then + export NNM_ACTIVE=1 + distrobox-enter $CONTAINER +fi +ENVEOF + echo "Created $ENVRC — run 'direnv allow' to activate" + fi + ;; + -) + shift + exec distrobox-enter "$CONTAINER" -- "$@" + ;; + *) + distrobox-enter "$CONTAINER" -- \ + env XDG_CONFIG_HOME="$CONFIG_DIR" \ + ZDOTDIR="$CONFIG_DIR/zsh" \ + kitty --class="nnm" \ + --config "$CONFIG_DIR/kitty/kitty.conf" \ + --directory "$PWD" \ + zsh Removing container..." +distrobox rm --force nnm 2>/dev/null || true + +echo "==> Removing image..." +podman image rm localhost/nnm:* 2>/dev/null || true + +echo "==> Removing /usr/local/bin/nnm..." +sudo rm -f /usr/local/bin/nnm + +echo "==> nnm uninstalled."