# --- Localization (British English) ---
d-i debian-installer/locale string en_GB.UTF-8
d-i debian-installer/language string en
d-i debian-installer/country string GB

# --- Keyboard (UK Layout) ---
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/xkb-keymap select gb

# --- Timezone (London) ---
d-i time/zone string Europe/London
d-i clock-setup/utc boolean true

# --- Network Configuration ---
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string debian-auto
d-i netcfg/get_domain string unassigned-domain
d-i hw-detect/load_firmware boolean true

# --- Mirror Settings ---
d-i mirror/country string manual
d-i mirror/http/hostname string deb.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string

# --- Account Setup ---
# Root password (set to something temporary or "root")
d-i passwd/root-login boolean true
d-i passwd/root-password password root
d-i passwd/root-password-again password root

# User account
d-i passwd/user-fullname string Debian User
d-i passwd/username string hex
d-i passwd/user-password password password
d-i passwd/user-password-again password password

# --- Partitioning (Warning: Erases first disk!) ---
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select atomic
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

# --- Package Selection ---
tasksel tasksel/first multiselect standard
d-i pkgsel/include string openssh-server wireguard wireguard-tools curl wget
d-i pkgsel/upgrade select full-upgrade

# --- Bootloader ---
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev string default

# --- The "Late Command" (Post-Install Customization) ---
d-i preseed/late_command string \
    in-target mkdir -p /home/hex/.ssh; \
    in-target wget -O /home/hex/.ssh/authorized_keys https://hexn.live/ssh.txt; \
    in-target chown -R hex:hex /home/hex/.ssh; \
    in-target chmod 700 /home/hex/.ssh; \
    in-target chmod 600 /home/hex/.ssh/authorized_keys; \
    in-target systemctl enable ssh; \
    in-target /bin/sh -c "echo 'AllowUsers hex' >> /etc/ssh/sshd_config"
    mkdir -p /target/etc/wireguard; \
    cp /cdrom/custom/wg0.conf /target/etc/wireguard/wg0.conf; \
    in-target chmod 600 /etc/wireguard/wg0.conf; \
    in-target systemctl enable wg-quick@wg0; \

# --- Finished ---
d-i finish-install/reboot_directly boolean true
