From 2724a43e073f55116db244d620eb055954476438 Mon Sep 17 00:00:00 2001 From: AngeD Date: Tue, 14 Mar 2023 17:33:29 +0100 Subject: [PATCH] feat: new install script with dwm --- README.md | 30 ++++++ base_install.sh | 55 ++++++++++ config | 40 +++++++ dotfiles.sh | 19 ++++ dwm/config | 20 ++++ dwm/etc/X11/xorg.conf.d/00-keyboard.conf | 6 ++ dwm/etc/X11/xorg.conf.d/30-touchpad.conf | 8 ++ .../xorg.conf.d/50-mouse-acceleration.conf | 6 ++ dwm/etc/udev/rules.d/backlight.rules | 1 + dwm/install.sh | 34 ++++++ gpu.sh | 32 ++++++ nvidia.hook | 15 +++ rootfs/etc/pacman.conf | 101 ++++++++++++++++++ .../etc/pacman.d/hooks/95-systemd-boot.hook | 9 ++ 14 files changed, 376 insertions(+) create mode 100755 base_install.sh create mode 100644 config create mode 100755 dotfiles.sh create mode 100644 dwm/config create mode 100644 dwm/etc/X11/xorg.conf.d/00-keyboard.conf create mode 100644 dwm/etc/X11/xorg.conf.d/30-touchpad.conf create mode 100644 dwm/etc/X11/xorg.conf.d/50-mouse-acceleration.conf create mode 100644 dwm/etc/udev/rules.d/backlight.rules create mode 100755 dwm/install.sh create mode 100755 gpu.sh create mode 100644 nvidia.hook create mode 100644 rootfs/etc/pacman.conf create mode 100644 rootfs/etc/pacman.d/hooks/95-systemd-boot.hook diff --git a/README.md b/README.md index f4aa4e5..7a42f89 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,32 @@ # archinstall +My personal Arch install script. It automates from step 2 of ArchWiki's +[Installation guide](https://wiki.archlinux.org/title/Installation_guide) +and more! + +## How to + +Follow the [Pre-installation](https://wiki.archlinux.org/title/Installation_guide#Pre-installation). +Once you chrooted in the system, clone this script +```bash +git clone https://git.maby.dev/ange/archinstall.git /tmp/ai +cd /tmp/ai/ +``` + +**Review and edit the `config` file before running any script!** + +To install the base system, run: +```bash +./base_install.sh +``` + +If you want a post install script, login as a normal user and run (replace +*desktopEnvironment* with your choice): +```bash +./desktopEnvironment/install.sh +``` + +For the dotfiles, run the script as the new user: +```bash +su $user -c ./dotfiles.sh +``` diff --git a/base_install.sh b/base_install.sh new file mode 100755 index 0000000..6e83d54 --- /dev/null +++ b/base_install.sh @@ -0,0 +1,55 @@ +#!/bin/bash -e +cd "$(dirname "$0")" +. ./config + +NORMAL='\e[0m' +BOLD='\e[1m' +GREEN='\e[32m' + +PACMAN='pacman --needed -Syu' + +# System config +ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime +hwclock --systohc +timedatectl set-ntp true +for l in "${locales[@]}"; do + sed -i "/#\s*$l/s/^#\s*//" /etc/locale.gen # todo test +done +locale-gen +echo "LANG=$lang" > /etc/locale.conf +echo "$hostname" > /etc/hostname + +# Packages +cp -rf rootfs/ / +$PACMAN "${pkg[@]}" +systemctl enable NetworkManager +systemctl enable reflector.timer + +if [ -d /sys/module/battery/ ]; then + $PACMAN "${laptop_pkg[@]}" + systemctl enable tlp +fi + +# Users +echo "root:$root_passwd" | chpasswd +useradd -mG wheel "$username" +echo "$username:$user_passwd" | chpasswd + +sed -i '/%wheel\s\+ALL=(ALL)\s\+ALL/s/^#\s*//' /etc/sudoers + +# Bootloader +case "$(lscpu | grep Vendor)" in + *AuthenticAMD*) + $PACMAN amd-ucode + ;; + *GenuineIntel*) + $PACMAN intel-ucode + ;; +esac + +bootctl install +cp loader/ /boot/loader # TODO + +mkinitcpio -P + +echo -e "${BOLD}${GREEN}DONE. Ctrl+D, umount -R /mnt and reboot${NORMAL}" diff --git a/config b/config new file mode 100644 index 0000000..e62c5c1 --- /dev/null +++ b/config @@ -0,0 +1,40 @@ +# User Variables +# Comment to disable + +username=ange +user_passwd=ange +root_passwd=root + +hostname="$username-pc" + +tz='Europe/Paris' +locales=( + 'en_US.UTF-8' +) +lang="${locales[0]}" + +esp="$(lsblk -f | grep vfat | grep -o '/boot.\+')" + +pkg=( + base-devel + docker{,-compose} + efibootmgr + fuse + git + htop + man-{db,pages} + mpv + neofetch + neovim + networkmanager + ranger + reflector + terminus-font awesome-terminal-fonts + tree + udisks2 + zsh +) + +laptop_pkg=( + tlp +) diff --git a/dotfiles.sh b/dotfiles.sh new file mode 100755 index 0000000..b278135 --- /dev/null +++ b/dotfiles.sh @@ -0,0 +1,19 @@ +#!/bin/bash -e + +config="git --git-dir $HOME/.dotfiles --work-tree $HOME" +repo='https://git.maby.dev/ange/.dotfiles.git' + +if [ "$EUID" = 0 ]; then + echo 'You are currently logged in as root. Continue?' + read -r +fi + +git clone --bare "$repo" "$HOME/.dotfiles" + +while ! $config checkout; do + echo 'Please remove conflicted files and press enter:' + read -r +done + +$config submodule update --init --recursive --remote +$config config status.showUntrackedFiles no diff --git a/dwm/config b/dwm/config new file mode 100644 index 0000000..0d2f885 --- /dev/null +++ b/dwm/config @@ -0,0 +1,20 @@ +# User Variables +# Comment to disable + +pkg=( + alacritty + dunst + feh + firefox + flameshot + i3lock xss-lock + materia-{gtk-theme,kde} papirus-icon-theme gtk-engine-murrine + noto-fonts{,-cjk,-emoji} ttf-{dejavu,liberation} + numlockx + pcmanfm + picom + pipewire{,-pulse} wireplumber pavucontrol playerctl + polkit-gnome + redshift + xorg-{server,xinit,xrandr,xsetroot} xclip +) diff --git a/dwm/etc/X11/xorg.conf.d/00-keyboard.conf b/dwm/etc/X11/xorg.conf.d/00-keyboard.conf new file mode 100644 index 0000000..af02101 --- /dev/null +++ b/dwm/etc/X11/xorg.conf.d/00-keyboard.conf @@ -0,0 +1,6 @@ +Section "InputClass" + Identifier "keyboard" + MatchIsKeyboard "true" + Option "XkbLayout" "us" + Option "XkbVariant" "altgr-intl" +EndSection diff --git a/dwm/etc/X11/xorg.conf.d/30-touchpad.conf b/dwm/etc/X11/xorg.conf.d/30-touchpad.conf new file mode 100644 index 0000000..e985a84 --- /dev/null +++ b/dwm/etc/X11/xorg.conf.d/30-touchpad.conf @@ -0,0 +1,8 @@ +Section "InputClass" + Identifier "touchpad" + Driver "libinput" + MatchIsTouchpad "true" + Option "Tapping" "true" + Option "ClickMethod" "clickfinger" + Option "NaturalScrolling" "true" +EndSection diff --git a/dwm/etc/X11/xorg.conf.d/50-mouse-acceleration.conf b/dwm/etc/X11/xorg.conf.d/50-mouse-acceleration.conf new file mode 100644 index 0000000..ea67682 --- /dev/null +++ b/dwm/etc/X11/xorg.conf.d/50-mouse-acceleration.conf @@ -0,0 +1,6 @@ +Section "InputClass" + Identifier "mouse" + Driver "libinput" + MatchIsPointer "true" + Option "AccelProfile" "flat" +EndSection diff --git a/dwm/etc/udev/rules.d/backlight.rules b/dwm/etc/udev/rules.d/backlight.rules new file mode 100644 index 0000000..9742b07 --- /dev/null +++ b/dwm/etc/udev/rules.d/backlight.rules @@ -0,0 +1 @@ +ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chmod g+w $sys$devpath/brightness" diff --git a/dwm/install.sh b/dwm/install.sh new file mode 100755 index 0000000..6204468 --- /dev/null +++ b/dwm/install.sh @@ -0,0 +1,34 @@ +#!/bin/bash -e +cd "$(dirname "$0")" +. ./config + +NORMAL='\e[0m' +BOLD='\e[1m' +GREEN='\e[32m' + +PACMAN='pacman --needed -Syu' + +if [ "$EUID" = 0 ]; then + echo 'This script needs root privileges.' + exit 1 +fi + +# drivers +case "$(lspci -k | grep -A3 -E '(VGA|3D)')" in + *amdgpu*) + pkg=("${pkg[@]}" xf86-video-amdgpu) + ;; + *i915*) + pkg=("${pkg[@]}" xf86-video-intel) + ;; + *nouveau*) + pkg=("${pkg[@]}" xf86-video-nouveau) + ;; +esac +$PACMAN "${pkg[@]}" + +cp -rf etc /etc + +echo -e "${BOLD}${GREEN}DONE. You can reboot.${NORMAL}" + +# TODO install dwm diff --git a/gpu.sh b/gpu.sh new file mode 100755 index 0000000..ff8c23f --- /dev/null +++ b/gpu.sh @@ -0,0 +1,32 @@ +#!/bin/bash -e +cd "$(dirname "$0")" + +NORMAL='\e[0m' +BOLD='\e[1m' +GREEN='\e[32m' + +if [ "$EUID" = 0 ]; then + echo 'This script needs root privileges.' + exit 1 +fi + +case "$(lspci -k | grep -E '(VGA|3D)')" in + *NVIDIA*) + $PACMAN nvidia{,-utils,-settings} + mkdir -p /etc/pacman.d/hooks/ + cp nvidia.hook /etc/pacman.d/hooks/ + modules='nvidia nvidia_modeset nvidia_uvm nvidia_drm' + ;; + *AMD*) + $PACMAN mesa vulkan-radeon + modules=amdgpu + ;; + *Intel*) + $PACMAN mesa vulkan-intel + modules=i915 + ;; +esac + +sed -i "s/^MODULES=(/MODULES=($modules/" /etc/mkinitcpio.conf + +echo -e "${BOLD}${GREEN}DONE. You can reboot.${NORMAL}" diff --git a/nvidia.hook b/nvidia.hook new file mode 100644 index 0000000..620cfa8 --- /dev/null +++ b/nvidia.hook @@ -0,0 +1,15 @@ +[Trigger] +Operation=Install +Operation=Upgrade +Operation=Remove +Type=Package +Target=nvidia +Target=linux +# Change the linux part above and in the Exec line if a different kernel is used + +[Action] +Description=Update NVIDIA module in initcpio +Depends=mkinitcpio +When=PostTransaction +NeedsTargets +Exec=/bin/sh -c 'while read -r trg; do case $trg in linux) exit 0; esac; done; /usr/bin/mkinitcpio -P' diff --git a/rootfs/etc/pacman.conf b/rootfs/etc/pacman.conf new file mode 100644 index 0000000..025ca90 --- /dev/null +++ b/rootfs/etc/pacman.conf @@ -0,0 +1,101 @@ +# +# /etc/pacman.conf +# +# See the pacman.conf(5) manpage for option and repository directives + +# +# GENERAL OPTIONS +# +[options] +# The following paths are commented out with their default values listed. +# If you wish to use different paths, uncomment and update the paths. +#RootDir = / +#DBPath = /var/lib/pacman/ +#CacheDir = /var/cache/pacman/pkg/ +#LogFile = /var/log/pacman.log +#GPGDir = /etc/pacman.d/gnupg/ +#HookDir = /etc/pacman.d/hooks/ +HoldPkg = pacman glibc +#XferCommand = /usr/bin/curl -L -C - -f -o %o %u +#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u +#CleanMethod = KeepInstalled +Architecture = auto + +# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup +#IgnorePkg = +#IgnoreGroup = + +#NoUpgrade = +#NoExtract = + +# Misc options +#UseSyslog +Color +#NoProgressBar +CheckSpace +VerbosePkgLists +ParallelDownloads = 8 +ILoveCandy + +# By default, pacman accepts packages signed by keys that its local keyring +# trusts (see pacman-key and its man page), as well as unsigned packages. +SigLevel = Required DatabaseOptional +LocalFileSigLevel = Optional +#RemoteFileSigLevel = Required + +# NOTE: You must run `pacman-key --init` before first using pacman; the local +# keyring can then be populated with the keys of all official Arch Linux +# packagers with `pacman-key --populate archlinux`. + +# +# REPOSITORIES +# - can be defined here or included from another file +# - pacman will search repositories in the order defined here +# - local/custom mirrors can be added here or in separate files +# - repositories listed first will take precedence when packages +# have identical names, regardless of version number +# - URLs will have $repo replaced by the name of the current repo +# - URLs will have $arch replaced by the name of the architecture +# +# Repository entries are of the format: +# [repo-name] +# Server = ServerName +# Include = IncludePath +# +# The header [repo-name] is crucial - it must be present and +# uncommented to enable the repo. +# + +# The testing repositories are disabled by default. To enable, uncomment the +# repo name header and Include lines. You can add preferred servers immediately +# after the header, and they will be used before the default mirrors. + +#[testing] +#Include = /etc/pacman.d/mirrorlist + +[core] +Include = /etc/pacman.d/mirrorlist + +[extra] +Include = /etc/pacman.d/mirrorlist + +#[community-testing] +#Include = /etc/pacman.d/mirrorlist + +[community] +Include = /etc/pacman.d/mirrorlist + +# If you want to run 32 bit applications on your x86_64 system, +# enable the multilib repositories as required here. + +#[multilib-testing] +#Include = /etc/pacman.d/mirrorlist + +#[multilib] +#Include = /etc/pacman.d/mirrorlist + +# An example of a custom package repository. See the pacman manpage for +# tips on creating your own repositories. +#[custom] +#SigLevel = Optional TrustAll +#Server = file:///home/custompkgs diff --git a/rootfs/etc/pacman.d/hooks/95-systemd-boot.hook b/rootfs/etc/pacman.d/hooks/95-systemd-boot.hook new file mode 100644 index 0000000..d65c027 --- /dev/null +++ b/rootfs/etc/pacman.d/hooks/95-systemd-boot.hook @@ -0,0 +1,9 @@ +[Trigger] +Type = Package +Operation = Upgrade +Target = systemd + +[Action] +Description = Gracefully upgrading systemd-boot... +When = PostTransaction +Exec = /usr/bin/systemctl restart systemd-boot-update.service