Skip to content
ca-xPublic

About

self host gist server

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Nibble

Nibble icon

简体中文

Nibble is a self-hosted Git snippet library. Edit snippets in a browser or with Git, browse revisions, and connect a GitHub account to import or publish Gists.

New snippets start with snippet.md. Write and preview Markdown in the editor, or change the file extension to edit another language. The file view highlights source files and Markdown code blocks.

Settings offers English and Simplified Chinese, plus system, light, and dark appearance.

The history viewer opens a specific Git commit and offers downloads for its binary files. Clone mixed text and binary snippets to edit their files with Git.

Snippet library on desktop Snippet library on mobile

Desktop editor · Desktop settings · Mobile snippet · Mobile settings

The screenshots show v0.1.0.

Run with Docker

Run the v0.3.6 image from GitHub Container Registry.

docker run -d --name nibble \
  --restart unless-stopped \
  -p 6157:6157 -p 2222:2222 \
  -v "$HOME/.nibble:/opengist" \
  ghcr.io/ca-x/nibble:v0.3.6

Open http://localhost:6157. The first local account becomes the administrator. Remove the 2222 port mapping and set OG_SSH_GIT_ENABLED=disabled if you only use Git over HTTP. The latest tag tracks the latest stable GitHub release.

The Compose file uses the /opengist mount that OpenGist uses. Nibble has its own database schema and Git storage layout. Use a separate directory for a new installation.

  • Set UID and GID to choose the application user when the container starts as root. Both default to 1000.
  • To run rootless, set user: "1000:1000" in Compose and ensure that identity can write the host data directory.
  • Mount YAML at /config.yml:ro and environment assignments at /run/secrets/opengist_secrets:ro. The entrypoint sources this secrets file as shell syntax. Keep it under administrator control.
  • The Docker health check calls GET /healthcheck on 127.0.0.1:6157 by default and reads NIBBLE_HTTP_PORT or OG_HTTP_PORT from the container environment. If the internal address or port is configured only in YAML or the secrets file, set NIBBLE_HEALTHCHECK_URL in the container environment to the matching local URL, including /healthcheck.

Run a binary

Download the archive for your system from GitHub Releases and verify it against the release's SHA256SUMS. Linux and macOS releases use .tar.gz, and Windows releases use .zip. Each supports amd64 and arm64. Git 2.28 or later must be available on PATH.

./nibble
./nibble --config /path/to/config.yml

On Windows, run nibble.exe. Nibble stores data in ~/.nibble by default and listens on port 6157. Set http.host: 127.0.0.1 to restrict a local instance to your machine.

Configuration

Set options in YAML or with environment variables. For the same key, Nibble checks NIBBLE_* first, then OG_*, then YAML. The table uses one environment alias for each option. The corresponding prefix works for the same key.

YAML key Environment variable Default or purpose
data-dir NIBBLE_DATA_DIR ~/.nibble for a binary installation. The container sets OG_OPENGIST_HOME=/opengist.
opengist-home OG_OPENGIST_HOME Compatibility alias for the data directory.
db-uri OG_DB_URI nibble.db in the data directory. Also accepts PostgreSQL and MySQL URLs.
sqlite.journal-mode OG_SQLITE_JOURNAL_MODE WAL for SQLite.
secret-key OG_SECRET_KEY Uses the persistent instance.key file unless configured. Preserve this key when migrating data.
external-url OG_EXTERNAL_URL Set the public HTTP(S) origin when using a reverse proxy.
oidc.discovery-url OG_OIDC_DISCOVERY_URL OpenID Provider discovery URL ending in /.well-known/openid-configuration.
oidc.client-key OG_OIDC_CLIENT_KEY OpenID Connect client ID.
oidc.secret OG_OIDC_SECRET Client secret when the OpenID Connect provider requires one.
oidc.provider-name OG_OIDC_PROVIDER_NAME Sign-in button label. Defaults to OpenID Connect.
oidc.username-claim NIBBLE_OIDC_USERNAME_CLAIM Optional claim used to suggest a local username. Defaults to preferred_username.
oidc.display-name-claim NIBBLE_OIDC_DISPLAY_NAME_CLAIM Optional claim used as the display name at signup. Defaults to name, nickname, then the username.
oidc.group-claim-name OG_OIDC_GROUP_CLAIM_NAME Optional group claim and requested scope.
oidc.admin-group OG_OIDC_ADMIN_GROUP Optional group that grants administrator privileges at sign-in.
http.host OG_HTTP_HOST 0.0.0.0
http.port OG_HTTP_PORT 6157
http.git-enabled OG_HTTP_GIT_ENABLED true
ssh.host OG_SSH_HOST 0.0.0.0
ssh.port OG_SSH_PORT 2222
ssh.git-enabled OG_SSH_GIT_ENABLED builtin, host, or disabled.
require-login OG_REQUIRE_LOGIN Requires sign-in for browsing.
disable-signup OG_DISABLE_SIGNUP Closes registration after the first account.
disable-comments OG_DISABLE_COMMENTS Disables comments.
disable-file-upload OG_DISABLE_FILE_UPLOAD Disables file upload.
admin.username NIBBLE_ADMIN_USERNAME Initial administrator username for unattended setup.
admin.password NIBBLE_ADMIN_PASSWORD Initial administrator credential. Set both bootstrap variables together.
github.device-client-id NIBBLE_GITHUB_DEVICE_CLIENT_ID GitHub OAuth App client ID for device authorization.
gitlab.base-url NIBBLE_GITLAB_BASE_URL HTTPS root URL for the GitLab Snippets plugin. Defaults to https://gitlab.com.
custom.name OG_CUSTOM_NAME Default site name. An administrator can set the visible name and upload a logo under Settings → Administration → Site branding.
log-level OG_LOG_LEVEL info

Nibble accesses SQLite, PostgreSQL, and MySQL through SeaORM. Database URLs use postgres://user@host/database or mysql://user@host/database. With SQLite the database lives alongside the Git repositories and installation key in the data directory. Use one active Nibble instance per data directory. Back up the database, repositories and key at the same point. Stop writes during the snapshot, or use coordinated snapshots if the database is external.

The database schema is at version 10. Nibble records completed upgrades and rejects databases written by a newer schema. Git stores file bytes and history. SeaORM stores current permissions, metadata and synchronization state. Data and version design

Snippet owners can turn off revision history from a snippet’s actions menu. Nibble serves the current version and pauses access to older snapshots and their share links. Authorized Git clones retain the full repository history. Forks made while history is off start with the current snapshot.

Semantic search

Keyword search works out of the box. For hybrid search, pull an embedding model on a trusted Ollama instance, then use the YAML below or set NIBBLE_SEARCH_OLLAMA_URL, NIBBLE_SEARCH_EMBEDDING_MODEL, and NIBBLE_SEARCH_EMBEDDING_VERSION.

search:
  ollama-url: http://127.0.0.1:11434
  embedding-model: bge-m3
  embedding-version: "1"

Set embedding-version to identify your deployment's model weights. Change it and restart Nibble when the weights change. Adjust the cosine floor with search.min-similarity or NIBBLE_SEARCH_MIN_SIMILARITY (default 0.35). The first search starts indexing in the background. Keyword search remains available during the build and provider outages. Nibble sends search terms and indexed text to the configured service. Include private and unlisted snippets in their owner's semantic search by explicitly setting search.embed-private: true or NIBBLE_SEARCH_EMBED_PRIVATE=true. Search design and limits

Sign-in and account security

To enable OpenID Connect, configure the discovery URL and client ID, set external-url to the public origin, and register <external-url>/oauth/openid-connect/callback with the provider. New identities follow the instance registration policy. Matching the configured administrator group grants a persistent Nibble administrator role at sign-in.

Browser sign-in requests openid profile email and the configured group scope. Missing or blank mapped values and invalid username suggestions fall back to the standard claims. If UserInfo returns 401, 403 or 404, Nibble uses the verified ID token. First-time users can enter a local username manually. Account linking uses iss and sub. Existing users keep their local profile settings.

In Settings → Security, turn on two-factor authentication and scan the QR code or enter the key in a TOTP app. Save the five single-use recovery codes shown at setup. A fresh authenticator code or recovery code can replace the set or disable the factor. Sign-in requires the second step when the factor is enabled.

The account deletion API, DELETE /api/settings/account, requires a signed-in browser session and the username in the JSON confirmation field. Deletion revokes local credentials and removes owned snippets from the library. Nibble protects the last administrator account.

GitHub Gist sync

Create a GitHub OAuth App with Device Flow enabled. In Settings → Plugins → Install plugins, install GitHub Gist under Sync. In Manage, enter the Client ID, enable the plugin and save. You can also supply the Client ID through deployment configuration. Once enabled, open the GitHub Gist tab and confirm the device code on GitHub. The connection uses the gist scope. GitHub OAuth Apps

Choose manual sync, scheduled pull, scheduled push, or scheduled two-way sync. Scheduled pushes update linked public and unlisted snippets. Use the push action on a snippet to publish it to GitHub for the first time. Nibble reports a conflict when both copies changed since their last sync.

GitLab Snippets sync

An administrator can install and enable GitLab Snippets under Settings → Plugins. Connect with a GitLab personal access token that has the api scope. For self-managed GitLab, set gitlab.base-url in the deployment before connecting. The same page exposes manual sync and scheduled pull, push, or two-way sync.

The plugin imports personal snippets and keeps copies of up to 10 text files per snippet. The first export is available from a public or unlisted snippet's actions. Unlisted exports are private on GitLab. Scheduled pushes update linked snippets only. When GitLab cannot confirm creation, use the remote snippet ID to recover the link from the snippet's actions.

Share a private snippet

Open the actions menu on a private snippet and choose Create share link. Set an expiration or require a password, then copy the link. Visitors see the version captured when you created the link. In Settings → Share links, you can copy links again, change their expiration or password, and revoke them.

Build from source

Install Rust 1.97.1 or later, Node.js 24, npm and Git 2.28 or later.

npm --prefix web ci
npm --prefix web run build
cargo run -- --config docker/config.yml

cargo build --locked --release -p nibble builds a release binary with the contents of web/dist embedded. Build a local image with docker build -t nibble . and smoke-test it with scripts/test-container.sh nibble. The tag workflow checks the tag against the Cargo version, publishes the linux/amd64 and linux/arm64 image, and attaches six binary archives and SHA256SUMS to the GitHub Release.

License

Nibble is licensed under Apache 2.0. OpenGist is the behavior and deployment reference.

About

self host gist server

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages