Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add socket-based IPFS support #90157

Merged
merged 7 commits into from Jun 12, 2020

Conversation

matthewbauer
Copy link
Member

Does a few things:

  • Previously we had three services for different config flavors. This is
    confusing because only one instance of IPFS can run on a host / port
    combination at once. So move all into ipfs.service, which contains the
    configuration specified in services.ipfs.

  • Cleanup; Remove unused auto-migrate feature, remove wrapper usages

  • Add startWhenNeeded for systemd-based socket/tcp activation.

Previously we had three services for different config flavors. This is
confusing because only one instance of IPFS can run on a host / port
combination at once. So move all into ipfs.service, which contains the
configuration specified in services.ipfs.

Also remove the env wrapper and just use systemd env configuration.
ipfs --local config --json "${concatStringsSep "." path}" "$value"
'')
({ Addresses.API = cfg.apiAddress;
Addresses.Gateway = cfg.gatewayAddress;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#addressesapi so all these can in fact be lists of addreses, which is good for when we want to do unix domain socket and tcp

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does it choose which one to use?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(we discussed offline, but for posterity, the server will listen for all 3.)

@matthewbauer
Copy link
Member Author

matthewbauer commented Jun 11, 2020

It does look like we may be able to remove ipfs-init.service if we pass in the --init flag to ipfs daemon. I'm not sure how that would interact with services.ipfs.localDiscovery though.

@Ericson2314
Copy link
Member

Ericson2314 commented Jun 12, 2020

@matthewbauer sounds plausible to me, though I'm happy to do that later.


CC @Mic92

Copy link
Contributor

@flokli flokli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given you also reviewed #43089, does this solve all the concerns from here and fix #42672?

nixos/modules/services/network-filesystems/ipfs.nix Outdated Show resolved Hide resolved
@matthewbauer
Copy link
Member Author

Given you also reviewed #43089, does this solve all the concerns from here and fix #42672?

I think some of it - at least you don't need the wrapper anymore.

@flokli
Copy link
Contributor

flokli commented Jun 12, 2020

@matthewbauer can you properly squash the updated typo in the commit introducing the description?

matthewbauer and others added 4 commits June 12, 2020 17:15
This makes it possible to only start IPFS when needed. So a user’s
IPFS daemon only starts when they actually use it.

A few important warnings though:

  - This probably shouldn’t be mixed with services.ipfs.autoMount
    since you want /ipfs and /ipns aren’t activated like this
  - ipfs.socket assumes that you are using ports 5001 and 8080 for the
    API and gateway respectively. We could do some parsing to figure
    out what is in apiAddress and gatewayAddress, but that’s kind of
    difficult given the nonstandard address format.
  - Apparently? this doesn’t work with the --api commands used in the tests.

Of course you can always start automatically with startWhenNeeded =
false, or just running ‘systemctl start ipfs.service’.

Tested with the following test (modified from tests/ipfs.nix):

  import ./make-test-python.nix ({ pkgs, ...} : {
    name = "ipfs";

    nodes.machine = { ... }: {
      services.ipfs = {
        enable = true;
        startWhenNeeded = true;
      };
    };

    testScript = ''
      start_all()

      machine.wait_until_succeeds("ipfs id")
      ipfs_hash = machine.succeed("echo fnord | ipfs add | awk '{ print $2 }'")

      machine.succeed(f"ipfs cat /ipfs/{ipfs_hash.strip()} | grep fnord")
    '';
  })

Fixes NixOS#90145

Update nixos/modules/services/network-filesystems/ipfs.nix

Co-authored-by: Florian Klink <flokli@flokli.de>
@Ericson2314 Ericson2314 merged commit 1c4480e into NixOS:master Jun 12, 2020
@Ericson2314 Ericson2314 deleted the socket-based-ipfs branch June 12, 2020 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants