2023-04-14 00:43:41 +00:00
|
|
|
{ lib, ...} : {
|
2022-07-24 18:49:05 +00:00
|
|
|
name = "kubo";
|
2023-04-14 00:43:41 +00:00
|
|
|
meta = with lib.maintainers; {
|
2023-04-13 23:49:48 +00:00
|
|
|
maintainers = [ mguentner Luflosi ];
|
2016-11-26 19:07:01 +00:00
|
|
|
};
|
|
|
|
|
2023-04-14 14:37:32 +00:00
|
|
|
nodes.machine = { config, ... }: {
|
2022-07-24 18:49:05 +00:00
|
|
|
services.kubo = {
|
2020-05-08 09:48:47 +00:00
|
|
|
enable = true;
|
2020-06-17 20:19:01 +00:00
|
|
|
# Also will add a unix domain socket socket API address, see module.
|
|
|
|
startWhenNeeded = true;
|
2022-10-04 10:44:48 +00:00
|
|
|
settings.Addresses.API = "/ip4/127.0.0.1/tcp/2324";
|
2022-03-17 15:40:54 +00:00
|
|
|
dataDir = "/mnt/ipfs";
|
2020-05-08 09:48:47 +00:00
|
|
|
};
|
2023-04-14 00:26:32 +00:00
|
|
|
users.users.alice = {
|
|
|
|
isNormalUser = true;
|
2023-04-14 14:37:32 +00:00
|
|
|
extraGroups = [ config.services.kubo.group ];
|
2023-04-14 00:26:32 +00:00
|
|
|
};
|
2016-11-26 19:07:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2020-05-08 09:48:47 +00:00
|
|
|
start_all()
|
2017-08-30 13:20:10 +00:00
|
|
|
|
2023-04-14 00:26:32 +00:00
|
|
|
with subtest("Automatic socket activation"):
|
|
|
|
ipfs_hash = machine.succeed(
|
|
|
|
"echo fnord0 | su alice -l -c 'ipfs add --quieter'"
|
|
|
|
)
|
|
|
|
machine.succeed(f"ipfs cat /ipfs/{ipfs_hash.strip()} | grep fnord0")
|
|
|
|
|
|
|
|
machine.stop_job("ipfs")
|
|
|
|
|
2023-04-14 00:46:22 +00:00
|
|
|
with subtest("IPv4 socket activation"):
|
|
|
|
machine.succeed("ipfs --api /ip4/127.0.0.1/tcp/2324 id")
|
|
|
|
ipfs_hash = machine.succeed(
|
|
|
|
"echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add --quieter"
|
|
|
|
)
|
|
|
|
machine.succeed(f"ipfs cat /ipfs/{ipfs_hash.strip()} | grep fnord")
|
2020-06-11 21:59:38 +00:00
|
|
|
|
2020-06-17 20:19:01 +00:00
|
|
|
machine.stop_job("ipfs")
|
|
|
|
|
2023-04-14 00:46:22 +00:00
|
|
|
with subtest("Unix domain socket activation"):
|
|
|
|
ipfs_hash = machine.succeed(
|
|
|
|
"echo fnord2 | ipfs --api /unix/run/ipfs.sock add --quieter"
|
|
|
|
)
|
|
|
|
machine.succeed(
|
|
|
|
f"ipfs --api /unix/run/ipfs.sock cat /ipfs/{ipfs_hash.strip()} | grep fnord2"
|
|
|
|
)
|
2022-03-17 15:40:54 +00:00
|
|
|
|
2023-12-02 23:50:53 +00:00
|
|
|
machine.stop_job("ipfs")
|
|
|
|
|
|
|
|
with subtest("Socket activation for the Gateway"):
|
|
|
|
machine.succeed(
|
|
|
|
f"curl 'http://127.0.0.1:8080/ipfs/{ipfs_hash.strip()}' | grep fnord2"
|
|
|
|
)
|
|
|
|
|
2023-04-14 00:46:22 +00:00
|
|
|
with subtest("Setting dataDir works properly with the hardened systemd unit"):
|
|
|
|
machine.succeed("test -e /mnt/ipfs/config")
|
|
|
|
machine.succeed("test ! -e /var/lib/ipfs/")
|
2020-05-08 09:48:47 +00:00
|
|
|
'';
|
2023-04-14 00:43:41 +00:00
|
|
|
}
|