Skip to content

Commit

Permalink
feat: expose .debug option
Browse files Browse the repository at this point in the history
The new option allows running xremap with upstream's debug logging enabled
  • Loading branch information
VTimofeenko committed Dec 5, 2023
1 parent 1bfd363 commit 41e158d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Following `services.xremap` options are exposed:
* `deviceName` – the name of the device to be used. To find out the name, you can check `/proc/bus/input/devices`
* `watch` – whether to watch for new devices
* `mouse` – whether to watch for mice by default
* `debug` – enables debug logging for xremap

See examples in `nixosConfigurations` inside flake.nix.

Expand Down
2 changes: 2 additions & 0 deletions homeManagerModules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let
cfg = config.services.xremap;
localLib = localFlake.localLib { inherit pkgs lib cfg; };
inherit (localLib) mkExecStart configFile;
inherit (lib) optionalString;
in
{
options.services.xremap = localLib.commonOptions;
Expand All @@ -18,6 +19,7 @@ in
Type = "simple";
ExecStart = mkExecStart configFile;
Restart = "always";
Environment = optionalString cfg.debug "RUST_LOG=debug";
};
Install.WantedBy = [ "graphical-session.target" ];
};
Expand Down
1 change: 1 addition & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ in
example = [ "--completions zsh" ];
description = "Extra arguments for xremap";
};
debug = mkEnableOption "run xremap with RUST_LOG=debug in case upstream needs logs";
};
configFile = pkgs.writeTextFile {
name = "xremap-config.yml";
Expand Down
2 changes: 2 additions & 0 deletions modules/system-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
let
cfg = config.services.xremap;
userPath = "/run/user/${toString cfg.userId}";
inherit (lib) optionalString;
in
{
systemd.services.xremap = lib.mkIf (cfg.serviceMode == "system") {
description = "xremap system service";
path = [ cfg.package ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Environment = optionalString cfg.debug "RUST_LOG=debug";
PrivateNetwork = true;
MemoryDenyWriteExecute = true;
CapabilityBoundingSet = [ "~CAP_SETUID" "~CAP_SETGID" "~CAP_SETPCAP" "~CAP_SYS_ADMIN" "~CAP_SYS_PTRACE" "~CAP_NET_ADMIN" "~CAP_FOWNER" "~CAP_IPC_OWNER" "~CAP_SYS_TIME" "~CAP_KILL" "~CAP_SYS_BOOT" "~CAP_LINUX_IMMUTABLE" "~CAP_IPC_LOCK" "~CAP_SYS_CHROOT" "~CAP_BLOCK_SUSPEND" "~CAP_SYS_PACCT" "~CAP_WAKE_ALARM" "~CAP_AUDIT_WRITE" "~CAP_AUDIT_CONTROL" "~CAP_AUDIT_READ" "CAP_DAC_READ_SEARCH" "CAP_DAC_OVERRIDE" ];
Expand Down
3 changes: 2 additions & 1 deletion modules/user-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{ pkgs, lib, config, ... }:

let
inherit (lib) optionalString;
cfg = config.services.xremap;
in
{
Expand Down Expand Up @@ -48,7 +49,7 @@ in
LockPersonality = true;
UMask = "077";
RestrictAddressFamilies = "AF_UNIX";
# Environment = "RUST_LOG=debug";
Environment = optionalString cfg.debug "RUST_LOG=debug";
ExecStart = mkExecStart configFile;
};
};
Expand Down

0 comments on commit 41e158d

Please sign in to comment.