warehouse/README.md

1.5 KiB

warehouse

A simple cargo registry.

To run this, you need to:

  • Create a /etc/warehouse/warehouse.toml file with the following contents:

    working_dir = "/path/to/some/directory"
    postgres_uri = "postgres://user:pass@db_host/db_name"
    listen_uri = "0.0.0.0:1234"
    
  • Run a PostgreSQL database at the specified URI.

  • Initialize a (not bare) git repository at the_working_dir/index

  • Create a index/config.json file, with the following contents:

    {
        "dl": "http://your.website:1234/api/v1/crates",
        "api": "http://your.website:1234"
    }
    

    HTTPS is currently broken for an unknown reason.

  • Write the following to index/.git/hooks/post-commit:

    #!/bin/sh
    
    exec git update-server-info
    
  • Commit the config.json to git.

  • Run any webserver at index/.git. (another method of serving git would also work)

    Note: you may need to set net.git-fetch-with-cli = true in your ~/.cargo/config.toml

The URL of that webserver/git repository is the URL of the registry.

Users must add the following to their ~/.cargo/config.toml:

[registries]
foobarbaz = { index = "http://the.index.url" }

Creating accounts is currently not managed by this code. You will have to run the following query to add a user:

INSERT INTO users (login, credential) VALUES ('username', 'account token')

You can then give out the token for someone else to use with cargo login.