kubo/docs/plugins.md
Steven Allen f706bc69ba docs: flesh out plugin documentation
* Flesh out build documentation.
* Add datastore plugins to plugin list.
* Link to example plugin.
* Add a TOC.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2018-12-26 16:48:49 -08:00

3.6 KiB

Plugins

Since 0.4.11 go-ipfs has an experimental plugin system that allows augmenting the daemons functionality without recompiling.

When an IPFS node is started, it will load plugins from the $IPFS_PATH/plugins directory (by default ~/.ipfs/plugins).

Table of Contents

Plugin Types

IPLD

IPLD plugins add support for additional formats to ipfs dag and other IPLD related commands.

Datastore

Datastore plugins add support for additional datastore backends.

Available Plugins

Name Type Built-In Description
git IPLD x An IPLD format for git objects.
badgerds Datastore x A high performance but experimental datastore.
flatfs Datastore x A stable filesystem-based datastore.
levelds Datastore x A stable, flexible datastore backend.
  • Built-In plugins are built into the go-ipfs binary and do not need to be installed separately. At the moment, all known plugins are built-in as they're mature and have proven themselves to be useful.

Installing Plugins

External plugins must be installed in $IPFS_PATH/plugins/ (usually ~/.ipfs/plugins/). Alternatively, plugins can be preloaded and built into the go-ipfs binary itself.

External Plugin

At the moment, this method is only supported on Linux and MacOS. Users of other operating systems should follow the instructions for preloaded plugins.

In-tree

To build plugins included in plugin/plugins, run:

go-ipfs$ make build_plugins
go-ipfs$ ls plugin/plugins/*.so

To install, copy desired plugins to $IPFS_PATH/plugins. For example:

go-ipfs$ mkdir -p ~/.ipfs/plugins/
go-ipfs$ cp plugin/plugins/git.so ~/.ipfs/plugins/
go-ipfs$ chmod +x ~/.ipfs/plugins/git.so # ensure plugin is executable

Finally, restart daemon if it is running.

Out-of-tree

To build out-of-tree plugins, use the plugin's Makefile if provided. Otherwise, you can manually build the plugin by running:

myplugin$ go build -buildmode=plugin -i -o myplugin.so myplugin.go

Finally, as with in-tree plugins:

  1. Install the plugin in $IPFS_PATH/plugins.
  2. Mark the plugin as executable (chmod +x $IPFS_PATH/plugins/myplugin.so).
  3. Restart your IPFS daemon (if running).

Preloaded Plugins

To preload a go-ipfs plugin:

  1. Add the plugin to the preload list: plugin/loader/preload_list
  2. Build ipfs
go-ipfs$ make build

Creating A Plugin

To create your own out-of-tree plugin, use the example plugin as a starting point. When you're ready, submit a PR adding it to the list of available plugins.