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.
45 lines
1.4 KiB
Bash
45 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
echo ">>> Initializing Nix environment for package-manager..."
|
|
|
|
# 1. /nix store
|
|
if [ ! -d /nix ]; then
|
|
echo ">>> Creating /nix store directory"
|
|
mkdir -m 0755 /nix
|
|
chown root:root /nix
|
|
fi
|
|
|
|
# 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
|
|
else
|
|
echo ">>> Warning: nix-daemon.service not found or systemctl not available."
|
|
fi
|
|
|
|
# 3. Ensure nix-users group
|
|
if ! getent group nix-users >/dev/null 2>&1; then
|
|
echo ">>> Creating nix-users group"
|
|
groupadd -r nix-users 2>/dev/null || true
|
|
fi
|
|
|
|
# 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
|
|
echo ">>> Adding user '$user' to nix-users"
|
|
usermod -aG nix-users "$user" 2>/dev/null || true
|
|
fi
|
|
done
|
|
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
|
|
echo ">>> Adding user '$USERNAME' to nix-users"
|
|
usermod -aG nix-users "$USERNAME" 2>/dev/null || true
|
|
fi
|
|
fi
|
|
|
|
echo ">>> Nix initialization complete."
|
|
echo ">>> You may need to log out and log back in to activate group membership."
|