1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00
nix-darwin/modules/services/ipfs.nix

70 lines
1.8 KiB
Nix
Raw Normal View History

2023-06-18 05:25:24 +00:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.ipfs;
in
{
meta.maintainers = [ "jmmaloney4" ];
options.services.ipfs = {
enable = mkOption {
type = types.bool;
default = false;
2024-04-14 21:02:32 +00:00
description = "Whether to enable the ipfs daemon.";
2023-06-18 05:25:24 +00:00
};
package = mkOption {
2023-08-30 14:14:14 +00:00
type = types.package;
2023-06-18 05:25:24 +00:00
default = pkgs.kubo;
# defaultText = "pkgs.kubo";
2024-04-14 21:02:32 +00:00
description = ''
2023-06-18 05:25:24 +00:00
The ipfs package to use.
'';
};
logFile = mkOption {
type = types.nullOr types.path;
default = null;
2023-08-30 14:14:14 +00:00
example = "/var/tmp/ipfs.log";
2024-04-14 21:02:32 +00:00
description = ''
2023-06-18 05:25:24 +00:00
The logfile to use for the ipfs service. Alternatively
{command}`sudo launchctl debug system/org.nixos.ipfs --stderr`
2023-06-18 05:25:24 +00:00
can be used to stream the logs to a shell after restarting the service with
{command}`sudo launchctl kickstart -k system/org.nixos.ipfs`.
2023-06-18 05:25:24 +00:00
'';
};
ipfsPath = mkOption {
type = types.nullOr types.path;
default = null;
2024-04-14 21:02:32 +00:00
description = "Set the IPFS_PATH environment variable.";
2023-06-18 05:25:24 +00:00
};
enableGarbageCollection = mkOption {
type = types.bool;
default = false;
2024-04-14 21:02:32 +00:00
description = "Passes --enable-gc flag to ipfs daemon.";
2023-06-18 05:25:24 +00:00
};
};
config = mkIf cfg.enable {
2023-08-30 14:14:14 +00:00
environment.systemPackages = [ cfg.package ];
2023-06-18 05:25:24 +00:00
launchd.user.agents.ipfs = {
serviceConfig = {
ProgramArguments = [ "${cfg.package}/bin/ipfs" "daemon" ]
++ optionals (cfg.enableGarbageCollection) [ "--enable-gc" ];
KeepAlive = true;
RunAtLoad = true;
ProcessType = "Background";
StandardOutPath = cfg.logFile;
StandardErrorPath = cfg.logFile;
EnvironmentVariables = {} // (optionalAttrs (cfg.ipfsPath != null) { IPFS_PATH = cfg.ipfsPath; });
};
};
};
}