# NIP Installation Guide

## Prerequisites

### All Platforms

- Nim compiler (version 1.6.0 or later)
- Git (for cloning the repository)
- Root/sudo access (for system installation)

### Linux

```bash
# Arch Linux
sudo pacman -S nim git

# Debian/Ubuntu
sudo apt install nim git

# Fedora
sudo dnf install nim git
```

### BSD

```bash
# FreeBSD
sudo pkg install nim git

# NetBSD
sudo pkgin install nim git

# DragonflyBSD
sudo pkg install nim git
```

## Installation Steps

### 1. Clone Repository

```bash
git clone https://git.maiwald.work/Nexus/NexusToolKit.git
cd NexusToolKit/nip
```

### 2. Build

```bash
./build.sh
```

This creates an optimized, stripped binary (`nip_mvp`, ~568KB).

### 3. Install

```bash
sudo ./install.sh
```

This will:
- Install binary to `/usr/local/bin/nip`
- Create necessary directories
- Setup default configuration
- Configure PATH and library paths

### 4. Verify

```bash
nip --version
nip platform
nip config show
```

## Post-Installation

### Setup Shell Integration

```bash
# Automatic setup (requires root)
sudo nip setup

# Or manually add to your shell profile:
source /etc/profile.d/nip.sh
```

### Initialize User Configuration

```bash
nip config init
```

Edit `~/.nip/config` to customize settings.

## Platform-Specific Notes

### Linux (Arch)

NIP works alongside Pacman. You can use both:

```bash
# Install with Pacman
sudo pacman -S firefox

# Or graft with NIP
sudo nip graft nix:firefox
```

### BSD Systems

PKGSRC is the default adapter on BSD:

```bash
# Graft from PKGSRC (native)
sudo nip graft pkgsrc:vim

# Or from Nix (if installed)
sudo nip graft nix:hello
```

### Installing Nix (Optional)

For best cross-platform support, install Nix:

```bash
# Linux & BSD
sh <(curl -L https://nixos.org/nix/install) --daemon
```

## Troubleshooting

### Build Fails

Ensure Nim is installed and up to date:

```bash
nim --version  # Should be 1.6.0+
```

### Permission Denied During Install

The install script requires root:

```bash
sudo ./install.sh
```

### Can't Create Directories

Check available disk space and permissions:

```bash
df -h /
ls -ld /Programs /System 2>/dev/null || echo "Directories don't exist yet"
```

## Uninstallation

```bash
sudo ./uninstall.sh
```

You'll be prompted to remove:
- Programs and symlinks
- Database and cache
- Configuration files

## Next Steps

After installation, see [USAGE.md](USAGE.md) for detailed usage instructions.
