From 2ac7aebcb0438350d47f03a9b5bd07e13399ef05 Mon Sep 17 00:00:00 2001 From: randogoth Date: Mon, 22 Dec 2025 20:43:26 +0200 Subject: [PATCH] added nix toolbox --- files/system/usr/bin/nix-toolbox-ensure | 22 +++++++++++++++++++ .../systemd/user/nix-toolbox-create.service | 14 ++++++++++++ recipes/recipe.yml | 5 +++++ 3 files changed, 41 insertions(+) create mode 100755 files/system/usr/bin/nix-toolbox-ensure create mode 100644 files/system/usr/lib/systemd/user/nix-toolbox-create.service diff --git a/files/system/usr/bin/nix-toolbox-ensure b/files/system/usr/bin/nix-toolbox-ensure new file mode 100755 index 0000000..82426c2 --- /dev/null +++ b/files/system/usr/bin/nix-toolbox-ensure @@ -0,0 +1,22 @@ +#!/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" +toolbox create --container "$container_name" --image "$image_ref" diff --git a/files/system/usr/lib/systemd/user/nix-toolbox-create.service b/files/system/usr/lib/systemd/user/nix-toolbox-create.service new file mode 100644 index 0000000..686483a --- /dev/null +++ b/files/system/usr/lib/systemd/user/nix-toolbox-create.service @@ -0,0 +1,14 @@ +[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 diff --git a/recipes/recipe.yml b/recipes/recipe.yml index 933a29d..6b26ee6 100644 --- a/recipes/recipe.yml +++ b/recipes/recipe.yml @@ -17,6 +17,11 @@ modules: - source: system destination: / # copies files/system/* (* means everything inside it) into your image's root folder / + - type: systemd + user: + enabled: + - nix-toolbox-create.service + - type: dnf install: packages: