IPFS: Difference between revisions

From NixOS Wiki
imported>Onny
mNo edit summary
Luflosi (talk | contribs)
Add instructions for adding the user to the correct group
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[https://ipfs.tech/ IPFS] (InterPlanetary File System) is a protocol, hypermedia and file sharing peer-to-peer network for storing and sharing data in a distributed file system. IPFS aims to make the web more efficient, resilient, and open by using content-addressing to uniquely identify each file in a global namespace. IPFS also enables persistent availability of data with or without internet backbone connectivity, and complements HTTP to build a better web for all of us. IPFS can be used by anyone who wants to store and provide files, or by developers who want to create applications using IPFS technology.
[https://ipfs.tech/ IPFS] (InterPlanetary File System) is a protocol, hypermedia and file sharing peer-to-peer network for storing and sharing data in a distributed file system. IPFS aims to make the web more efficient, resilient, and open by using content-addressing to uniquely identify each file in a global namespace. IPFS also enables persistent availability of data with or without internet backbone connectivity, and complements HTTP.


== Installation ==
== Installation ==


Install ''kubo'', which is the recommended IPFS client, in your current environment
Install and enable ''kubo'' (which is the recommended IPFS implementation) and add your user to the correct group


<syntaxhighlight lang="console">
<syntaxhighlight lang="nix">
# nix-env -iA nixos.kubo
services.kubo = {
  enable = true;
};
users.users.alice.extraGroups = [ config.services.kubo.group ];
</syntaxhighlight>
</syntaxhighlight>
Note that after enabling this option and rebuilding your system, you need to log out and back in for the "IPFS_PATH" environment variable to be present in your shell and for your user to become part of the ipfs group. Until you do that, the CLI tools won't be able to talk to the daemon by default.


== Usage ==
== Usage ==
Line 14: Line 18:


<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
echo "hello world" > hello
# echo "hello world" > hello
ipfs add hello
# ipfs add hello
# This should output a hash string that looks something like:
This should output a hash string that looks something like:
# QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
ipfs cat <that hash>
# ipfs cat <that hash>
</syntaxhighlight>
</syntaxhighlight>


Line 24: Line 28:


<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
ipfs get <hash>
# ipfs get <hash>
</syntaxhighlight>
</syntaxhighlight>


Line 30: Line 34:


<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
ipfs add -r folder
# ipfs add -r folder
ipfs ls <hash>
# ipfs ls <hash>
ipfs ls <hash>/subdirectory
# ipfs ls <hash>/subdirectory
</syntaxhighlight>
</syntaxhighlight>


[[Category:Applications]]
[[Category:Applications]]

Latest revision as of 16:45, 1 April 2024

IPFS (InterPlanetary File System) is a protocol, hypermedia and file sharing peer-to-peer network for storing and sharing data in a distributed file system. IPFS aims to make the web more efficient, resilient, and open by using content-addressing to uniquely identify each file in a global namespace. IPFS also enables persistent availability of data with or without internet backbone connectivity, and complements HTTP.

Installation

Install and enable kubo (which is the recommended IPFS implementation) and add your user to the correct group

services.kubo = {
  enable = true;
};
users.users.alice.extraGroups = [ config.services.kubo.group ];

Note that after enabling this option and rebuilding your system, you need to log out and back in for the "IPFS_PATH" environment variable to be present in your shell and for your user to become part of the ipfs group. Until you do that, the CLI tools won't be able to talk to the daemon by default.

Usage

Publish a file and read it afterwards

# echo "hello world" > hello
# ipfs add hello
This should output a hash string that looks something like:
QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
# ipfs cat <that hash>

Download a file given a hash

# ipfs get <hash>

Publish and print directory content. For the ls command, use the hash of the root directory.

# ipfs add -r folder
# ipfs ls <hash>
# ipfs ls <hash>/subdirectory