plugins.md 3.64 KB
Newer Older
1 2
# Plugins

Jeromy Johnson's avatar
Jeromy Johnson committed
3 4
Since 0.4.11 go-ipfs has an experimental plugin system that allows augmenting
the daemons functionality without recompiling.
5

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

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
**Table of Contents**

- [Plugin Types](#plugin-types)
    - [IPLD](#ipld)
    - [Datastore](#datastore)
- [Available Plugins](#available-plugins)
- [Installing Plugins](#installing-plugins)
    - [External Plugin](#external-plugin)
        - [In-tree](#in-tree)
        - [Out-of-tree](#out-of-tree)
    - [Preloaded Plugins](#preloaded-plugins)
- [Creating A Plugin](#creating-a-plugin)

## Plugin Types

### IPLD
25 26 27 28

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

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
### Datastore

Datastore plugins add support for additional datastore backends.

## Available Plugins

| Name                                                                            | Type      | Built-In | Description                                    |
|---------------------------------------------------------------------------------|-----------|----------|------------------------------------------------|
| [git](https://github.com/ipfs/go-ipfs/tree/master/plugin/plugins/git)           | IPLD      | x        | An IPLD format for git objects.                |
| [badgerds](https://github.com/ipfs/go-ipfs/tree/master/plugin/plugins/badgerds) | Datastore | x        | A high performance but experimental datastore. |
| [flatfs](https://github.com/ipfs/go-ipfs/tree/master/plugin/plugins/flatfs)     | Datastore | x        | A stable filesystem-based datastore.           |
| [levelds](https://github.com/ipfs/go-ipfs/tree/master/plugin/plugins/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
53

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

57
#### In-tree
58

59 60 61
To build plugins included in
[plugin/plugins](https://github.com/ipfs/go-ipfs/tree/master/plugin/plugins),
run:
62 63 64 65 66 67

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

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

70 71 72 73 74 75
```bash
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
```

76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
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:

```bash
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).
92

93
### Preloaded Plugins
94

95
To preload a go-ipfs plugin:
96

97
1. Add the plugin to the preload list: `plugin/loader/preload_list`
98 99 100 101
2. Build ipfs
```bash
go-ipfs$ make build
```
102 103 104 105 106 107 108

## Creating A Plugin

To create your own out-of-tree plugin, use the [example
plugin](https://github.com/ipfs/go-ipfs-example-plugin/) as a starting point.
When you're ready, submit a PR adding it to the list of [available
plugins](#available-plugins).