From 092b2ba51cbc9285a56fade6bc2d2a1b96f3b1bf Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 19 Aug 2025 14:34:34 +0200 Subject: [PATCH] Address installation inside a chroot --- install.sh | 13 ++++++++++++- install/config/network.sh | 7 +------ install/config/power.sh | 2 +- install/desktop/bluetooth.sh | 2 +- install/desktop/printer.sh | 6 +++--- install/development/firewall.sh | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/install.sh b/install.sh index 92176459..660e6597 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,18 @@ export PATH="$HOME/.local/share/omarchy/bin:$PATH" OMARCHY_INSTALL=~/.local/share/omarchy/install # Chroot installations have some differences -export OMARCHY_CHROOT_INSTALL=$(! cmp -s /proc/1/root/ / && echo 1 || echo 0) +if ! cmp -s /proc/1/root/ / 2>/dev/null; then + export OMARCHY_CHROOT_INSTALL=1 +fi + +chrootable_systemctl_enable() { + local args=("$@") + if [ -n "${OMARCHY_CHROOT_INSTALL:-}" ]; then + sudo systemctl "${args[@]}" enable + else + sudo systemctl "${args[@]}" enable --now + fi +} # Give people a chance to retry running the installation catch_errors() { diff --git a/install/config/network.sh b/install/config/network.sh index ce726810..52722547 100644 --- a/install/config/network.sh +++ b/install/config/network.sh @@ -4,12 +4,7 @@ # This can happen if archinstall used ethernet if ! command -v iwctl &>/dev/null; then yay -S --noconfirm --needed iwd - - if [ -n "${OMARCHY_CHROOT_INSTALL:-}" ]; then - sudo systemctl enable iwd.service - else - sudo systemctl enable --now iwd.service - fi + chrootable_systemctl_enable iwd.service fi # Prevent systemd-networkd-wait-online timeout on boot diff --git a/install/config/power.sh b/install/config/power.sh index 3c3059d4..f473b69c 100644 --- a/install/config/power.sh +++ b/install/config/power.sh @@ -9,7 +9,7 @@ if ls /sys/class/power_supply/BAT* &>/dev/null; then powerprofilesctl set balanced || true # Enable battery monitoring timer for low battery notifications - systemctl --user enable --now omarchy-battery-monitor.timer || true + chrootable_systemctl_enable --user omarchy-battery-monitor.timer || true else # This computer runs on power outlet powerprofilesctl set performance || true diff --git a/install/desktop/bluetooth.sh b/install/desktop/bluetooth.sh index e7b5029c..f7c6282f 100644 --- a/install/desktop/bluetooth.sh +++ b/install/desktop/bluetooth.sh @@ -4,4 +4,4 @@ yay -S --noconfirm --needed blueberry # Turn on bluetooth by default -sudo systemctl enable --now bluetooth.service +chrootable_systemctl_enable bluetooth.service diff --git a/install/desktop/printer.sh b/install/desktop/printer.sh index ec379a82..664f96cd 100644 --- a/install/desktop/printer.sh +++ b/install/desktop/printer.sh @@ -1,16 +1,16 @@ #!/bin/bash sudo pacman -S --noconfirm cups cups-pdf cups-filters cups-browsed system-config-printer avahi nss-mdns -sudo systemctl enable --now cups.service +chrootable_systemctl_enable cups.service # Disable multicast dns in resolved. Avahi will provide this for better network printer discovery sudo mkdir -p /etc/systemd/resolved.conf.d echo -e "[Resolve]\nMulticastDNS=no" | sudo tee /etc/systemd/resolved.conf.d/10-disable-multicast.conf -sudo systemctl enable --now avahi-daemon.service +chrootable_systemctl_enable avahi-daemon.service # Enable automatically adding remote printers if ! grep -q '^CreateRemotePrinters Yes' /etc/cups/cups-browsed.conf; then echo 'CreateRemotePrinters Yes' | sudo tee -a /etc/cups/cups-browsed.conf fi -sudo systemctl enable --now cups-browsed.service +chrootable_systemctl_enable cups-browsed.service diff --git a/install/development/firewall.sh b/install/development/firewall.sh index 8e4d56bc..ee6dfee8 100644 --- a/install/development/firewall.sh +++ b/install/development/firewall.sh @@ -1,6 +1,6 @@ #!/bin/bash -if ! command -v ufw &>/dev/null; then +if ! command -v ufw &>/dev/null && -z "${OMARCHY_CHROOT_INSTALL:-}"; then yay -S --noconfirm --needed ufw ufw-docker # Allow nothing in, everything out