From 7b4ea8d82fdeaa71ab942a8a8f6f8add8afdfad0 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 27 Jan 2024 13:05:49 +0300 Subject: [PATCH] arrpc: add module --- modules/misc/news.nix | 6 ++++++ modules/modules.nix | 1 + modules/services/arrpc.nix | 39 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 modules/services/arrpc.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index a5f6975ab..5d4c99217 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1401,6 +1401,12 @@ in { ''; } + { + time = "2024-02-05T22:33:54+00:00"; + message = '' + A new module is available: 'services.arrpc' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index d798147ef..a75037c0f 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -251,6 +251,7 @@ let ./programs/zsh.nix ./programs/zsh/prezto.nix ./programs/zsh/zsh-abbr.nix + ./services/arrpc.nix ./services/autorandr.nix ./services/avizo.nix ./services/barrier.nix diff --git a/modules/services/arrpc.nix b/modules/services/arrpc.nix new file mode 100644 index 000000000..ec003257b --- /dev/null +++ b/modules/services/arrpc.nix @@ -0,0 +1,39 @@ +{ config, pkgs, lib, ... }: +let + inherit (lib) mkIf mkOption mkPackageOption mkEnableOption types; + + cfg = config.services.arrpc; +in { + meta.maintainers = [ lib.maintainers.NotAShelf ]; + + options.services.arrpc = { + enable = mkEnableOption "arrpc"; + package = mkPackageOption pkgs "arrpc" { }; + + systemdTarget = mkOption { + type = types.str; + default = "graphical-session.target"; + example = "sway-session.target"; + description = '' + Systemd target to bind to. + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.arRPC = { + Unit = { + Description = + "Discord Rich Presence for browsers, and some custom clients"; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = lib.getExe cfg.package; + Restart = "always"; + }; + + Install.WantedBy = [ cfg.systemdTarget ]; + }; + }; +}