Compare commits

..

No commits in common. "main" and "v1" have entirely different histories.
main ... v1

34 changed files with 253 additions and 343 deletions

View File

@ -1,19 +1,31 @@
# archinstall
My personal Arch install script.
My personal Arch install script. It automates from step 2 of ArchWiki's
[Installation guide](https://wiki.archlinux.org/title/Installation_guide#Installation)
and more!
## HOW-TO
Install git, clone the script, edit the `config` file to match your preferences
and run the `install.sh` script.
Follow the [Pre-installation](https://wiki.archlinux.org/title/Installation_guide#Pre-installation).
Once you mounted the partitions, clone this script
```bash
pacman -Sy git
git clone https://git.maby.dev/ange/archinstall.git
cd archinstall
$EDITOR config
./install.sh
git clone https://git.maby.dev/ange/archinstall /tmp/ai && cd -- "$_"
```
## Extend
If you want to extend this script, simply place your own commands in a `.sh`
file in `modules/{prechroot,chroot,chroot/user}` respectively depending on when
you need it to be executed.
To install the base system, run:
```bash
$EDITOR config
./base.sh
```
If you want a desktop install:
```bash
$EDITOR ./desktop/config
./desktop/install.sh
$EDITOR ./desktop/$WM/config
./desktop/$WM/install.sh
```
For the dotfiles, run the script as the newly created user:
```bash
su - $user -c ./dotfiles.sh
```

30
config
View File

@ -2,44 +2,44 @@
# Comment to disable
# shellcheck disable=SC2034
install_type=dwm # base|desktop|dwm
disk=/dev/nvme0n1
disk_passwd=cryptroot
swapfile=1024 # MiB
#swapfile=2048
swapfile=auto # auto|MB
username=ange
userpasswd=ange
rootpasswd=root
user_passwd=ange
root_passwd=root
shell=bash
default_shell=/bin/zsh
hostname="$username-pc"
tz=Europe/Paris
locales=en_US # 'en_US,fr_FR'
lang=en_US
locales=(
en_US
)
lang="${locales[0]}"
pkg=(
base-devel man-{db,pages} tldr
bash-completion fzf
dosfstools exfatprogs
base{,-devel} man-{db,pages} tldr
efibootmgr
fastfetch
git
gvfs{,-gphoto2,-mtp} dosfstools exfatprogs
iwd iptables-nft wireguard-tools bind gnu-netcat
jq
lf
linux{,-lts,-firmware} mkinitcpio
neovim{,-lspconfig} python-{pynvim,black} ripgrep bash-language-server pyright
opendoas
openssh
p7zip unrar
podman docker-compose
podman docker-compose aardvark-dns
reflector
renameutils perl-rename
rsync
terminus-font awesome-terminal-fonts
tlp
zsh fzf
)
# vim: ft=sh

36
desktop/config Normal file
View File

@ -0,0 +1,36 @@
# User Variables
# Comment to disable
# shellcheck disable=SC2034
pkg=(
aerc w3m
bluez{,-utils}
dunst libnotify
feh
gammastep
graphicsmagick ghostscript
materia-gtk-theme papirus-icon-theme
monero
mpv
#newsraft
noto-fonts{,-cjk,-emoji} ttf-{dejavu,liberation} otf-font-awesome
pass{,-otp} gcr
pcmanfm-gtk3
pipewire{,-pulse,-jack} pavucontrol playerctl
polkit-gnome
qemu-{base,audio-pipewire,hw-usb-host,hw-display-virtio-{gpu,vga},ui-gtk} dnsmasq
xdg-user-dirs
yt-dlp
zathura{,-pdf-poppler}
zenity
)
flatpakpkg=(
com.valvesoftware.Steam org.freedesktop.Platform.VulkanLayer.gamescope
net.lutris.Lutris
org.gimp.GIMP
org.gtk.Gtk3theme.Materia-dark
org.mozilla.firefox
)
# vim: ft=sh

12
desktop/dwm/config Normal file
View File

@ -0,0 +1,12 @@
# User Variables
# Comment to disable
# shellcheck disable=SC2034
pkg=(
autorandr
i3lock xss-lock
picom
xorg-{server,xinit,xrandr,xsetroot} xclip xdotool
)
# vim: ft=sh

8
desktop/dwm/install.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
cd -- "$(dirname "$0")"
. ../../src/lib.sh
cp -rfTv rootfs/ /mnt/
cat config ../../src/lib.sh src/install.sh | arch-chroot /mnt/ bash
echo "${BOLD}${GREEN}DONE${NORMAL}"

View File

@ -0,0 +1,24 @@
#!/bin/bash
set -x
pac "${pkg[@]}"
case "$(lsmod)" in
*amdgpu*)
pac xf86-video-amdgpu
;;
*i915*)
# https://wiki.archlinux.org/title/Intel_graphics#Installation
#pac xf86-video-intel
;;
*nouveau*)
# https://bugs.freedesktop.org/show_bug.cgi?id=94844#c3
#pac xf86-video-nouveau
;;
*)
;;
esac
git clone --depth 1 https://git.maby.dev/ange/.dotfiles /tmp/dotfiles
/tmp/dotfiles/.config/suckless/update.sh

