nixpkgs-suyu/nixos/modules
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
..
config nixos/networking: Add the FQDN and hostname to /etc/hosts 2020-05-25 14:06:25 +02:00
hardware Merge pull request #73530 from eadwu/nvidia/systemd-pm 2020-05-12 13:54:45 +02:00
i18n/input-method Revert "ibus: fix dconf db installation" 2020-04-24 18:22:59 -04:00
installer Merge pull request #85996 from misuzu/nixos-install-low-memory 2020-05-08 18:40:24 +03:00
misc Update link in /etc/os-release (#85723) 2020-04-22 00:16:22 +02:00
profiles Merge pull request #74378 from ttuegel/lxc-container 2020-04-25 16:25:15 +02:00
programs Merge pull request #86643 from asbachb/zsh-bash-autocomplete 2020-05-19 11:57:25 +02:00
security Merge pull request #87016 from flokli/nsswitch-cleanup 2020-05-14 14:55:43 +02:00
services nixos/ipfs: add startWhenNeeded option 2020-06-12 17:15:27 -05:00
system nixos/binfmt: move systemd-binfmt.service to binfmt module 2020-05-18 11:18:44 +02:00
tasks nixos: Require networking.hostName to be a valid DNS label 2020-05-25 18:13:39 +02:00
testing nixos/service-runner.nix: Allow quotes in commands + test 2020-02-28 14:26:29 +01:00
virtualisation nixos/cri-o: default to upstream pause 2020-05-25 12:27:49 +02:00
module-list.nix Merge pull request #82753 from Kloenk/feature/engelsystem 2020-05-24 16:31:23 +02:00
rename.nix rkt: remove 2020-05-16 09:23:07 +10:00