Refactor pkgmgr installers, introduce capability-based execution, and replace manifest layer
References: - Current ChatGPT conversation: https://chatgpt.com/share/6935d6d7-0ae4-800f-988a-44a50c17ba48 - Extended discussion: https://chatgpt.com/share/6935d734-fd84-800f-9755-290902b8cee8 Summary: This commit performs a major cleanup and modernization of the installation pipeline: 1. Introduced a new capability-detection subsystem: - Capabilities (python-runtime, make-install, nix-flake) are detected per installer/layer. - Installers run only when they add new capabilities. - Prevents duplicated work such as Python installers running when Nix already provides the runtime. 2. Removed deprecated pkgmgr.yml manifest installer: - Dependency resolution is now delegated entirely to real package managers (Nix, pip, make, distro build tools). - Simplifies layering and avoids unnecessary recursion. 3. Reworked OS-specific installers: - Arch PKGBUILD now uses 'makepkg --syncdeps --cleanbuild --install --noconfirm'. - Debian installer now builds proper .deb packages via dpkg-buildpackage + installs them. - RPM installer now builds packages using rpmbuild and installs them via rpm. 4. Switched from remote GitHub flakes to local-flake execution: - Wrapper now executes: nix run /usr/lib/package-manager#pkgmgr - Avoids lock-file write attempts and improves reliability in CI. 5. Added bash -i based integration test: - Correctly sources ~/.bashrc and evaluates alias + venv activation. - ‘pkgmgr --help’ is now printed for debugging without failing tests. 6. Updated unit tests across all installers: - Removed references to manifest installer. - Adjusted expectations for new behaviors (makepkg, dpkg-buildpackage, rpmbuild). - Added capability subsystem tests. 7. Improved flake.nix packaging logic: - The entire project source tree is copied into the runtime closure. - pkgmgr wrapper now executes runpy inside the packaged directory. Together, these changes create a predictable, layered, capability-driven installer pipeline with consistent behavior across Arch, Debian, RPM, Nix, and Python layers.
This commit is contained in:
@@ -3,14 +3,14 @@ set -euo pipefail
|
||||
|
||||
echo ">>> Initializing Nix environment for package-manager..."
|
||||
|
||||
# 1. /nix Store
|
||||
# 1. /nix store
|
||||
if [ ! -d /nix ]; then
|
||||
echo ">>> Creating /nix store directory"
|
||||
mkdir -m 0755 /nix
|
||||
chown root:root /nix
|
||||
fi
|
||||
|
||||
# 2. nix-daemon aktivieren, falls vorhanden
|
||||
# 2. Enable nix-daemon if available
|
||||
if command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q nix-daemon.service; then
|
||||
echo ">>> Enabling nix-daemon.service"
|
||||
systemctl enable --now nix-daemon.service 2>/dev/null || true
|
||||
@@ -18,16 +18,13 @@ else
|
||||
echo ">>> Warning: nix-daemon.service not found or systemctl not available."
|
||||
fi
|
||||
|
||||
# 3. Gruppe nix-users sicherstellen
|
||||
# 3. Ensure nix-users group
|
||||
if ! getent group nix-users >/dev/null 2>&1; then
|
||||
echo ">>> Creating nix-users group"
|
||||
# Debian/RPM/Arch haben alle groupadd
|
||||
groupadd -r nix-users 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# 4. Benutzer zu nix-users hinzufügen (Best-Effort)
|
||||
|
||||
# a) Wenn loginctl vorhanden ist → alle eingeloggten User
|
||||
# 4. Add users to nix-users (best-effort)
|
||||
if command -v loginctl >/dev/null 2>&1; then
|
||||
for user in $(loginctl list-users | awk 'NR>1 {print $2}'); do
|
||||
if id "$user" >/dev/null 2>&1; then
|
||||
@@ -35,7 +32,6 @@ if command -v loginctl >/dev/null 2>&1; then
|
||||
usermod -aG nix-users "$user" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
# b) Fallback: logname (typisch bei Debian)
|
||||
elif command -v logname >/dev/null 2>&1; then
|
||||
USERNAME="$(logname 2>/dev/null || true)"
|
||||
if [ -n "$USERNAME" ] && id "$USERNAME" >/dev/null 2>&1; then
|
||||
@@ -44,5 +40,5 @@ elif command -v logname >/dev/null 2>&1; then
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ">>> Nix initialization for package-manager complete."
|
||||
echo ">>> Nix initialization complete."
|
||||
echo ">>> You may need to log out and log back in to activate group membership."
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Enable flakes if not already configured.
|
||||
if [[ -z "${NIX_CONFIG:-}" ]]; then
|
||||
export NIX_CONFIG="experimental-features = nix-command flakes"
|
||||
fi
|
||||
|
||||
# Run Kevin’s package manager via Nix flake
|
||||
exec nix run "github:kevinveenbirkenbach/package-manager#pkgmgr" -- "$@"
|
||||
FLAKE_DIR="/usr/lib/package-manager"
|
||||
|
||||
exec nix run "${FLAKE_DIR}#pkgmgr" -- "$@"
|
||||
|
||||
Reference in New Issue
Block a user