feat: full rewrite in modules

This commit is contained in:
ange 2024-05-24 20:46:28 +02:00
parent 33725b0188
commit 5cc6a0dd08
Signed by: ange
GPG key ID: 9E0C4157BB7BEB1D
31 changed files with 283 additions and 215 deletions

View file

@ -0,0 +1,32 @@
#!/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 "$disk_passwd" | cryptsetup luksFormat "$root" -
echo "$disk_passwd" | cryptsetup open "$root" cryptroot -
root=/dev/mapper/cryptroot
}
mkfs.vfat -F32 "$boot"
mkfs.ext4 "$root"
mount "$root" /mnt/
mount -mo 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

@ -0,0 +1,15 @@
#!/bin/bash
#shellcheck disable=SC2154
case "$(lscpu)" in
*AMD*) pkg+=(amd-ucode) ;;
*Intel*) pkg+=(intel-ucode) ;;
*) ;;
esac
[ -n "$flatpak" ] && pkg+=(flatpak xdg-desktop-portal-gtk)
[ -f /sys/class/power_supply/BAT0 ] && pkg+=(tlp)
pacstrap -C rootfs/etc/pacman.conf -K /mnt/ \
base linux{,-lts,-firmware} "$shell" "${pkg[@]}"

View file

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

View file

@ -0,0 +1,14 @@
#!/bin/bash
#shellcheck disable=SC2154
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

View file

@ -0,0 +1,20 @@
#!/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

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

View file

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

View file

@ -0,0 +1,4 @@
#!/bin/bash
#shellcheck disable=SC2154
[ -n "$flatpak" ] && flatpak install -y "${flatpak[@]}"

View file

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

View file

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

14
modules/base.sh Normal file
View file

@ -0,0 +1,14 @@
#!/bin/bash
#shellcheck disable=SC2154
for i in modules/00-prechroot/*.sh; do
bash -x "$i"
done
for i in modules/10-chroot/*.sh; do
arch-chroot /mnt/ bash -x "$i"
done
for i in modules/20-user/*.sh; do
arch-chroot /mnt/ sudo -u "$username" bash -x "$i"
done

45
modules/desktop.sh Normal file
View file

@ -0,0 +1,45 @@
#!/bin/bash
#shellcheck disable=SC2154
pkg+=(
aerc w3m
bluez{,-utils}
dunst libnotify
feh
gammastep
graphicsmagick ghostscript
gvfs{,-gphoto2,-mtp}
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
)
case "$(lspci | grep 'VGA\|3D')" in
*AMD*) pkg+=(vulkan-radeon) ;;
*Intel*) pkg+=(vulkan-intel) ;;
*NVIDIA*) pkg+=(vulkan-nouveau) ;;
*) ;;
esac
./modules/base.sh
xdg-user-dirs-update

28
modules/dwm.sh Normal file
View file

@ -0,0 +1,28 @@
#!/bin/bash
#shellcheck disable=SC2154
pkg+=(
autorandr
i3lock xss-lock
picom
xorg-{server,xinit,xrandr,xsetroot} xclip xdotool
)
case "$(lsmod)" in
*amdgpu*) pkg+=(xf86-video-amdgpu) ;;
*i915*)
# https://wiki.archlinux.org/title/Intel_graphics#Installation
#pkg+=(xf86-video-intel)
;;
*nouveau*)
# https://bugs.freedesktop.org/show_bug.cgi?id=94844#c3
#pkg+=(xf86-video-nouveau)
;;
*)
;;
esac
./modules/desktop.sh
git clone --depth 1 https://git.maby.dev/ange/.dotfiles.git dotfiles
arch-chroot ./dotfiles/.config/suckless/update.sh