@@ -3,14 +3,42 @@ set -euo pipefail
33
44rpm_url=" https://nix-community.github.io/nix-installers/lix/x86_64/lix-multi-user-2.91.1.rpm"
55
6- install -d /usr/share/nix-store /var/lib/nix-store /var/cache/nix-store /nix
6+ install -d /usr/share/nix-store /var/lib/nix-store /var/cache/nix-store /nix /etc/nix
77
88# Avoid systemd calls during RPM %post in the image build environment.
99export SYSTEMD_OFFLINE=1
1010
1111# Install the RPM; allow missing GPG key since we fetch directly by URL.
1212dnf install -y --nogpgcheck " $rpm_url "
1313
14+ nix_conf=/etc/nix/nix.conf
15+ lix_cache_url=" https://cache.lix.systems/"
16+ lix_cache_key=" cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="
17+
18+ ensure_list_value () {
19+ local key=" $1 " value=" $2 " escaped_value
20+ escaped_value=$( printf ' %s' " $value " | sed ' s/[\\&]/\\&/g' )
21+
22+ touch " $nix_conf "
23+
24+ if grep -Eq " ^${key} [[:space:]]*=.*${escaped_value} " " $nix_conf " ; then
25+ return
26+ fi
27+
28+ if grep -Eq " ^${key} [[:space:]]*=" " $nix_conf " ; then
29+ sed -i " s|^${key} [[:space:]]*= *\\ (.*\\ )|${key} = \\ 1 ${escaped_value} |" " $nix_conf "
30+ else
31+ echo " ${key} = ${value} " >> " $nix_conf "
32+ fi
33+ }
34+
35+ ensure_list_value " substituters" " $lix_cache_url "
36+ ensure_list_value " trusted-public-keys" " $lix_cache_key "
37+
38+ # # Ensure the overlay mount service is enabled so /nix is populated on boot.
39+ # mkdir -p /etc/systemd/system/multi-user.target.wants
40+ # ln -sf /usr/lib/systemd/system/nix-overlay.service /etc/systemd/system/multi-user.target.wants/nix-overlay.service
41+
1442# Move the pre-populated store out of /nix so it can serve as the immutable lowerdir.
1543if compgen -G " /nix/*" > /dev/null; then
1644 mv /nix/* /usr/share/nix-store/
0 commit comments