mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-08-17 00:20:44 +03:00
module: add spacebar service
This commit is contained in:
parent
c5f7cee0ed
commit
7ebda10e40
@ -51,6 +51,7 @@
|
|||||||
./services/privoxy
|
./services/privoxy
|
||||||
./services/redis
|
./services/redis
|
||||||
./services/skhd
|
./services/skhd
|
||||||
|
./services/spacebar
|
||||||
./services/synapse-bt.nix
|
./services/synapse-bt.nix
|
||||||
./services/synergy
|
./services/synergy
|
||||||
./services/yabai
|
./services/yabai
|
||||||
|
74
modules/services/spacebar/default.nix
Normal file
74
modules/services/spacebar/default.nix
Normal file
@ -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}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@ -121,6 +121,7 @@ let
|
|||||||
tests.services-offlineimap = makeTest ./tests/services-offlineimap.nix;
|
tests.services-offlineimap = makeTest ./tests/services-offlineimap.nix;
|
||||||
tests.services-privoxy = makeTest ./tests/services-privoxy.nix;
|
tests.services-privoxy = makeTest ./tests/services-privoxy.nix;
|
||||||
tests.services-skhd = makeTest ./tests/services-skhd.nix;
|
tests.services-skhd = makeTest ./tests/services-skhd.nix;
|
||||||
|
tests.services-spacebar = makeTest ./tests/services-spacebar.nix;
|
||||||
tests.services-synapse-bt = makeTest ./tests/services-synapse-bt.nix;
|
tests.services-synapse-bt = makeTest ./tests/services-synapse-bt.nix;
|
||||||
tests.services-synergy = makeTest ./tests/services-synergy.nix;
|
tests.services-synergy = makeTest ./tests/services-synergy.nix;
|
||||||
tests.services-yabai = makeTest ./tests/services-yabai.nix;
|
tests.services-yabai = makeTest ./tests/services-yabai.nix;
|
||||||
|
27
tests/services-spacebar.nix
Normal file
27
tests/services-spacebar.nix
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
spacebar = pkgs.runCommand "spacebar-0.0.0" {} "mkdir $out";
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
services.spacebar.enable = true;
|
||||||
|
services.spacebar.package = spacebar;
|
||||||
|
services.spacebar.config = { background_color = "0xff202020"; };
|
||||||
|
services.spacebar.extraConfig = ''echo "spacebar config loaded..."'';
|
||||||
|
|
||||||
|
test = ''
|
||||||
|
echo >&2 "checking spacebar service in ~/Library/LaunchAgents"
|
||||||
|
grep "org.nixos.spacebar" ${config.out}/user/Library/LaunchAgents/org.nixos.spacebar.plist
|
||||||
|
grep "${spacebar}/bin/spacebar" ${config.out}/user/Library/LaunchAgents/org.nixos.spacebar.plist
|
||||||
|
|
||||||
|
conf=`sed -En '/<string>-c<\/string>/{n; s/\s+?<\/?string>//g; p;}' \
|
||||||
|
${config.out}/user/Library/LaunchAgents/org.nixos.spacebar.plist`
|
||||||
|
|
||||||
|
echo >&2 "checking config in $conf"
|
||||||
|
grep "spacebar -m config background_color 0xff202020" $conf
|
||||||
|
grep "spacebar config loaded..." $conf
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user