7
desktop/install.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
cd -- "$(dirname "$0")"
. ../src/lib.sh
cat config ../src/lib.sh src/install.sh | arch-chroot /mnt/ bash
echo "${BOLD}${GREEN}DONE${NORMAL}"

15
desktop/src/install.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -x
pac "${pkg[@]}" flatpak xdg-desktop-portal-gtk
flatpak install -y "${flatpakpkg[@]}"
case "$(lspci | grep 'VGA\|3D')" in
*AMD*) pac vulkan-radeon ;;
*Intel*) pac vulkan-intel ;;
*NVIDIA*) pac vulkan-nouveau ;;
*) ;;
esac
xdg-user-dirs-update

8
dotfiles.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
cd -- "$(dirname "$0")"
. ./config
. ./src/lib.sh
cat src/dotfiles.sh | arch-chroot /mnt/ su - "$username" -c 'bash'
echo "${BOLD}${GREEN}DONE.${NORMAL}"

View File

@ -1,11 +1,34 @@
#!/bin/bash
exec &> >(tee logs.out)
set -a
cd -- "$(dirname "$0")"
. ./config
set +a
. ./src/lib.sh
printf '%s\n' "${pkg[@]}" > pkglist.txt
set -x
(
case "$swapfile" in
[0-9]*)
size="$swapfile"
;;
auto)
ram="$(free -m | awk '/^Mem:/ {print $2}')"
size="$(python -c "from math import ceil,log; print(2**ceil((log($ram)/log(2))))")"
;;
*)
exit
;;
esac
bash ./modules/"$install_type".sh
dd if=/dev/zero of=/mnt/swapfile bs=1M count="$size" status=progress
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
swapon /mnt/swapfile
)
pacstrap -C rootfs/etc/pacman.conf -K /mnt/ --needed "${pkg[@]}"
cp -rfTv rootfs/ /mnt/
genfstab -U /mnt/ >> /mnt/etc/fstab
swapoff /mnt/swapfile
cat config src/lib.sh src/install.sh | arch-chroot /mnt/ bash
echo "${BOLD}${GREEN}DONE${NORMAL}"

View File

@ -1,22 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
for i in modules/prechroot/*.sh; do
bash -x "$i"
done
cp -r modules/chroot/ /mnt/
for i in modules/chroot/*.sh; do
arch-chroot /mnt bash -x "${i/modules/}"
done
for i in modules/chroot/user/*.sh; do
arch-chroot /mnt su - "$username" -c "bash -x '${i/modules/}'"
done
for i in modules/postchroot/*.sh; do
bash -x "$i"
done
rm -rf /mnt/chroot/

View File

@ -1,14 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime
hwclock --systohc
while read -r l; do
sed -i "/^#\s*$l.UTF-8/s/^#\s*//" /etc/locale.gen
done <<< "${locales//,/$'\n'}"
locale-gen
echo "LANG=$lang.UTF-8" > /etc/locale.conf
echo "$hostname" > /etc/hostname

View File

