nixpkgs/nixos/modules/services/network-filesystems
Matthew Bauer b36ef706fb nixos/ipfs: add startWhenNeeded option
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 #90145

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

Co-authored-by: Florian Klink <flokli@flokli.de>
2020-06-12 17:15:27 -05:00
..
openafs treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
orangefs nixos/orangefs: add modules for server and client 2019-09-25 14:17:08 +02:00
cachefilesd.nix cachefilesd service: init 2016-10-16 19:58:33 +03:00
ceph.nix treewide: use attrs instead of list for types.loaOf options 2020-01-06 10:39:18 -05:00
davfs2.nix treewide: use attrs instead of list for types.loaOf options 2020-01-06 10:39:18 -05:00
diod.nix nixos/diod: fix permissions 2019-02-17 18:26:00 +01:00
drbd.nix treewide: use attrs instead of list for types.loaOf options 2020-01-06 10:39:18 -05:00
glusterfs.nix nixos: remove dependencies on local-fs.target 2019-09-01 19:06:38 +02:00
ipfs.nix nixos/ipfs: add startWhenNeeded option 2020-06-12 17:15:27 -05:00
kbfs.nix nixos/keybase, nixos/kbfs: update service configs; add redirector 2019-12-23 22:55:06 -08:00
netatalk.nix treewide: add bool type to enable options, or make use of mkEnableOption 2020-04-21 08:55:36 +02:00
nfsd.nix nixos/treewide: Move rename.nix imports to their respective modules 2019-12-10 02:51:19 +01:00
rsyncd.nix treewide: add bool type to enable options, or make use of mkEnableOption 2020-04-21 08:55:36 +02:00
samba.nix nixos/samba: move nss database configuration into samba module 2020-05-11 16:14:50 +02:00
tahoe.nix services.tahoe: Use 1.13-compatible invocations. 2019-02-19 10:23:47 -08:00
u9fs.nix u9fs service: start after network.target 2019-06-30 22:43:08 -04:00
xtreemfs.nix treewide: add bool type to enable options, or make use of mkEnableOption 2020-04-21 08:55:36 +02:00
yandex-disk.nix treewide: add bool type to enable options, or make use of mkEnableOption 2020-04-21 08:55:36 +02:00