1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

sxhkd: configurable package and command line arguments

Fixes #1598.
This commit is contained in:
Nicolas Berbiche 2021-01-13 19:56:32 -05:00 committed by Robert Helgesson
parent 4b772fd698
commit 8127799f79
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
3 changed files with 23 additions and 6 deletions

View file

@ -22,6 +22,20 @@ in
options.services.sxhkd = { options.services.sxhkd = {
enable = mkEnableOption "simple X hotkey daemon"; enable = mkEnableOption "simple X hotkey daemon";
package = mkOption {
type = types.package;
default = pkgs.sxhkd;
defaultText = "pkgs.sxhkd";
description = "Package containing the <command>sxhkd</command> executable.";
};
extraOptions = mkOption {
type = types.listOf types.str;
default = [ ];
description = "Command line arguments to invoke <command>sxhkd</command> with.";
example = literalExample ''[ "-m 1" ]'';
};
keybindings = mkOption { keybindings = mkOption {
type = types.attrsOf (types.nullOr types.str); type = types.attrsOf (types.nullOr types.str);
default = {}; default = {};
@ -75,7 +89,7 @@ in
+ "${config.home.profileDirectory}/bin" + "${config.home.profileDirectory}/bin"
+ optionalString (cfg.extraPath != "") ":" + optionalString (cfg.extraPath != "") ":"
+ cfg.extraPath; + cfg.extraPath;
ExecStart = "${pkgs.sxhkd}/bin/sxhkd"; ExecStart = "${cfg.package}/bin/sxhkd ${toString cfg.extraOptions}";
}; };
Install = { Install = {

View file

@ -3,6 +3,10 @@
services.sxhkd = { services.sxhkd = {
enable = true; enable = true;
package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out" // {
outPath = "@sxhkd@";
};
keybindings = { keybindings = {
"super + a" = "run command a"; "super + a" = "run command a";
"super + b" = null; "super + b" = null;
@ -19,9 +23,6 @@
''; '';
}; };
nixpkgs.overlays =
[ (self: super: { sxhkd = pkgs.writeScriptBin "dummy-sxhkd" ""; }) ];
nmt.script = '' nmt.script = ''
sxhkdrc=home-files/.config/sxhkd/sxhkdrc sxhkdrc=home-files/.config/sxhkd/sxhkdrc

View file

@ -1,8 +1,10 @@
{ config, ... }: { config, pkgs, ... }:
{ {
config = { config = {
services.sxhkd = { services.sxhkd = {
enable = true; enable = true;
package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out" // { outPath = "@sxhkd@"; };
extraOptions = [ "-m 1" ];
extraPath = "/home/the-user/bin:/extra/path/bin"; extraPath = "/home/the-user/bin:/extra/path/bin";
}; };
@ -11,7 +13,7 @@
assertFileExists $serviceFile assertFileExists $serviceFile
assertFileRegex $serviceFile 'ExecStart=.*/bin/sxhkd' assertFileRegex $serviceFile 'ExecStart=@sxhkd@/bin/sxhkd -m 1'
assertFileRegex $serviceFile \ assertFileRegex $serviceFile \
'Environment=PATH=.*\.nix-profile/bin:/home/the-user/bin:/extra/path/bin' 'Environment=PATH=.*\.nix-profile/bin:/home/the-user/bin:/extra/path/bin'