# NIP Installation Guide

## Quick Install (Recommended)

### One-Line Installation

```bash
# Using curl
curl -L https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/install.sh | sudo bash

# Using wget
wget -O- https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/install.sh | sudo bash
```

### What the installer does:

1. **Detects your system** (OS, architecture, memory)
2. **Selects optimal binary variant** (ultra-minimal for embedded, compressed for general use)
3. **Downloads and verifies** the NIP binary
4. **Creates system directories** (/Programs, /System/Links, etc.)
5. **Sets up system integration** (PATH, library paths)
6. **Ready to use!**

---

## Manual Installation

### 1. Download Binary

Choose the variant that best fits your needs:

| Variant | Size | Best For | Download |
|---------|------|----------|----------|
| **Ultra-Minimal** | 517KB | Embedded/IoT systems | [nip-optimized-size-upx](https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/nip-optimized-size-upx) |
| **Compressed** | 557KB | General use (recommended) | [nip-static-upx](https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/nip-static-upx) |
| **Standard** | 1.6MB | No compression preference | [nip-static](https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/nip-static) |
| **Size-Optimized** | 1.5MB | Minimal systems | [nip-optimized-size](https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/nip-optimized-size) |
| **Speed-Optimized** | 1.6MB | Performance critical | [nip-optimized-speed](https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/nip-optimized-speed) |

### 2. Install Binary

```bash
# Download (example with compressed variant)
curl -L https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/nip-static-upx -o nip

# Make executable
chmod +x nip

# Install system-wide
sudo mv nip /usr/local/bin/nip
```

### 3. Create System Directories

```bash
# Core directories
sudo mkdir -p /Programs
sudo mkdir -p /System/Links/{Executables,Libraries,Headers,Shared}
sudo mkdir -p /var/lib/nip/{cas,db,generations}
sudo mkdir -p /var/cache/nip/{packages,build}
sudo mkdir -p /var/log/nip
sudo mkdir -p /etc/nip

# Set permissions
sudo chmod 755 /Programs /System/Links/*
sudo chmod 755 /var/lib/nip /var/lib/nip/*
sudo chmod 755 /var/cache/nip /var/cache/nip/*
sudo chmod 755 /var/log/nip /etc/nip
```

### 4. Setup System Integration

```bash
# Add to PATH
echo 'export PATH="/usr/local/bin:$PATH"' | sudo tee /etc/profile.d/nip.sh

# Setup library paths
echo "/System/Links/Libraries" | sudo tee /etc/ld.so.conf.d/nip.conf
sudo ldconfig
```

---

## Platform Support

### Currently Supported

- ✅ **Linux x86_64** (all major distributions)
- ✅ **Static binaries** (no dependencies)
- ✅ **Kernel 4.19+** compatibility

### Planned Support

- 📋 **Linux ARM64** (aarch64)
- 📋 **Linux RISC-V** (riscv64)
- 📋 **FreeBSD x86_64**
- 📋 **NetBSD x86_64**

---

## Verification

### Check Installation

```bash
# Verify NIP is installed
which nip

# Check version
nip --version

# Initialize system (first time)
sudo nip setup

# Check status
nip status
```

### Expected Output

```bash
$ nip --version
NIP version 0.1.0-mvp

$ nip status
🎅 NIP v0.2.0 'Weihnachtsmann' Status
====================================

✅ Binary: /usr/local/bin/nip (557KB)
✅ Directories: All system directories present
✅ Integration: PATH and library paths configured
📋 Ready for package management!
```

---

## Uninstallation

### Quick Uninstall

```bash
# One-line uninstaller
curl -L https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/uninstall.sh | sudo bash

# Or with wget
wget -O- https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/uninstall.sh | sudo bash
```

### Manual Uninstall

```bash
# Remove binary
sudo rm -f /usr/local/bin/nip

# Remove system integration
sudo rm -f /etc/profile.d/nip.sh
sudo rm -f /etc/ld.so.conf.d/nip.conf
sudo ldconfig

# Optionally remove data (WARNING: This removes all packages!)
sudo rm -rf /Programs /System/Links
sudo rm -rf /var/lib/nip /var/cache/nip /var/log/nip /etc/nip
```

---

## Troubleshooting

### Common Issues

**1. Permission Denied**
```bash
# Make sure you're using sudo
sudo nip setup
```

**2. Command Not Found**
```bash
# Check if NIP is in PATH
echo $PATH | grep -q "/usr/local/bin" || echo "PATH issue"

# Reload shell or source profile
source /etc/profile.d/nip.sh
```

**3. Binary Won't Execute**
```bash
# Check if binary is executable
ls -la /usr/local/bin/nip

# Check architecture compatibility
file /usr/local/bin/nip
```

**4. System Directories Missing**
```bash
# Re-run setup
sudo nip setup

# Or create manually (see manual installation)
```

### Getting Help

- 📚 **Documentation:** [NexusToolKit Repository](https://git.maiwald.work/Nexus/NexusToolKit)
- 🐛 **Issues:** [Report Issues](https://git.maiwald.work/Nexus/NexusToolKit/issues)
- 💬 **Support:** [Discussions](https://git.maiwald.work/Nexus/NexusToolKit/discussions)

---

## Advanced Installation

### Custom Installation Directory

```bash
# Set custom install directory
export INSTALL_DIR="/opt/nip/bin"
curl -L https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/install.sh | sudo bash
```

### Offline Installation

```bash
# 1. Download installer and binary on connected machine
curl -L https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/install.sh -o install.sh
curl -L https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/nip-static-upx -o nip-static-upx

# 2. Transfer to offline machine
scp install.sh nip-static-upx user@offline-machine:

# 3. Install offline
sudo bash install.sh --offline nip-static-upx
```

### Container Installation

```dockerfile
# Dockerfile example
FROM alpine:latest

# Install NIP
RUN apk add --no-cache curl sudo && \
    curl -L https://git.maiwald.work/Nexus/NexusToolKit/raw/branch/main/nip/install.sh | bash

# Use NIP
RUN nip setup
```

---

## Next Steps

After installation:

1. **Initialize NIP:** `sudo nip setup`
2. **Check status:** `nip status`
3. **Install packages:** `nip graft aur firefox`
4. **Build from source:** `nip build nginx +http3`
5. **Read documentation:** [Getting Started Guide](https://git.maiwald.work/Nexus/NexusToolKit/blob/main/nip/README.md)

---

**Installation Guide Version:** 1.0
**Last Updated:** November 18, 2025
**NIP Version:** v0.2.0 "Weihnachtsmann"