From 8127799f79ee96129b295d78294f40a54078131f Mon Sep 17 00:00:00 2001 From: Nicolas Berbiche Date: Wed, 13 Jan 2021 19:56:32 -0500 Subject: [PATCH] sxhkd: configurable package and command line arguments Fixes #1598. --- modules/services/sxhkd.nix | 16 +++++++++++++++- tests/modules/services/sxhkd/configuration.nix | 7 ++++--- tests/modules/services/sxhkd/service.nix | 6 ++++-- 3 files changed, 23 insertions(+), 6 deletions(-) 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'