diff --git a/README.md b/README.md index c1b0fdf..3299ba9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ *Deinonyxus* is a personal spin of the UBlue Bluefin DX image with the 🍦[Lix](https://lix.systems/) flavored Nix package manager baked in and a first-login bootstrap for simple declarative package management using [curator](https://codeberg.org/randogoth/curator). -The overlay mount approach was directly borrowed from the [Daemonix](https://github.com/DXC-0/daemonix/) Silverblue/Nix image. +The Nix store is seeded into `/usr/share/nix-store` in the image and bind-mounted from `/var/lib/nix-store` to `/nix` on boot to avoid overlay stacking limits on composefs/ostree. ## What’s inside - Base: `ghcr.io/ublue-os/bluefin-dx:latest` without Cockpit, Docker, Firefox, VS Code diff --git a/files/scripts/install-lix.sh b/files/scripts/install-lix.sh index 59ba7dc..08d3cba 100755 --- a/files/scripts/install-lix.sh +++ b/files/scripts/install-lix.sh @@ -5,7 +5,7 @@ set -euo pipefail rpm_url="https://nix-community.github.io/nix-installers/lix/x86_64/lix-multi-user-2.91.1.rpm" -install -d /usr/share/nix-store /var/lib/nix-store /var/cache/nix-store /nix /etc/nix +install -d /usr/share/nix-store /var/lib/nix-store /nix /etc/nix # Avoid systemd calls during RPM %post in the image build environment. export SYSTEMD_OFFLINE=1 @@ -40,8 +40,9 @@ ensure_list_value() { ensure_list_value "substituters" "$lix_cache_url" ensure_list_value "trusted-public-keys" "$lix_cache_key" -# === MOVE INITIAL NIX STORE TO LOWERDIR === +# === SEED STORE FOR FIRST BOOT (copied into /var on boot) === if compgen -G "/nix/*" >/dev/null; then - mv /nix/* /usr/share/nix-store/ + rsync -aH --delete /nix/ /usr/share/nix-store/ + rm -rf /nix/* fi diff --git a/files/system/etc/modules-load.d/overlay.conf b/files/system/etc/modules-load.d/overlay.conf deleted file mode 100644 index 08047cf..0000000 --- a/files/system/etc/modules-load.d/overlay.conf +++ /dev/null @@ -1 +0,0 @@ -overlay diff --git a/files/system/usr/bin/mount-nix-overlay.sh b/files/system/usr/bin/mount-nix-overlay.sh deleted file mode 100755 index 22ad012..0000000 --- a/files/system/usr/bin/mount-nix-overlay.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -mkdir -p /usr/share/nix-store /var/lib/nix-store /var/cache/nix-store /nix - -# Skip if already mounted to avoid errors on reload. -if mountpoint -q /nix; then - exit 0 -fi - -mount -t overlay overlay \ - -o lowerdir=/usr/share/nix-store,upperdir=/var/lib/nix-store,workdir=/var/cache/nix-store \ - /nix diff --git a/files/system/usr/bin/mount-nix.sh b/files/system/usr/bin/mount-nix.sh new file mode 100755 index 0000000..5e45edf --- /dev/null +++ b/files/system/usr/bin/mount-nix.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Bind-mount /var/lib/nix-store to /nix. +# If /var/lib/nix-store is empty, seed it from the baked store in /usr/share/nix-store. + +mkdir -p /usr/share/nix-store /var/lib/nix-store /nix + +copy_seed_store() { + if command -v rsync >/dev/null 2>&1; then + rsync -aH --delete /usr/share/nix-store/ /var/lib/nix-store/ + else + cp -a /usr/share/nix-store/. /var/lib/nix-store/ + fi +} + +if ! mountpoint -q /nix; then + if [ -z "$(ls -A /var/lib/nix-store 2>/dev/null)" ] && compgen -G "/usr/share/nix-store/*" >/dev/null; then + copy_seed_store + fi + + mount --bind /var/lib/nix-store /nix + mount -o remount,bind,exec /nix + + # Ensure daemon paths exist and labels are sane. + if command -v systemd-tmpfiles >/dev/null 2>&1; then + systemd-tmpfiles --create /usr/lib/tmpfiles.d/nix-daemon.conf + fi + if command -v restorecon >/dev/null 2>&1; then + restorecon -RF /var/lib/nix-store /nix || true + fi +fi diff --git a/files/system/usr/lib/systemd/system/nix-overlay.service b/files/system/usr/lib/systemd/system/nix-overlay.service index fca9a70..e0b8c8e 100644 --- a/files/system/usr/lib/systemd/system/nix-overlay.service +++ b/files/system/usr/lib/systemd/system/nix-overlay.service @@ -1,14 +1,14 @@ [Unit] -Description=Mount OverlayFS for /nix +Description=Bind-mount /var/lib/nix-store to /nix DefaultDependencies=no After=local-fs.target -Before=systemd-tmpfiles-setup.service nix-daemon.service nix-daemon.socket -ConditionPathExists=/usr/bin/mount-nix-overlay.sh +RequiresMountsFor=/var /var/lib/nix-store +Before=nix-daemon.service nix-daemon.socket +ConditionPathExists=/usr/bin/mount-nix.sh [Service] Type=oneshot -ExecStart=/usr/bin/mount-nix-overlay.sh -ExecStartPost=/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nix-daemon.conf +ExecStart=/usr/bin/mount-nix.sh RemainAfterExit=yes [Install] diff --git a/recipes/recipe.yml b/recipes/recipe.yml index af25d09..258e836 100644 --- a/recipes/recipe.yml +++ b/recipes/recipe.yml @@ -35,23 +35,16 @@ modules: files: add: - https://repo.vscodium.dev/vscodium.repo - - https://openrazer.github.io/hardware:razer.repo install: packages: - repo: vscodium packages: - codium - - dkms - - openrazer-daemon - - openrazer-kernel-modules-dkms - syncthing - uv - waydroid - - xautomation remove: packages: - - kmod-openrazer - - openrazer-kmod-common - android-tools - cockpit-bridge - cockpit-machines @@ -78,9 +71,8 @@ modules: scope: system # If no repo information is specified, Flathub will be used by default install: # system flatpaks we want all users to have and not remove - - app.zen_browser.zen + - net.waterfox.waterfox - org.telegram.desktop - - app.polychromatic.controller remove: # replace default Firefox with Waterfox - org.mozilla.firefox - scope: user # Also add Flathub user repo, but no user packages