# Pixi Repositories

> Use a CloudRepo Python repository from Pixi: the pypi-dependencies index, the .netrc credential, CI with NETRC, and what Pixi prints when it fails.

Pixi installs conda packages from conda channels and Python packages from a PyPI-compatible index. A CloudRepo Python repository is a PyPI-compatible index, so Pixi reads your private Python packages from it. Keep a `channels` line in `pixi.toml` pointing at the channel’s own host; CloudRepo hosts Python repositories, not conda channels.

## Before you start

- A Python repository to install from. [Creating a Repository](/docs/manage/repositories.html#creating-a-repository) explains how to make one.
- A repository token that covers it. **Download packages** is enough to install; publishing takes **Download and publish packages**. [Repository Tokens](/docs/authenticate/repository-tokens.html) shows how to create one. In `.netrc`, `login` is the email address that owns the token and `password` is the token.
- The index address, `https://your-org.mycloudrepo.io/repositories/your-repo/simple/`. The repository’s [Connection Settings](/docs/manage/repositories.html#view-connection-settings) page shows the URL with your organization and repository filled in. Add `/simple/` to the end.
- Pixi. The behavior described on this page was observed with Pixi 0.81.0.

> **Note:** Use a repository token with Pixi, not the password you use to sign in to the admin portal.

## Connect Pixi

**Pixi**

**1. Put the credential in `~/.netrc`.** Pixi reads it for any Python index host it finds there. Keep the file private to your own user (`chmod 600 ~/.netrc`):

`~/.netrc`

```ini
machine your-org.mycloudrepo.io
login you@example.com
password YOUR_REPOSITORY_TOKEN
```

**2. Name the index in `pixi.toml`.** Give each private package its own `index`. A package that names an index is looked up on that index, not on PyPI:

`pixi.toml`

```toml
[pypi-dependencies]
my-package = { version = "==1.0.0", index = "https://your-org.mycloudrepo.io/repositories/your-repo/simple/" }
```

The same entry from the command line:

**Terminal**

```bash
pixi add --pypi "my-package==1.0.0" --index https://your-org.mycloudrepo.io/repositories/your-repo/simple/
```

**3. Install.** Run this in the same directory as `pixi.toml`:

**Terminal**

```bash
pixi install
```

Expected: Pixi solves the environment and installs `my-package` from your repository.

## In CI

Pixi also reads the netrc named by the `NETRC` environment variable. Keep the token in the platform’s secret store, expose it to the step as `CLOUDREPO_TOKEN` (and your email as `CLOUDREPO_USERNAME`), write the netrc into a private temporary directory, point `NETRC` at it, and delete the directory when the step ends:

**Terminal**

```bash
umask 077
NETRC_DIR="$(mktemp -d)"
trap 'rm -rf "$NETRC_DIR"' EXIT
echo "machine your-org.mycloudrepo.io login $CLOUDREPO_USERNAME password $CLOUDREPO_TOKEN" > "$NETRC_DIR/netrc"
export NETRC="$NETRC_DIR/netrc"
pixi install
```

The token is in the file and in the environment, never on a command line, and the file is gone when the step exits, so it does not stay behind on a runner that later jobs reuse. For how each CI system holds a secret, see [CI/CD](/docs/ci/overview.html).

> **Pixi has no username or password variable:** Pixi’s authentication methods for a Python index are a netrc file and the keyring. Setting `PIXI_PYPI_USERNAME` and `PIXI_PYPI_PASSWORD`, as some examples do, sends nothing: the index sees a request with no credential.

## Troubleshooting

**`Because my-package was not found in the package registry and you require my-package==1.0.0`.** Pixi prints the same sentence when the package is missing and when the index answers `401 Unauthorized`, so a package you know is published usually means the credential did not arrive. Check, in order:

1. `~/.netrc` (or the file `NETRC` names) has a `machine` line that is exactly `your-org.mycloudrepo.io`, with no `https://` and no path.
2. `login` is the email address that owns the token, `password` is the token itself rather than your portal password, and the token has not expired or been revoked.
3. The `index` URL is `https://your-org.mycloudrepo.io/repositories/your-repo/simple/` with your repository’s name.

If those hold, test the credential on its own with the steps in [Troubleshooting](/docs/reference/troubleshooting.html#test-the-credential-on-its-own).

**The package is in the repository and the token is right, but the repository is a different one.** A token reaches only the repositories it was created for. `403 Forbidden` with `scope_mismatch_repo` means the token does not include this repository. See [`scope_mismatch_repo`](/docs/reference/error-codes.html#scope_mismatch_repo).

---

The page: https://www.cloudrepo.io/docs/formats/pixi.html
