2022-11-13 17:39:35 -05:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.ipfs;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.ipfs = {
|
|
|
|
enable = mkEnableOption "Enable kubo on darwin";
|
2023-03-15 15:56:51 -04:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.kubo_carmirror;
|
|
|
|
defaultText = literalExpression "pkgs.kubo";
|
|
|
|
description = "The package to use for kubo";
|
|
|
|
};
|
|
|
|
|
|
|
|
logFile = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = "/var/tmp/ipfs.log";
|
|
|
|
description = "Absolute path to log stderr / stdout";
|
|
|
|
};
|
2022-11-13 17:39:35 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2023-03-15 15:56:51 -04:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
2022-11-13 17:39:35 -05:00
|
|
|
|
|
|
|
launchd.user.agents.ipfs = {
|
2023-03-15 15:56:51 -04:00
|
|
|
path = [ cfg.package ];
|
2022-11-17 22:39:47 -05:00
|
|
|
script = ''
|
|
|
|
if ! test -e $HOME/.ipfs/version; then
|
2023-03-15 15:56:51 -04:00
|
|
|
${cfg.package}/bin/ipfs init
|
2022-11-17 22:39:47 -05:00
|
|
|
fi
|
2023-03-15 15:56:51 -04:00
|
|
|
${cfg.package}/bin/ipfs daemon --migrate
|
2022-11-17 22:39:47 -05:00
|
|
|
'';
|
2022-11-13 17:39:35 -05:00
|
|
|
serviceConfig = {
|
|
|
|
KeepAlive = true;
|
|
|
|
RunAtLoad = true;
|
2023-03-15 15:56:51 -04:00
|
|
|
ProcessType = "Background";
|
|
|
|
StandardErrorPath = cfg.logFile;
|
|
|
|
StandardOutPath = cfg.logFile;
|
2022-11-13 17:39:35 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|