#!/usr/bin/env sh

set -ex

_fail() {
    echo "$@" >&2
    exit 1
}

# Enable sudo + wheel
pacman -S --noconfirm sudo zsh

# Super awkward replace first incantation to enable all:all w/o nopasswd
sed -i '0,/^# %wheel/s//%wheel/' /etc/sudoers || _fail "Could not enable %wheel to sudo"

# Provision the 'arrdem' user
groupadd -r -g 1000001 arrdem
useradd -m -u 1000001 -g 1000001 -s /usr/bin/zsh -G wheel arrdem
chpasswd -e <<'EOF'
arrdem:$6$XCORPTp5G0NEyh6g$UkrlrRi4SnILWwWObEO9rxeJvgn95SbCAuxxN.ZElZDk6vDEdRwK60AWCTtineASNb9a578s7KOzHmM39Oxdf/
EOF
