athens/services/ipfs-darwin.nix

49 lines
1.1 KiB
Nix
Raw Normal View History

{ 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";
};
};
};
config = mkIf cfg.enable {
2023-03-15 15:56:51 -04:00
environment.systemPackages = [ cfg.package ];
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
'';
serviceConfig = {
KeepAlive = true;
RunAtLoad = true;
2023-03-15 15:56:51 -04:00
ProcessType = "Background";
StandardErrorPath = cfg.logFile;
StandardOutPath = cfg.logFile;
};
};
};
}