daemonix approach
This commit is contained in:
parent
8d362d13b2
commit
d4e84b0e41
7 changed files with 48 additions and 38 deletions
13
files/scripts/install-nix.sh
Executable file
13
files/scripts/install-nix.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
rpm_url="https://nix-community.github.io/nix-installers/nix/x86_64/nix-multi-user-2.24.10.rpm"
|
||||
|
||||
install -d /usr/share/nix-store /var/lib/nix-store /var/cache/nix-store /nix
|
||||
|
||||
dnf install -y "$rpm_url"
|
||||
|
||||
# Move the pre-populated store out of /nix so it can serve as the immutable lowerdir.
|
||||
if compgen -G "/nix/*" >/dev/null; then
|
||||
mv /nix/* /usr/share/nix-store/
|
||||
fi
|
||||
1
files/system/etc/modules-load.d/overlay.conf
Normal file
1
files/system/etc/modules-load.d/overlay.conf
Normal file
|
|
@ -0,0 +1 @@
|
|||
overlay
|
||||
13
files/system/usr/bin/mount-nix-overlay.sh
Executable file
13
files/system/usr/bin/mount-nix-overlay.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/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
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
image_ref="${NIX_TOOLBOX_IMAGE:-ghcr.io/thrix/nix-toolbox:42}"
|
||||
container_name="${NIX_TOOLBOX_CONTAINER:-nix-toolbox-42}"
|
||||
|
||||
if ! command -v toolbox >/dev/null 2>&1; then
|
||||
echo "toolbox not installed; skipping nix-toolbox setup" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v podman >/dev/null 2>&1; then
|
||||
echo "podman not installed; skipping nix-toolbox setup" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if podman container exists "$container_name"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Creating $container_name from $image_ref"
|
||||
distrobox create --name "$container_name" --image "$image_ref"
|
||||
14
files/system/usr/lib/systemd/system/nix-overlay.service
Normal file
14
files/system/usr/lib/systemd/system/nix-overlay.service
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Mount OverlayFS for /nix
|
||||
DefaultDependencies=no
|
||||
After=local-fs.target
|
||||
Before=nix-daemon.service
|
||||
ConditionPathExists=/usr/bin/mount-nix-overlay.sh
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/mount-nix-overlay.sh
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
[Unit]
|
||||
Description=Ensure nix-toolbox container is available for this user
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/nix-toolbox-ensure
|
||||
RemainAfterExit=yes
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
Loading…
Add table
Add a link
Reference in a new issue