Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/ydotool: init module #107210

Closed
wants to merge 1 commit into from
Closed

Conversation

kimat
Copy link
Contributor

@kimat kimat commented Dec 19, 2020

Motivation for this change

ydotool requires a daemon to be started for it to be used:

ydotool key a
ydotool: notice: ydotoold backend unavailable (may have latency+delay issues)
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Copy link
Member

@berbiche berbiche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not create a system user that has access to input and run the service with that user?

I personally have this in my configuration to use ydotool with libinput-gestures:

let
  configFile = ...;
in
{
  # https://github.com/NixOS/nixpkgs/issues/70471
  # Chown&chmod /dev/uinput to owner:root group:input mode:0660
  boot.kernelModules = [ "uinput" ];
  services.udev.extraRules = ''
    SUBSYSTEM=="misc", KERNEL=="uinput", TAG+="uaccess", OPTIONS+="static_node=uinput", GROUP="input", MODE="0660"
  '';

  users.users.libinput-gestures = {
    group = "input";
    description = "libinput gestures/gebaard user";
    isSystemUser = true;
    inherit (config.users.users.nobody) home;
  };

  systemd.services.libinput-gestures = {
    description = "Touchpad gesture listener";
    reloadIfChanged = true;

    partOf = [ "graphical.target" ];
    requires = [ "graphical.target" ];
    after = [ "graphical.target" ];
    wantedBy = [ "graphical.target" ];

    serviceConfig = {
      Type = "simple";
      ExecStart = "${pkgs.libinput-gestures}/bin/libinput-gestures -c ${configFile}";
      #ExecStart = "${pkgs.gebaar-libinput}/bin/gebaard";
      #Environment = [ ''"XDG_CONFIG_HOME=${configFile}"'' ];
      User = config.users.users.libinput-gestures.name;
      Group = config.users.users.libinput-gestures.group;
    };
  };
}

@stale
Copy link

stale bot commented Jun 30, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 30, 2021
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 19, 2021
@stale
Copy link

stale bot commented Apr 19, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 19, 2022
@BenediktBroich
Copy link
Contributor

This still needs a daemon.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 20, 2022
@kraem kraem mentioned this pull request Sep 20, 2022
13 tasks
@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 30, 2022
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/1724

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 18, 2023
Comment on lines +6 to +8
meta = {
maintainers = with lib.maintainers; [ kimat ];
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meta is always written last in the expression.

ExecStart = "${pkgs.ydotool}/bin/ydotoold";
Restart = "on-failure";
};
wantedBy = [ "default.target" ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wantedBy = [ "default.target" ];
wantedBy = [ "multi-user.target" ];

services are almost always put under multi-user.target.

config = mkIf cfg.enable {
systemd.user.services.ydotool = {
description = "Ydotool daemon";
path = with pkgs; [ ydotool ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tool re-execs itself, right?

wantedBy = [ "default.target" ];
};

environment.systemPackages = [ pkgs.ydotool ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't systemPackages available in the systemd unit?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Our systemd units specify PATH.

@SuperSandro2000
Copy link
Member

Closing because author did not react in the last year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants