This Composer registry fetches multiple sources and serves them as Composer packages.
config.json
or a config.yml
like your preferences.docker run \
-p 8080:8080 \
-v $(pwd)/config.json:/config.json \
-v $(pwd)/storage:/storage \
ghcr.io/shyim/composer-registry:latest
/storage
will be used to save the database and zips if mirroring is enabled
Import this as flake.
inputs = {
composer-registry = {
url = "github:shyim/composer-registry";
inputs.nixpkgs.follows = "nixpkgs";
};
}
Import the module on your system.
{ pkgs, inputs, ... }:
{
imports = [
inputs.composer-registry.nixosModules.default
];
}
Activate the given service:
services.composer-registry = {
enable = true;
settings = {
base_url = "https://my.composer.io";
};
};
The base config file looks like this:
{
"$schema": "https://raw.githubusercontent.com/shyim/composer-registry/main/config-schema.json",
"base_url": "http://localhost:8080"
}
The base_url
is the URL where the instance is available. Currently it is not possible to change this afterwards. (This will be used only for mirroring/custom packages).
{
"$schema": "https://raw.githubusercontent.com/shyim/composer-registry/main/config-schema.json",
"base_url": "http://localhost:8080",
"providers": [
{
"name": "my-gitlab-instance", // provider name.
"type": "gitlab",
"domain": "gitlab.com", // gitlab.com or your instance domain
"token": "my-gitlab-token", // access token with read_api
"webhook_secret": "my-gitlab-webhook-secret", // webhook secret Webhook address is /webhook/<provider-name>
"fetch_all_on_start": true, // Fetches all packages on start, Optional
"projects": [
{
"name": "my-gitlab-group/repo" // project name to consider
}
],
"cron_schedule": "*/5 * * * *" // Cron schedule for refetching anything. Optional if you don't want to have webhooks
}
]
}
The registry serves only the package information, the zip will be directly downloaded from your Gitlab instance. To do this you need to configure composer too.
Add following to your composer.json
"repositories": [
{
"type": "composer",
"url": "<url-of-this-service-hosted>"
}
],
"config": {
"gitlab-domains": ["<GITLAB-DOMAIN>"]
}
> composer config gitlab-token.<GITLAB-DOMAIN> TOKEN
{
"$schema": "https://raw.githubusercontent.com/shyim/composer-registry/main/config-schema.json",
"base_url": "http://localhost:8080",
"providers": [
{
"name": "my-github-instance", // provider name.
"type": "github",
"token": "my-github-token", // personal access token
"webhook_secret": "my-github-webhook-secret", // webhook secret Webhook address is /webhook/<provider-name>
"fetch_all_on_start": true, // Fetches all packages on start, Optional
"projects": [
{
"name": "my-github-group/repo" // project name to consider
}
],
"cron_schedule": "*/5 * * * *" // Cron schedule for refetching anything. Optional if you don't want to have webhooks
}
]
}
The registry serves only the package information, the zip will be directly downloaded from your GitHub instance. To do this you need to configure composer too.
Add following to your composer.json
> composer config github-oauth.github.com token
{
"$schema": "https://raw.githubusercontent.com/shyim/composer-registry/main/config-schema.json",
"base_url": "http://localhost:8080",
"providers": [
{
"name": "shopware", // provider name.
"type": "shopware",
"fetch_all_on_start": true, // Fetches all packages on start, Optional
"projects": [
{
"name": "The Composer Token" // project name to consider
}
],
"cron_schedule": "*/5 * * * *" // Cron schedule for refetching anything. Optional if you don't want to have webhooks
}
]
}
The registry will download all packages from the Shopware Composer repository and serve them.
{
"$schema": "https://raw.githubusercontent.com/shyim/composer-registry/main/config-schema.json",
"base_url": "http://localhost:8080",
"providers": [
{
"name": "custom", // provider name.
"type": "custom",
"webhook_secret": "my-api-secret"
}
]
}
This will enable two API endpoints to add/update or delete packages:
Create/update package:
POST http://localhost:8080/custom/package/create
Authorization: bearer <webhook-secret>
The request body is the ZIP file.
Delete package:
DELETE http://localhost:8080/custom/package/<name>/<version>
Authorization: bearer <webhook-secret>
By default, is the authentication disabled. To enabled add users to your configuration.
{
"$schema": "https://raw.githubusercontent.com/shyim/composer-registry/main/config-schema.json",
"base_url": "http://localhost:8080",
"users": [
{
"token": "TOKEN"
}
]
}
The token can be configured like so
> composer config bearer.<instance-domain> <your-token>
You can add to the tokens rules, when they match then the token will be able to download that package.
Possible types are: begins_with
, ends_with
, contains
, equals
{
"$schema": "https://raw.githubusercontent.com/shyim/composer-registry/main/config-schema.json",
"base_url": "http://localhost:8080",
"users": [
{
"token": "test",
"rules": [
{
"type": "begins_with",
"value": "store.shopware.com"
}
]
}
]
}