deinonyxus/files/scripts/install-lix.sh

49 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2025-12-22 21:13:22 +02:00
#!/usr/bin/env bash
set -euo pipefail
2025-12-30 16:19:24 +02:00
# === INSTALL LIX FROM RPM ===
2025-12-30 11:08:13 +02:00
rpm_url="https://nix-community.github.io/nix-installers/lix/x86_64/lix-multi-user-2.91.1.rpm"
2025-12-22 21:13:22 +02:00
2026-01-14 18:19:46 +02:00
install -d /usr/share/nix-store /var/lib/nix-store /nix /etc/nix
2025-12-22 21:13:22 +02:00
2025-12-22 21:56:28 +02:00
# Avoid systemd calls during RPM %post in the image build environment.
export SYSTEMD_OFFLINE=1
# Install the RPM; allow missing GPG key since we fetch directly by URL.
dnf install -y --nogpgcheck "$rpm_url"
2025-12-22 21:13:22 +02:00
2025-12-30 16:19:24 +02:00
# === ADD MISSING LIX CACHE ACCESS PUBKEY ===
2025-12-30 12:56:58 +02:00
nix_conf=/etc/nix/nix.conf
lix_cache_url="https://cache.lix.systems/"
lix_cache_key="cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="
ensure_list_value() {
local key="$1" value="$2" escaped_value
escaped_value=$(printf '%s' "$value" | sed 's/[\\&]/\\&/g')
touch "$nix_conf"
if grep -Eq "^${key}[[:space:]]*=.*${escaped_value}" "$nix_conf"; then
return
fi
if grep -Eq "^${key}[[:space:]]*=" "$nix_conf"; then
sed -i "s|^${key}[[:space:]]*= *\\(.*\\)|${key} = \\1 ${escaped_value}|" "$nix_conf"
else
echo "${key} = ${value}" >>"$nix_conf"
fi
}
ensure_list_value "substituters" "$lix_cache_url"
ensure_list_value "trusted-public-keys" "$lix_cache_key"
2026-01-14 18:19:46 +02:00
# === SEED STORE FOR FIRST BOOT (copied into /var on boot) ===
2025-12-30 12:56:58 +02:00
2025-12-22 21:13:22 +02:00
if compgen -G "/nix/*" >/dev/null; then
2026-01-14 18:19:46 +02:00
rsync -aH --delete /nix/ /usr/share/nix-store/
rm -rf /nix/*
2025-12-22 21:13:22 +02:00
fi