2023-10-02 06:26:11 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2022-03-09 13:06:27 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.plover;
|
|
|
|
|
|
|
|
toPloverINI = with lib;
|
|
|
|
generators.toINI {
|
2022-11-19 03:05:31 +00:00
|
|
|
mkKeyValue = generators.mkKeyValueDefault
|
|
|
|
{
|
|
|
|
mkValueString = v:
|
|
|
|
if v == true then
|
|
|
|
"True"
|
|
|
|
else if v == false then
|
|
|
|
"False"
|
|
|
|
else
|
|
|
|
generators.mkValueStringDefault { } v;
|
|
|
|
} " = ";
|
2022-03-09 13:06:27 +00:00
|
|
|
};
|
|
|
|
|
2022-11-19 03:05:31 +00:00
|
|
|
ploverIniFormat = {}: {
|
2022-03-09 13:06:27 +00:00
|
|
|
type = (pkgs.formats.ini { }).type;
|
|
|
|
generate = name: value: pkgs.writeText name (toPloverINI value);
|
|
|
|
};
|
|
|
|
|
|
|
|
settingsFormat = ploverIniFormat { };
|
2022-11-19 03:05:31 +00:00
|
|
|
in
|
|
|
|
{
|
2022-03-09 13:06:27 +00:00
|
|
|
options.services.plover = {
|
|
|
|
enable = lib.mkEnableOption "Plover stenography engine service";
|
|
|
|
|
|
|
|
package = lib.mkOption {
|
|
|
|
type = lib.types.package;
|
2023-07-27 03:13:39 +00:00
|
|
|
description = "The derivation containing the binaries for the service.";
|
2022-03-09 13:06:27 +00:00
|
|
|
default = pkgs.plover.dev;
|
|
|
|
defaultText = "pkgs.plover.dev";
|
|
|
|
example = lib.literalExpression "pkgs.plover.stable";
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = lib.mkOption {
|
|
|
|
type = settingsFormat.type;
|
|
|
|
description = "Configuration to be used for the application.";
|
|
|
|
default = { };
|
|
|
|
defaultText = lib.literalExpression "{}";
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
{
|
|
|
|
"Output Configuration" = {
|
|
|
|
undo_levels = 100;
|
|
|
|
};
|
|
|
|
|
|
|
|
"Stroke Display" = {
|
|
|
|
show = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = lib.mkOption {
|
|
|
|
type = with lib.types; listOf str;
|
|
|
|
description =
|
2023-07-27 03:13:39 +00:00
|
|
|
"Extra command-line arguments to pass to {command}`plover`";
|
2022-03-09 13:06:27 +00:00
|
|
|
default = [ ];
|
|
|
|
defaultText = lib.literalExpression "[]";
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
[ "--gui none" ]
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.plover" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
xdg.configFile."plover/plover.cfg".source =
|
|
|
|
settingsFormat.generate "plover-config-${config.home.username}"
|
2022-11-19 03:05:31 +00:00
|
|
|
cfg.settings;
|
2022-03-09 13:06:27 +00:00
|
|
|
|
|
|
|
systemd.user.services.plover = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Plover stenography engine";
|
|
|
|
Documentation = [ "https://github.com/openstenoproject/plover/wiki/" ];
|
2022-04-06 02:48:29 +00:00
|
|
|
PartOf = "default.target";
|
2022-03-09 13:06:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
ExecStart = "${cfg.package}/bin/plover ${
|
|
|
|
lib.concatStringsSep " " cfg.extraOptions
|
|
|
|
}";
|
|
|
|
};
|
|
|
|
|
|
|
|
Install.WantedBy = [ "default.target" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|