Skip to content

Commit 5a42289

Browse files
authored
Merge pull request #5876 from ipfs/doc/plugin-stuff
docs: flesh out plugin documentation
2 parents b3bea6a + 02a1fea commit 5a42289

File tree

1 file changed

+83
-16
lines changed

1 file changed

+83
-16
lines changed

docs/plugins.md

+83-16
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,114 @@
33
Since 0.4.11 go-ipfs has an experimental plugin system that allows augmenting
44
the daemons functionality without recompiling.
55

6-
When an IPFS node is created, it will load plugins from the `$IPFS_PATH/plugins`
6+
When an IPFS node is started, it will load plugins from the `$IPFS_PATH/plugins`
77
directory (by default `~/.ipfs/plugins`).
88

9-
### Plugin types
9+
**Table of Contents**
10+
11+
- [Plugin Types](#plugin-types)
12+
- [IPLD](#ipld)
13+
- [Datastore](#datastore)
14+
- [Available Plugins](#available-plugins)
15+
- [Installing Plugins](#installing-plugins)
16+
- [External Plugin](#external-plugin)
17+
- [In-tree](#in-tree)
18+
- [Out-of-tree](#out-of-tree)
19+
- [Preloaded Plugins](#preloaded-plugins)
20+
- [Creating A Plugin](#creating-a-plugin)
21+
22+
## Plugin Types
23+
24+
### IPLD
1025

11-
#### IPLD
1226
IPLD plugins add support for additional formats to `ipfs dag` and other IPLD
1327
related commands.
1428

15-
### Supported plugins
29+
### Datastore
30+
31+
Datastore plugins add support for additional datastore backends.
32+
33+
## Available Plugins
34+
35+
| Name | Type | Preloaded | Description |
36+
|---------------------------------------------------------------------------------|-----------|-----------|------------------------------------------------|
37+
| [git](https://github.com/ipfs/go-ipfs/tree/master/plugin/plugins/git) | IPLD | x | An IPLD format for git objects. |
38+
| [badgerds](https://github.com/ipfs/go-ipfs/tree/master/plugin/plugins/badgerds) | Datastore | x | A high performance but experimental datastore. |
39+
| [flatfs](https://github.com/ipfs/go-ipfs/tree/master/plugin/plugins/flatfs) | Datastore | x | A stable filesystem-based datastore. |
40+
| [levelds](https://github.com/ipfs/go-ipfs/tree/master/plugin/plugins/levelds) | Datastore | x | A stable, flexible datastore backend. |
1641

17-
| Name | Type |
18-
|------|------|
19-
| git | IPLD |
42+
* **Preloaded** plugins are built into the go-ipfs binary and do not need to be
43+
installed separately. At the moment, all in-tree plugins are preloaded.
2044

21-
#### Installation
45+
## Installing Plugins
2246

23-
##### Linux
47+
Go-ipfs supports two types of plugins: External and Preloaded.
48+
49+
* External plugins must be installed in `$IPFS_PATH/plugins/` (usually
50+
`~/.ipfs/plugins/`).
51+
* Preloaded plugins are built-into the go-ipfs when it's compiled.
52+
53+
### External Plugin
54+
55+
The advantage of an external plugin is that it can be built, packaged, and
56+
installed independently of go-ipfs. Unfortunately, this method is only supported
57+
on Linux and MacOS at the moment. Users of other operating systems should follow
58+
the instructions for preloaded plugins.
59+
60+
#### In-tree
61+
62+
To build plugins included in
63+
[plugin/plugins](https://github.com/ipfs/go-ipfs/tree/master/plugin/plugins),
64+
run:
2465

25-
1. Build included plugins:
2666
```bash
2767
go-ipfs$ make build_plugins
2868
go-ipfs$ ls plugin/plugins/*.so
2969
```
3070

31-
3. Copy desired plugins to `$IPFS_PATH/plugins`
71+
To install, copy desired plugins to `$IPFS_PATH/plugins`. For example:
72+
3273
```bash
3374
go-ipfs$ mkdir -p ~/.ipfs/plugins/
3475
go-ipfs$ cp plugin/plugins/git.so ~/.ipfs/plugins/
3576
go-ipfs$ chmod +x ~/.ipfs/plugins/git.so # ensure plugin is executable
3677
```
3778

38-
4. Restart daemon if it is running
79+
Finally, restart daemon if it is running.
3980

40-
##### Other
81+
#### Out-of-tree
4182

42-
Go currently only supports plugins on Linux, for other platforms you will need
43-
to compile them into IPFS binary.
83+
To build out-of-tree plugins, use the plugin's Makefile if provided. Otherwise,
84+
you can manually build the plugin by running:
4485

45-
1. Uncomment plugin entries in `plugin/loader/preload_list`
86+
```bash
87+
myplugin$ go build -buildmode=plugin -i -o myplugin.so myplugin.go
88+
```
89+
90+
Finally, as with in-tree plugins:
91+
92+
1. Install the plugin in `$IPFS_PATH/plugins`.
93+
2. Mark the plugin as executable (`chmod +x $IPFS_PATH/plugins/myplugin.so`).
94+
3. Restart your IPFS daemon (if running).
95+
96+
### Preloaded Plugins
97+
98+
The advantages of preloaded plugins are:
99+
100+
1. They're bundled with the go-ipfs binary.
101+
2. They work on all platforms.
102+
103+
To preload a go-ipfs plugin:
104+
105+
1. Add the plugin to the preload list: `plugin/loader/preload_list`
46106
2. Build ipfs
47107
```bash
48108
go-ipfs$ make build
49109
```
110+
111+
## Creating A Plugin
112+
113+
To create your own out-of-tree plugin, use the [example
114+
plugin](https://github.com/ipfs/go-ipfs-example-plugin/) as a starting point.
115+
When you're ready, submit a PR adding it to the list of [available
116+
plugins](#available-plugins).

0 commit comments

Comments
 (0)