Archlinux setup - nutthawit/alpine-dotfile GitHub Wiki

Install cosmic

sudo pacman -S cosmic firefox power-profiles-daemon vi git git-lfs tree less tinyxxd weston bc packagekit btop bluez bluez-utils sof-firmware alsa-ucm-conf noto-fonts noto-fonts-cjk noto-fonts-emoji
sudo systemctl enable NetworkManager
  • tinyxxd for compare binary file
  • weston for run smithay/examples
  • packagekit need for cosmic-comp to install native package
  • sof-firmware and alsa-ucm-conf are sound card drivers
  • noto-fonts noto-fonts-cjk noto-fonts-emoji for test jp fonts with jp keyboard layout

Create machine startup snapshot with btrbk

Run the following commands as root sudo -s

  1. Install btrbk
pacman -S btrbk
  1. Create systemd service
cat << 'EOF' > /etc/systemd/system/create-machine-startup-snapshot.service
[Unit]
Description=Create Btrfs machine startup snapshots
DefaultDependencies=no
After=local-fs.target
Before=multi-user.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/create-machine-startup-snapshot
RemainAfterExit=no

[Install]
WantedBy=multi-user.target
EOF
systemctl enable create-machine-startup-snapshot
  1. Create a startup script
cat << 'EOF' > /usr/local/bin/create-machine-startup-snapshot 
#!/usr/bin/bash

set -eu

TARGET_DIR="${1:-/mnt/btr_pool/btrbk_snapshots}"

# Delete old machine start snapshots
find "$TARGET_DIR" -maxdepth 1 -name "*machine_start*" -type d -print -exec btrfs subvolume delete {} \;

# Create new snapshots
snap @ machine_start
snap @home machine_start
EOF
chmod +x /usr/local/bin/create-machine-startup-snapshot 
  1. Create the snap command (a wrapper script)
cat << 'EOF' > /usr/local/bin/snap 
#!/usr/bin/bash
#
# snap

show_example() {
        echo "Usage: $0 <subvol_name> <description>"
    echo "Example: $0 @ firefox_installed"
}

if [ $# -eq 0 ]; then
    show_example
        exit 1
fi

if [ "$(id -u)" -ne 0 ]; then
  echo "This script must be run with 'sudo' or as the 'root' user."
  exit 1
fi

subvol_name="$1"
description="$2"

if [ "$subvol_name" == "@" ]; then
        btrbk snapshot -c /etc/btrbk/[email protected] @ | rename-snapshot "$description"
elif [ "$subvol_name" == "@home" ]; then
        btrbk snapshot -c /etc/btrbk/[email protected] @home | rename-snapshot "$description"
else
        show_example
    exit 1
fi
EOF
chmod +x /usr/local/bin/snap
  1. Create the rename-snapshot command
cat << 'EOF' > /usr/local/bin/rename-snapshot
#!/usr/bin/bash
#
# rename-snapshot

# Check if description parameter is provided
if [ $# -eq 0 ]; then
    echo "Usage: $0 <description>"
    echo "Example: btrbk snapshot -c /etc/btrbk/[email protected] @ | $0 firefox_installed"
    exit 1
fi

description="$1"

# Read from stdin if piped, otherwise use first argument
if [ ! -t 0 ]; then
    # Reading from pipe
    input=$(cat)
fi

# Extract just the snapshot name (home.20251006T0809 or @.20251006T0809)
snapshot_name=$(echo "$input" | grep -oE '(@home|@)\.[0-9]{8}T[0-9]{4}')

if [ -z "$snapshot_name" ]; then
    echo "Error: Could not extract snapshot name from input"
    exit 1
fi

subvol="${snapshot_name%.*}"      # Everything before the last dot
timestamp="${snapshot_name#*.}"   # Everything after the first dot

# New name format with custom description
new_name=${subvol}.${description}.${timestamp}

# Rename the snapshot
mv "/mnt/btr_pool/btrbk_snapshots/$snapshot_name" "/mnt/btr_pool/btrbk_snapshots/$new_name"
echo "Renamed: $snapshot_name -> $new_name"
EOF
chmod +x /usr/local/bin/rename-snapshot
  1. Create btrfs configurations
cat << EOF > /etc/btrbk/[email protected]
timestamp_format long

snapshot_dir /mnt/btr_pool/btrbk_snapshots
subvolume /mnt/btr_pool/@

EOF

cat << EOF > /etc/btrbk/[email protected]
timestamp_format long

snapshot_dir /mnt/btr_pool/btrbk_snapshots
subvolume /mnt/btr_pool/@home

EOF
  1. Mount root partition to /mnt/btr_pool and add entry to /etc/fstab
ROOT=/dev/nvme0n1p2
BTR_POOL=/mnt/btr_pool

echo "${ROOT} ${BTR_POOL} btrfs subvolid=5,noatime 0 0" | tee -a /etc/fstab
mkdir ${BTR_POOL}
mount -a
mount
  1. Create directory for store snapshots
mkdir /mnt/btr_pool/btrbk_snapshots

Then, restart a machine and snapshot will automatically create when the machine startup.

Enable tmux navigate inside vim sessions

  1. Install nvim-lua/kickstart
yay -S neovim-git lua luarocks wl-clipboard lazygit

# Clone my kickstart fork
git clone [email protected]:nutthawit/kickstart.nvim.git ~/.config/nvim
sed -i '/lazy-lock.json/d' ~/.config/nvim/.gitignore
  1. Install tmux
yay -S tmux stow
git clone https://github.com/tmux-plugins/tmux-resurrect ~/tmux-resurrect
stow -v tmux
  1. Add the following to your ~/.tmux.conf file:
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
vim_pattern='(\S+/)?g?\.?(view|l?n?vim?x?|fzf)(diff)?(-wrapped)?'
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +${vim_pattern}$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h'  'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j'  'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k'  'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l'  'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\'  'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\'  'select-pane -l'"

bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l

Then, restart Neovim and lazy.nvim will automatically install the plugin and configure the keybindings.

Setup home bash shell

yay -S extra/rustup
rustup default stable

# Change default cargo from gcc to llvm
yay -S extra/clang extra/lld
mkdir ~/.cargo
stow -v cargo

# Install ripgrep and fd those required by kickstart/nvim
yay -S extra/ripgrep extra/fd

# Install smart-cd and promp custom
yay -S zoxide-git extra/starship

# Install debugger backend of rust-lldb
yay -S extra/lldb

mv ~/.bashrc ~/.bashrc.old
mv ~/.bash_profile ~/.bash_profile.old
stow -v arch-sh
stow -v git

See also

Rust Other Installation Methods

Cargo Configuration Precedence

CPU Specific Instructions

Manage password with KeePassXC

sudo pacman -S keepassxc

Install Dropbox Headless

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

Make su

sudo -s

Create systemd service

cat << 'EOF' >> /etc/systemd/system/dropbox-headless.service
[Unit]
Description=Dropbox Headless

[Service]
ExecStart=/home/tie/.dropbox-dist/dropboxd
Restart=on-failure

[Install]
WantedBy=default.target
EOF
systemctl enable --now dropbox-headless.service

See also

https://github.com/christoomey/vim-tmux-navigator

https://wiki.archlinux.org/title/Linux_Containers#Setup

⚠️ **GitHub.com Fallback** ⚠️