@ -1,20 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
bootctl install
root="$(findmnt -nr -o source /)"
cryptdev="$(cryptsetup status "$root" | awk '/device/ {print $2}')"
[ -n "$cryptdev" ] && {
uuid="$(blkid | grep "$cryptdev" | awk '{print $2}')"
options="cryptdevice=$uuid:$(basename "$root") "
}
options="${options}root=$root"
for f in /boot/loader/entries/*.conf; do
cat << EOF >> "$f"
options $options rw
EOF
done

View File

@ -1,8 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
shell="$(sed -n "/$shell/{p;q}" /etc/shells)"
useradd -mG wheel,video "$username" -s "${shell:-/bin/bash}"
echo "root:$rootpasswd" | chpasswd
echo "$username:$userpasswd" | chpasswd

View File

@ -1,10 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
systemctl enable iwd.service
systemctl enable nftables.service
systemctl enable reflector.timer
systemctl enable systemd-networkd.service
systemctl enable systemd-resolved.service
systemctl enable systemd-timesyncd.service
systemctl enable tlp.service

View File

@ -1,5 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
[ -s /chroot/flatpak.txt ] \
&& xargs flatpak install -y --noninteractive < /chroot/flatpak.txt

View File

@ -1,4 +0,0 @@
#!/bin/bash
git clone --depth 1 https://git.maby.dev/ange/.dotfiles.git /tmp/dotfiles
/tmp/dotfiles/.config/suckless/update.sh

View File

@ -1,4 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
systemctl enable --user podman.socket

View File

@ -1,44 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
#newsraft
printf '%s\n' \
aerc w3m \
alacritty \
bluez{,-utils} \
dunst libnotify \
feh \
gammastep \
graphicsmagick ghostscript \
gvfs{,-gphoto2,-mtp} \
materia-gtk-theme papirus-icon-theme \
monero \
mpv \
noto-fonts{,-cjk,-emoji} otf-font-awesome \
pass{,-otp} gcr \
pcmanfm-gtk3 \
pipewire{,-pulse,-jack} pavucontrol playerctl \
polkit-gnome \
qemu-{base,audio-pipewire,hw-usb-host,hw-display-virtio-{gpu,vga},ui-gtk} dnsmasq \
xdg-user-dirs \
yt-dlp \
zathura{,-pdf-poppler} \
zenity \
>> pkglist.txt
printf '%s\n' \
com.valvesoftware.Steam \
org.gimp.GIMP \
org.gtk.Gtk3theme.Materia-dark \
org.mozilla.firefox \
>> modules/chroot/flatpak.txt
case "$(lspci | grep 'VGA\|3D')" in
*AMD*) echo vulkan-radeon libva-mesa-driver mesa-vdpau >> pkglist.txt ;;
*Intel*) echo vulkan-intel intel-media-driver >> pkglist.txt ;;
*NVIDIA*) echo vulkan-nouveau libva-mesa-driver mesa-vdpau >> pkglist.txt ;;
*) ;;
esac
find ./modules/ -name '*.sh.desktop' -exec rename '.desktop' '' '{}' +
bash ./modules/base.sh

View File

@ -1,26 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
printf '%s\n' \
autorandr \
i3lock xss-lock \
picom \
xorg-{server,xinit,xrandr,xsetroot} xclip xdotool \
>> pkglist.txt
case "$(lsmod)" in
*amdgpu*) echo xf86-video-amdgpu >> pkglist.txt ;;
*i915*)
# https://wiki.archlinux.org/title/Intel_graphics#Installation
#echo xf86-video-intel >> pkglist.txt
;;
*nouveau*)
# https://bugs.freedesktop.org/show_bug.cgi?id=94844#c3
#echo xf86-video-nouveau >> pkglist.txt
;;
*)
;;
esac
find ./modules/ -name '*.sh.dwm' -exec rename '.dwm' '' '{}' +
bash ./modules/desktop.sh

View File

@ -1,14 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
BOLD=$'\e[1m'
GREEN=$'\e[32m'
NORMAL=$'\e[0m'
echo "${BOLD}${GREEN}DONE. Umount? [Y/n]${NORMAL} " && read -r ANS
case "$ANS" in
''|[Yy]*) ;;
*) exit ;;
esac
umount -R /mnt/

View File

@ -1,35 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
sgdisk -Z \
-n '0:0:+512M' -t '0:ef00' -c '0:boot' \
-n '0:0:0' -t '0:8300' -c '0:root' \
"$disk"
boot=/dev/disk/by-partlabel/boot
root=/dev/disk/by-partlabel/root
[ -n "$disk_passwd" ] && {
echo -n "$disk_passwd" | cryptsetup luksFormat "$root" -
cryptsetup open "$root" cryptroot - <<< "$disk_passwd"
root=/dev/mapper/cryptroot
}
sleep 2 # wait for /dev/disk/by-partlabel/ to be populated
mkfs.fat -F32 "$boot"
mkfs.ext4 -F "$root"
mount "$root" /mnt/
mount -m -o fmask=0077,dmask=0077 /dev/disk/by-partlabel/boot /mnt/boot/
[ -n "$swapfile" ] && {
dd if=/dev/zero of=/mnt/swapfile bs=1M count="$swapfile" status=progress
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
swapon /mnt/swapfile
}
cp -rfTv rootfs/ /mnt/
genfstab -U /mnt/ >> /mnt/etc/fstab
swapoff /mnt/swapfile

View File

@ -1,18 +0,0 @@
#!/bin/bash
#shellcheck disable=SC2154
case "$(lscpu)" in
*AMD*) echo amd-ucode >> pkglist.txt ;;
*Intel*) echo intel-ucode >> pkglist.txt ;;
*) ;;
esac
[ -s modules/chroot/flatpak.txt ] \
&& printf '%s\n' flatpak xdg-desktop-portal-gtk >> pkglist.txt
[ -d /sys/class/power_supply/BAT0 ] && echo tlp >> pkglist.txt
pacstrap -C rootfs/etc/pacman.conf -K /mnt \
base linux{,-lts,-firmware} "$shell" - < pkglist.txt
find /mnt/etc/ -name '*.pacnew' -delete

0
rootfs/boot/loader/entries/arch-lts.conf Normal file → Executable file
View File

0
rootfs/boot/loader/entries/arch.conf Normal file → Executable file
View File

0
rootfs/boot/loader/loader.conf Normal file → Executable file
View File

View File

@ -1,81 +0,0 @@
# vim:set ft=sh
# MODULES
# The following modules are loaded before any boot hooks are
# run. Advanced users may wish to specify all system modules
# in this array. For instance:
# MODULES=(usbhid xhci_hcd)
MODULES=()
# BINARIES
# This setting includes any additional binaries a given user may
# wish into the CPIO image. This is run last, so it may be used to
# override the actual binaries included by a given hook
# BINARIES are dependency parsed, so you may safely ignore libraries
BINARIES=()
# FILES
# This setting is similar to BINARIES above, however, files are added
# as-is and are not parsed in any way. This is useful for config files.
FILES=()
# HOOKS
# This is the most important setting in this file. The HOOKS control the
# modules and scripts added to the image, and what happens at boot time.
# Order is important, and it is recommended that you do not change the
# order in which HOOKS are added. Run 'mkinitcpio -H <hook name>' for
# help on a given hook.
# 'base' is _required_ unless you know precisely what you are doing.
# 'udev' is _required_ in order to automatically load modules
# 'filesystems' is _required_ unless you specify your fs modules in MODULES
# Examples:
## This setup specifies all modules in the MODULES setting above.
## No RAID, lvm2, or encrypted root is needed.
# HOOKS=(base)
#
## This setup will autodetect all modules for your system and should
## work as a sane default
# HOOKS=(base udev autodetect modconf block filesystems fsck)
#
## This setup will generate a 'full' image which supports most systems.
## No autodetection is done.
# HOOKS=(base udev modconf block filesystems fsck)
#
## This setup assembles a mdadm array with an encrypted root file system.
## Note: See 'mkinitcpio -H mdadm_udev' for more information on RAID devices.
# HOOKS=(base udev modconf keyboard keymap consolefont block mdadm_udev encrypt filesystems fsck)
#
## This setup loads an lvm2 volume group.
# HOOKS=(base udev modconf block lvm2 filesystems fsck)
#
## This will create a systemd based initramfs which loads an encrypted root filesystem.
# HOOKS=(base systemd autodetect modconf kms keyboard sd-vconsole sd-encrypt block filesystems fsck)
#
## NOTE: If you have /usr on a separate partition, you MUST include the
# usr and fsck hooks.
HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont block encrypt filesystems fsck)
# COMPRESSION
# Use this to compress the initramfs image. By default, zstd compression
# is used for Linux ≥ 5.9 and gzip compression is used for Linux < 5.9.
# Use 'cat' to create an uncompressed image.
#COMPRESSION="zstd"
#COMPRESSION="gzip"
#COMPRESSION="bzip2"
#COMPRESSION="lzma"
#COMPRESSION="xz"
#COMPRESSION="lzop"
#COMPRESSION="lz4"
# COMPRESSION_OPTIONS
# Additional options for the compressor
#COMPRESSION_OPTIONS=()
# MODULES_DECOMPRESS
# Decompress loadable kernel modules and their firmware during initramfs
# creation. Switch (yes/no).
# Enable to allow further decreasing image size when using high compression
# (e.g. xz -9e or zstd --long --ultra -22) at the expense of increased RAM usage
# at early boot.
# Note that any compressed files will be placed in the uncompressed early CPIO
# to avoid double compression.
#MODULES_DECOMPRESS="no"

View File

@ -1,8 +1,7 @@
#!/usr/bin/nft -f
# vim:set ts=2 sw=2 et:
flush ruleset
destroy table inet filter
table inet filter {
chain input {
type filter hook input priority filter; policy drop;

View File

@ -1,10 +1,13 @@
#!/bin/bash
#shellcheck disable=SC2154
cd
config=(git --git-dir "$HOME/.dotfiles" --work-tree "$HOME")
repo='https://git.maby.dev/ange/.dotfiles.git'
set -x
git clone --bare "$repo" "$HOME/.dotfiles"
"${config[@]}" checkout -f
"${config[@]}" submodule update --init --recursive --remote
"${config[@]}" config status.showUntrackedFiles no

57
src/install.sh Normal file
View File

@ -0,0 +1,57 @@
#!/bin/bash
set -x
# System config
ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime
hwclock --systohc
for l in "${locales[@]}"; do
sed -i "/^#\s*$l.UTF-8/s/^#\s*//" /etc/locale.gen
done
locale-gen
echo "LANG=$lang.UTF-8" > /etc/locale.conf
echo - "$hostname" > /etc/hostname
sed -i '/^HOOKS=(/s/filesystems/encrypt filesystems/' /etc/mkinitcpio.conf
# Services
systemctl enable \
iwd.service \
nftables.service \
reflector.timer \
systemd-networkd.service \
systemd-resolved.service \
systemd-timesyncd.service \
tlp.service
sudo -u "$username" systemctl enable podman.socket
# Users
echo "root:$root_passwd" | chpasswd
useradd -mG wheel,video "$username" -s "${default_shell-/bin/bash}"
echo - "$username:$user_passwd" | chpasswd
# ucode
case "$(lscpu)" in
*AMD*) pac amd-ucode ;;
*Intel*) pac intel-ucode ;;
*) ;;
esac
# Bootloader
bootctl install
root="$(findmnt -nr -o source /)"
cryptdev="$(cryptsetup status "$root" | awk '/device/{print $2}' || true)"
if [ -n "$cryptdev" ]; then
uuid="$(blkid | grep "$cryptdev" | awk '{print $2}')"
options="cryptdevice=$uuid:$(basename "$root") "
fi
options="${options}root=$root"
for f in /boot/loader/entries/*.conf; do
cat << EOF >> "$f"
options $options rw
EOF
done

11
src/lib.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ -t 1 ]; then
NORMAL=$'\e[0m'
BOLD=$'\e[1m'
GREEN=$'\e[32m'
fi
function pac() {
yes | pacman --needed -Syu "$@"
}