summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorcmacrae <hi@cmacr.ae>2020-05-14 15:09:40 +0100
committercmacrae <hi@cmacr.ae>2020-05-14 19:41:28 +0100
commit7ebda10e402468bf7f67ddb235c05a8836c92c14 (patch)
tree6c5cd248e847a46cdd99d63fad89b16a11c61bdf /modules
parentc5f7cee0edff41b235c81f94c4e846a87e62002e (diff)
module: add spacebar service
Diffstat (limited to 'modules')
-rw-r--r--modules/module-list.nix1
-rw-r--r--modules/services/spacebar/default.nix74
2 files changed, 75 insertions, 0 deletions
diff --git a/modules/module-list.nix b/modules/module-list.nix
index bbe8e67..e639c02 100644
--- a/modules/module-list.nix
+++ b/modules/module-list.nix
@@ -51,6 +51,7 @@
./services/privoxy
./services/redis
./services/skhd
+ ./services/spacebar
./services/synapse-bt.nix
./services/synergy
./services/yabai
diff --git a/modules/services/spacebar/default.nix b/modules/services/spacebar/default.nix
new file mode 100644
index 0000000..51ea998
--- /dev/null
+++ b/modules/services/spacebar/default.nix
@@ -0,0 +1,74 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.services.spacebar;
+
+ toSpacebarConfig = opts:
+ concatStringsSep "\n" (mapAttrsToList
+ (p: v: "spacebar -m config ${p} ${toString v}") opts);
+
+ configFile = mkIf (cfg.config != {} || cfg.extraConfig != "")
+ "${pkgs.writeScript "spacebarrc" (
+ (if (cfg.config != {})
+ then "${toSpacebarConfig cfg.config}"
+ else "")
+ + optionalString (cfg.extraConfig != "") cfg.extraConfig)}";
+in
+
+{
+ options = with types; {
+ services.spacebar.enable = mkOption {
+ type = bool;
+ default = false;
+ description = "Whether to enable the spacebar spacebar.";
+ };
+
+ services.spacebar.package = mkOption {
+ type = path;
+ description = "The spacebar package to use.";
+ };
+
+ services.spacebar.config = mkOption {
+ type = attrs;
+ default = {};
+ example = literalExample ''
+ {
+ clock_format = "%R";
+ background_color = "0xff202020";
+ foreground_color = "0xffa8a8a8";
+ }
+ '';
+ description = ''
+ Key/Value pairs to pass to spacebar's 'config' domain, via the configuration file.
+ '';
+ };
+
+ services.spacebar.extraConfig = mkOption {
+ type = str;
+ default = "";
+ example = literalExample ''
+ echo "spacebar config loaded..."
+ '';
+ description = ''
+ Extra arbitrary configuration to append to the configuration file.
+ '';
+ };
+ };
+
+ config = mkIf (cfg.enable) {
+ environment.systemPackages = [ cfg.package ];
+
+ launchd.user.agents.spacebar = {
+ serviceConfig.ProgramArguments = [ "${cfg.package}/bin/spacebar" ]
+ ++ optionals (cfg.config != {} || cfg.extraConfig != "") [ "-c" configFile ];
+
+ serviceConfig.KeepAlive = true;
+ serviceConfig.RunAtLoad = true;
+ serviceConfig.EnvironmentVariables = {
+ PATH = "${cfg.package}/bin:${config.environment.systemPath}";
+ };
+ };
+ };
+}