Add bt-agent

This commit is contained in:
Alexander Bantyev 2022-02-04 12:56:03 +03:00
parent 75d30f7bf4
commit 9b44287df7
Signed by: balsoft
GPG Key ID: E081FF12ADCB4AD5
3 changed files with 44 additions and 0 deletions

View File

@ -36,6 +36,11 @@
environment.sessionVariables.WINEPREFIX = "/home/balsoft/.local/share/wineprefixes/default";
services.bt-agent = {
enable = true;
capability = "NoInputNoOutput";
};
persist = {
enable = true;
cache.clean.enable = false; # Scary...

38
modules/bt-agent.nix Normal file
View File

@ -0,0 +1,38 @@
{ config, pkgs, lib, ... }: {
options.services.bt-agent = with lib; {
enable = mkEnableOption "Bluetooth authentication agent";
package = mkOption {
default = pkgs.bluez-tools;
type = types.package;
};
capability = mkOption {
default = "DisplayYesNo";
description = "Agent capability";
type = types.enum [
"DisplayOnly"
"DisplayYesNo"
"KeyboardOnly"
"NoInputNoOutput"
];
};
pinFile = mkOption {
default = null;
type = types.nullOr types.path;
description = "Path to the PIN's file";
};
};
config = let
cfg = config.services.bt-agent;
args = [ "--capability=${cfg.capability}" ]
++ lib.optional (!isNull cfg.pinFile) "--pin=${cfg.pinFile}";
in lib.mkIf cfg.enable {
systemd.services.bt-agent = {
path = [ cfg.package ];
serviceConfig.Type = "forking";
serviceConfig.KillSignal = "SIGKILL";
script = "bt-agent -d ${lib.escapeShellArgs args}";
wantedBy = [ "bluetooth.target" ];
after = [ "bluetooth.service" ];
};
};
}

View File

@ -7,6 +7,7 @@
secrets
secrets-envsubst
persist
bt-agent
# PROFILES