nix-config/modules/optional/streamdeck.nix
Patrick 11764d5850
feat: systemd upgrade
feat: streamdeck ui config
2023-09-18 17:27:54 +02:00

61 lines
1.7 KiB
Nix

{
lib,
pkgs,
...
}: let
inherit
(lib)
types
mkEnableOption
mkPackageOption
mkOption
mkIf
;
settingsFormat = pkgs.formats.json {};
in {
# broken on nixpkgs currently. How fun
programs.streamdeck-ui.enable = true;
home-manager.sharedModules = [
({config, ...}: {
options.programs.streamdeck-ui = {
enable = mkEnableOption "streamdeck-ui";
package = mkPackageOption pkgs "streamdeck-ui" {};
autoStart = mkOption {
default = true;
type = types.bool;
description = "Whether streamdeck-ui should be started automatically";
};
settings = mkOption {
default = {};
type = types.submodule {freeformType = settingsFormat.type;};
description = "Configuration per streamdeck";
};
};
config = mkIf config.programs.streamdeck-ui.enable {
home.sessionVariables.STREAMDECK_UI_CONFIG = "${config.xdg.configHome}/streamdeck-ui/config.json";
xdg.configFile.streamdeck-ui = {
target = "streamdeck-ui/config.json";
source = settingsFormat.generate "config.json" {
streamdeck_ui_version = 1;
state = config.programs.streamdeck-ui.settings;
};
};
systemd.user.services = mkIf config.programs.streamdeck-ui.autoStart {
streamdeck-ui = {
Unit = {
Description = "Start streamdeck-ui";
};
Service = {
ExecStart = "${config.programs.streamdeck-ui.package}/bin/streamdeck-ui --no-ui";
};
Install = {
WantedBy = ["default.target"];
};
};
};
};
})
];
}