2022-08-28 15:42:46 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.netbird;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.netbird = {
|
2024-04-14 21:02:32 +00:00
|
|
|
enable = mkEnableOption "Netbird daemon";
|
2022-08-28 15:42:46 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.netbird;
|
|
|
|
defaultText = literalExpression "pkgs.netbird";
|
2024-04-14 21:02:32 +00:00
|
|
|
description = "The package to use for netbird";
|
2022-08-28 15:42:46 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
launchd.daemons.netbird = {
|
|
|
|
script = ''
|
|
|
|
mkdir -p /var/run/netbird /var/lib/netbird
|
|
|
|
exec ${cfg.package}/bin/netbird service run
|
|
|
|
'';
|
|
|
|
serviceConfig = {
|
|
|
|
EnvironmentVariables = {
|
|
|
|
NB_CONFIG = "/var/lib/netbird/config.json";
|
|
|
|
NB_LOG_FILE = "console";
|
|
|
|
};
|
|
|
|
KeepAlive = true;
|
|
|
|
RunAtLoad = true;
|
|
|
|
StandardOutPath = "/var/log/netbird.out.log";
|
|
|
|
StandardErrorPath = "/var/log/netbird.err.log";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|