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