diff --git a/modules/services/sxhkd.nix b/modules/services/sxhkd.nix
index d9f0a968..f36cc9d6 100644
--- a/modules/services/sxhkd.nix
+++ b/modules/services/sxhkd.nix
@@ -22,6 +22,20 @@ in
options.services.sxhkd = {
enable = mkEnableOption "simple X hotkey daemon";
+ package = mkOption {
+ type = types.package;
+ default = pkgs.sxhkd;
+ defaultText = "pkgs.sxhkd";
+ description = "Package containing the sxhkd executable.";
+ };
+
+ extraOptions = mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ description = "Command line arguments to invoke sxhkd with.";
+ example = literalExample ''[ "-m 1" ]'';
+ };
+
keybindings = mkOption {
type = types.attrsOf (types.nullOr types.str);
default = {};
@@ -75,7 +89,7 @@ in
+ "${config.home.profileDirectory}/bin"
+ optionalString (cfg.extraPath != "") ":"
+ cfg.extraPath;
- ExecStart = "${pkgs.sxhkd}/bin/sxhkd";
+ ExecStart = "${cfg.package}/bin/sxhkd ${toString cfg.extraOptions}";
};
Install = {
diff --git a/tests/modules/services/sxhkd/configuration.nix b/tests/modules/services/sxhkd/configuration.nix
index 03206a8d..e9d85477 100644
--- a/tests/modules/services/sxhkd/configuration.nix
+++ b/tests/modules/services/sxhkd/configuration.nix
@@ -3,6 +3,10 @@
services.sxhkd = {
enable = true;
+ package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out" // {
+ outPath = "@sxhkd@";
+ };
+
keybindings = {
"super + a" = "run command a";
"super + b" = null;
@@ -19,9 +23,6 @@
'';
};
- nixpkgs.overlays =
- [ (self: super: { sxhkd = pkgs.writeScriptBin "dummy-sxhkd" ""; }) ];
-
nmt.script = ''
sxhkdrc=home-files/.config/sxhkd/sxhkdrc
diff --git a/tests/modules/services/sxhkd/service.nix b/tests/modules/services/sxhkd/service.nix
index 9b4fd70c..ee29b998 100644
--- a/tests/modules/services/sxhkd/service.nix
+++ b/tests/modules/services/sxhkd/service.nix
@@ -1,8 +1,10 @@
-{ config, ... }:
+{ config, pkgs, ... }:
{
config = {
services.sxhkd = {
enable = true;
+ package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out" // { outPath = "@sxhkd@"; };
+ extraOptions = [ "-m 1" ];
extraPath = "/home/the-user/bin:/extra/path/bin";
};
@@ -11,7 +13,7 @@
assertFileExists $serviceFile
- assertFileRegex $serviceFile 'ExecStart=.*/bin/sxhkd'
+ assertFileRegex $serviceFile 'ExecStart=@sxhkd@/bin/sxhkd -m 1'
assertFileRegex $serviceFile \
'Environment=PATH=.*\.nix-profile/bin:/home/the-user/bin:/extra/path/bin'