mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 12:19:07 +00:00
plover: init service
This commit is contained in:
parent
142f9857a7
commit
998f408fb2
94
modules/home-manager/services/plover.nix
Normal file
94
modules/home-manager/services/plover.nix
Normal file
@ -0,0 +1,94 @@
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.plover;
|
||||
|
||||
toPloverINI = with lib;
|
||||
generators.toINI {
|
||||
mkKeyValue = generators.mkKeyValueDefault {
|
||||
mkValueString = v:
|
||||
if v == true then
|
||||
"True"
|
||||
else if v == false then
|
||||
"False"
|
||||
else
|
||||
generators.mkValueStringDefault { } v;
|
||||
} " = ";
|
||||
};
|
||||
|
||||
ploverIniFormat = { }: {
|
||||
type = (pkgs.formats.ini { }).type;
|
||||
generate = name: value: pkgs.writeText name (toPloverINI value);
|
||||
};
|
||||
|
||||
settingsFormat = ploverIniFormat { };
|
||||
in {
|
||||
options.services.plover = {
|
||||
enable = lib.mkEnableOption "Plover stenography engine service";
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
description = -"The derivation containing the binaries for the service.";
|
||||
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 =
|
||||
"Extra command-line arguments to pass to <literal>plover</literal>";
|
||||
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}"
|
||||
cfg.settings;
|
||||
|
||||
systemd.user.services.plover = {
|
||||
Unit = {
|
||||
Description = "Plover stenography engine";
|
||||
Documentation = [ "https://github.com/openstenoproject/plover/wiki/" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = "${cfg.package}/bin/plover ${
|
||||
lib.concatStringsSep " " cfg.extraOptions
|
||||
}";
|
||||
};
|
||||
|
||||
Install.WantedBy = [ "default.target" ];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user