#!/bin/bash

ln -sf /usr/share/zoneinfo/Canada/Atlantic /etc/localtime
hwclock --systohc

sed -i 's/#en_CA/en_CA/g' /etc/locale.gen
sed -i 's/#fr_CA/fr_CA/g' /etc/locale.gen
sed -i 's/#en_US/en_US/g' /etc/locale.gen
locale-gen
echo "LANG=en_CA.UTF-8" >> /etc/locale.conf
echo "FONT=ter-228b" >> /etc/vconsole.conf
#echo "KEYMAP=cf" >> /etc/vconsole.conf # if you want French Canadian keyboard layout
echo "arch" >> /etc/hostname
echo "127.0.0.1 localhost" >> /etc/hosts
echo "::1       localhost" >> /etc/hosts
echo "127.0.1.1 arch.localdomain arch" >> /etc/hosts
echo root:password | chpasswd

# You can add xorg to the installation packages, I usually add it at the DE or WM install script
# You can remove the tlp (Linux Advanced Power Management) package if you are installing on a desktop or vm

pacman -S grub efibootmgr networkmanager network-manager-applet dialog wpa_supplicant mtools dosfstools base-devel linux-headers avahi xdg-user-dirs xdg-utils gvfs gvfs-smb nfs-utils inetutils dnsutils bluez bluez-utils cups hplip alsa-utils pulseaudio pavucontrol bash-completion openssh rsync reflector acpi acpi_call dnsmasq openbsd-netcat iptables-nft ipset flatpak sof-firmware nss-mdns acpid os-prober ntfs-3g terminus-font

# pacman -S --noconfirm xf86-video-amdgpu
# pacman -S --noconfirm nvidia nvidia-utils nvidia-settings

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ARCH
#change the directory to /boot/efi is you mounted the EFI partition at /boot/efi

grub-mkconfig -o /boot/grub/grub.cfg

sed -i 's/MODULES=()/MODULES=(overlay usbcore xhci-hcd nvme)/g' /etc/mkinitcpio.conf
sed -i 's/HOOKS.*/HOOKS=(base udev autodetect modconf block filesystems keyboard usr fsck shutdown)/g' /etc/mkinitcpio.conf

mkinitcpio -p linux

systemctl enable NetworkManager
systemctl enable bluetooth
#systemctl enable cups.service
systemctl enable sshd
systemctl enable avahi-daemon
#systemctl enable tlp # You can comment this command out if you didn't install tlp, see above
systemctl enable reflector.timer
systemctl enable fstrim.timer
#systemctl enable firewalld
systemctl enable acpid

useradd -m -g users eric
echo eric:password | chpasswd
usermod -aG wheel eric

echo "wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

printf "\e[1;32mDone! Type exit, umount -a and reboot.\e[0m"
