at master 1.9 kB view raw
1{ lib, ... }: 2{ 3 name = "kubo"; 4 meta = with lib.maintainers; { 5 maintainers = [ 6 mguentner 7 Luflosi 8 ]; 9 }; 10 11 nodes.machine = 12 { config, ... }: 13 { 14 services.kubo = { 15 enable = true; 16 # Also will add a unix domain socket socket API address, see module. 17 startWhenNeeded = true; 18 settings.Addresses.API = "/ip4/127.0.0.1/tcp/2324"; 19 dataDir = "/mnt/ipfs"; 20 }; 21 users.users.alice = { 22 isNormalUser = true; 23 extraGroups = [ config.services.kubo.group ]; 24 }; 25 }; 26 27 testScript = '' 28 start_all() 29 30 with subtest("Automatic socket activation"): 31 ipfs_hash = machine.succeed( 32 "echo fnord0 | su alice -l -c 'ipfs add --quieter'" 33 ) 34 machine.succeed(f"ipfs cat /ipfs/{ipfs_hash.strip()} | grep fnord0") 35 36 machine.stop_job("ipfs") 37 38 with subtest("IPv4 socket activation"): 39 machine.succeed("ipfs --api /ip4/127.0.0.1/tcp/2324 id") 40 ipfs_hash = machine.succeed( 41 "echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add --quieter" 42 ) 43 machine.succeed(f"ipfs cat /ipfs/{ipfs_hash.strip()} | grep fnord") 44 45 machine.stop_job("ipfs") 46 47 with subtest("Unix domain socket activation"): 48 ipfs_hash = machine.succeed( 49 "echo fnord2 | ipfs --api /unix/run/ipfs.sock add --quieter" 50 ) 51 machine.succeed( 52 f"ipfs --api /unix/run/ipfs.sock cat /ipfs/{ipfs_hash.strip()} | grep fnord2" 53 ) 54 55 machine.stop_job("ipfs") 56 57 with subtest("Socket activation for the Gateway"): 58 machine.succeed( 59 f"curl 'http://127.0.0.1:8080/ipfs/{ipfs_hash.strip()}' | grep fnord2" 60 ) 61 62 with subtest("Setting dataDir works properly with the hardened systemd unit"): 63 machine.succeed("test -e /mnt/ipfs/config") 64 machine.succeed("test ! -e /var/lib/ipfs/") 65 ''; 66}