feat: HomeManager | enable notifications for yubikey touch required
This commit is contained in:
@@ -69,6 +69,7 @@
|
|||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
modules = [
|
modules = [
|
||||||
./home-manager/home.nix
|
./home-manager/home.nix
|
||||||
|
./modules/home-manager/yubikey-touch-detector.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ in {
|
|||||||
# Enable home-manager
|
# Enable home-manager
|
||||||
programs.home-manager.enable = true;
|
programs.home-manager.enable = true;
|
||||||
|
|
||||||
|
services.yubikey-touch-detector.enable = true;
|
||||||
|
|
||||||
# Nicely reload system units when changing configs
|
# Nicely reload system units when changing configs
|
||||||
systemd.user.startServices = "sd-switch";
|
systemd.user.startServices = "sd-switch";
|
||||||
}
|
}
|
||||||
|
|||||||
65
modules/home-manager/yubikey-touch-detector.nix
Normal file
65
modules/home-manager/yubikey-touch-detector.nix
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.yubikey-touch-detector;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.yubikey-touch-detector = {
|
||||||
|
enable = mkEnableOption "a tool to detect when your YubiKey is waiting for a touch";
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.yubikey-touch-detector;
|
||||||
|
defaultText = "pkgs.yubikey-touch-detector";
|
||||||
|
description = ''
|
||||||
|
Package to use. Binary is expected to be called "yubikey-touch-detector".
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.enable = mkEnableOption "starting the process only when the socket is used";
|
||||||
|
|
||||||
|
extraArgs = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [ "--libnotify" ];
|
||||||
|
defaultText = literalExpression ''[ "--libnotify" ]'';
|
||||||
|
description = ''
|
||||||
|
Extra arguments to pass to the tool. The arguments are not escaped.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
|
# Service description licensed under ISC
|
||||||
|
# See https://github.com/maximbaz/yubikey-touch-detector/blob/c9fdff7163361d6323e2de0449026710cacbc08a/LICENSE
|
||||||
|
# Author: Maxim Baz
|
||||||
|
systemd.user.sockets.yubikey-touch-detector = mkIf cfg.socket.enable {
|
||||||
|
Unit.Description = "Unix socket activation for YubiKey touch detector service";
|
||||||
|
Socket = {
|
||||||
|
ListenFIFO = "%t/yubikey-touch-detector.sock";
|
||||||
|
RemoveOnStop = true;
|
||||||
|
SocketMode = "0660";
|
||||||
|
};
|
||||||
|
Install.WantedBy = [ "sockets.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Same license thing for the description here
|
||||||
|
systemd.user.services.yubikey-touch-detector = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Detects when your YubiKey is waiting for a touch";
|
||||||
|
Requires = optionals cfg.socket.enable [ "yubikey-touch-detector.socket" ];
|
||||||
|
};
|
||||||
|
Service = {
|
||||||
|
ExecStart = "${cfg.package}/bin/yubikey-touch-detector ${concatStringsSep " " cfg.extraArgs}";
|
||||||
|
Environment = [ "PATH=${lib.makeBinPath [ pkgs.gnupg ]}" ];
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = "1sec";
|
||||||
|
};
|
||||||
|
Install.Also = optionals cfg.socket.enable [ "yubikey-touch-detector.socket" ];
|
||||||
|
Install.WantedBy = [ "default.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user