# Documentation

Common ways to use `nix develop` with Nix O'matic.

## Single package

Ask for a single package by name:

### Using Nix

```bash
nix \
    --extra-experimental-features 'nix-command flakes' \
    develop 'https://nixomatic.com/?p=cowsay' \
      --accept-flake-config \
      --command -- cowsay 'Hello, world!'
```

### Using Docker

```bash
docker run -v nix-store:/nix --rm nixos/nix nix \
    --extra-experimental-features 'nix-command flakes' \
    --option build-users-group "" \
    develop 'https://nixomatic.com/?p=cowsay' \
      --accept-flake-config \
      --command -- cowsay 'Hello, world!'
```

Pipe data into a tool inside the environment:

### Using Nix

```bash
echo 'Hello, world!' | \
    nix \
      --extra-experimental-features 'nix-command flakes' \
      develop 'https://nixomatic.com/?p=cowsay' \
        --accept-flake-config \
        --command -- cowsay
```

### Using Docker

```bash
echo 'Hello, world!' | \
    docker run -v nix-store:/nix --rm -i nixos/nix nix \
      --extra-experimental-features 'nix-command flakes' \
      --option build-users-group "" \
      develop 'https://nixomatic.com/?p=cowsay' \
        --accept-flake-config \
        --command -- cowsay
```

## Multiple packages

Request multiple packages with comma-separated values in an interactive shell:

### Using Nix

```bash
nix \
    --extra-experimental-features 'nix-command flakes' \
    develop 'https://nixomatic.com/?p=rustc,cargo' \
      --accept-flake-config
```

### Using Docker

```bash
docker run -v nix-store:/nix --rm -it nixos/nix nix \
    --extra-experimental-features 'nix-command flakes' \
    --option build-users-group "" \
    develop 'https://nixomatic.com/?p=rustc,cargo' \
      --accept-flake-config
```

## Versioning

Use `:` to pin a package to a specific nixpkgs revision:

### Using Nix

```bash
nix \
    --extra-experimental-features 'nix-command flakes' \
    develop 'https://nixomatic.com/?p=python3:3b93cf5' \
      --accept-flake-config
```

### Using Docker

```bash
docker run -v nix-store:/nix --rm -it nixos/nix nix \
    --extra-experimental-features 'nix-command flakes' \
    --option build-users-group "" \
    develop 'https://nixomatic.com/?p=python3:3b93cf5' \
      --accept-flake-config
```

Pin to a specific package version with `@`. Versions are resolved with [nxv](https://nxv.urandom.io/):

### Using Nix

```bash
nix \
    --extra-experimental-features 'nix-command flakes' \
    develop 'https://nixomatic.com/?p=nodejs@20.11.1' \
      --accept-flake-config
```

### Using Docker

```bash
docker run -v nix-store:/nix --rm -it nixos/nix nix \
    --extra-experimental-features 'nix-command flakes' \
    --option build-users-group "" \
    develop 'https://nixomatic.com/?p=nodejs@20.11.1' \
      --accept-flake-config
```

## Mixed

Or mix and match both:

### Using Nix

```bash
nix \
    --extra-experimental-features 'nix-command flakes' \
    develop 'https://nixomatic.com/?p=cowsay:ed142ab,python3:3b93cf5,nodejs@20.11.1' \
      --accept-flake-config
```

### Using Docker

```bash
docker run -v nix-store:/nix --rm -it nixos/nix nix \
    --extra-experimental-features 'nix-command flakes' \
    --option build-users-group "" \
    develop 'https://nixomatic.com/?p=cowsay:ed142ab,python3:3b93cf5,nodejs@20.11.1' \
      --accept-flake-config
```
