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/libinput: separate settings by mouse/touchpad #108909

Merged
merged 3 commits into from Jan 21, 2021
Merged

nixos/libinput: separate settings by mouse/touchpad #108909

merged 3 commits into from Jan 21, 2021

Conversation

thiagokokada
Copy link
Contributor

@thiagokokada thiagokokada commented Jan 10, 2021

This PR deprecates services.xserver.libinput for multiple settings, one for each kind of device:

  • services.xserver.libinput.mouse
  • services.xserver.libinput.touchpad

Looking at man 4 libinput, they basically have the same options so I simply replicated them, even if some options doesn't make sense for mouse (tapping for example).

With this commit this is now possible:

{
  services.xserver.libinput = {
    enable = true;
    mouse = {
      accelProfile = "flat";
    };
    touchpad = {
      naturalScrolling = true;
    };
  };
}

And you will have a mouse with no natural scrolling but with accel profile flat, while touchpad will have natural scrolling but accel profile adaptative (default).

It is possible to support more device types (tablets/keyboards/touchscreens), but at least looking at the
libinput manual for those devices it doesn't seem that it has any configuration options for them. They can still be configured using services.xserver.inputClassSections though, and this will work now since there is no rule by default that matches them.

Closes issue #75007, while also making configuration of mouses and touchpads using Nix attrs possible like said in PR #73785.

Alternative for #107676. This is a more elegant solution, but the other PR is much simpler, so I think both approaches are valid. So I will keep both, and closes the other one after one is merged.

Motivation for this change
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.

@thiagokokada
Copy link
Contributor Author

Rebased and tried to reduce the diff as maximum as possible to make the review easier.

@thiagokokada
Copy link
Contributor Author

/marvin opt-in
/status needs_reviewer

@marvin-mk2 marvin-mk2 bot added the marvin label Jan 11, 2021
@marvin-mk2
Copy link

marvin-mk2 bot commented Jan 11, 2021

Hi! I'm an experimental bot. My goal is to guide this PR through its stages, hopefully ending with a merge. You can read up on the usage here.

@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/440

${cfg.additionalOptions}
EndSection
'';
services.xserver.inputClassSections = [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As a side effect of using inputClassSections instead of config here, this now works as it should:

{
    xserver = {
      enable = true;
      libinput = {
        enable = true;
        mouse = {
          naturalScrolling = true;
        };
      };
    };

    inputClassSections = [
      ''
        Identifier "natural scrolling"
        MatchIsPointer "on"
        Option "NaturalScrolling" "on"
      ''
    ];
}

You will have Natural Scrolling in a mouse in this case.

And while this may be strange, it is important to cover the cases like PR #90635 (that was reverted later). So even if we set something by default in mouse/touchpad, the user can always overwrite (this is isn't true nowadays since you can't overwrite a config with inputClassSections).

@thiagokokada
Copy link
Contributor Author

thiagokokada commented Jan 12, 2021

CC @eadwu @Twey @pwetzel Since they were involved with PR #90635, and I believe this PR here also cover their use case.

Also CC @sylv-io @worldofpeace Since they're the authors of PR ##72774 #73785.


mkConfigForDevice = deviceType: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not every option makes sense for mouse and touchpad here, so probably we will need some mkIf deviceType == "touchpad" and mkIf deviceType == "mouse". But I think this can be fixed in another PR since there isn't any clear documentation if option X is never applied for Y device.

Copy link
Member

Choose a reason for hiding this comment

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

I think I'd prefer adding the type-specific options not here but where we use the function, like touchpad = mkConfigForDevice "touchpad" // { tapToClick = mkOption …; };

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this makes sense. Once this PR is merged I will look at it.

@worldofpeace
Copy link
Contributor

Hi @thiagokokada I'm actually really interested in your PR, but my brain is like 🧻 rn so I don't think I can make a good review. Maybe @lheckemann?

Copy link
Member

@lheckemann lheckemann left a comment

Choose a reason for hiding this comment

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

I think this needs a release notes entry, since (correct me if I'm wrong) settings that would previously apply to mice no longer will with this change. Overall LGTM.


mkConfigForDevice = deviceType: {
Copy link
Member

Choose a reason for hiding this comment

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

I think I'd prefer adding the type-specific options not here but where we use the function, like touchpad = mkConfigForDevice "touchpad" // { tapToClick = mkOption …; };

This commits deprecates `services.xserver.libinput` for multiple
settings, one for each kind of device:

- `services.xserver.libinput.mouse`
- `services.xserver.libinput.touchpad`

Looking at `man 4 libinput`, they basically have the same options so I
simply replicated them, even if some options doesn't make sense for
mouse (`tapping` for example).

With this commit this is now possible:

```nix
{
  services.xserver.libinput = {
    enable = true;
    mouse = {
      accelProfile = "flat";
    };
    touchpad = {
      naturalScrolling = true;
    };
  };
}
```

And you will have a mouse with no natural scrolling but with accel
profile flat, while touchpad will have natural scrolling but accel
profile adaptative (default).

It is possible to support more device types
(tablets/keyboards/touchscreens), but at least looking at the
libinput manual for those devices it doesn't seem that it has any
configuration options for them. They can still be configured using
`services.xserver.inputClassSections` though, and this will work now
since there is no rule by default that matches them.

Closes issue #75007, while also making configuration of mouses and
touchpads using Nix attrs possible like said in PR #73785.
@thiagokokada
Copy link
Contributor Author

Documentation done (needed a rebase to avoid conflicts).

@lheckemann Can you please review again?

@thiagokokada
Copy link
Contributor Author

@lheckemann Sorry to bother you, but can you review this PR again?

@marvin-mk2
Copy link

marvin-mk2 bot commented Jan 19, 2021

Reminder: Please review!

This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR will be should be put back in the needs_reviewer queue in one day.


Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually.

@lheckemann lheckemann merged commit 5153dee into NixOS:master Jan 21, 2021
@thiagokokada thiagokokada deleted the libinput-by-device-type branch January 21, 2021 18:36
@flokli
Copy link
Contributor

flokli commented Jan 21, 2021

Do we want to provide mkRenamedOptionModule entries, like we usually do when moving things around?

I updated my nixpkgs checkout, and then got the following error message:

The option `services.xserver.libinput.tappingDragLock' does not exist. Definition values:
- In `/etc/nixos/modules/profiles/xserver.nix':
    {
      _type = "if";
      condition = true;
      content = false;
    }

I mean, I figured out how to migrate, but usually we do this where feasible.

@thiagokokada
Copy link
Contributor Author

@flokli Well, sorry, I was sure that I had made those renames but it seems I forgot it 😿 .

I will open a PR to fix this. Probably separate from #110350 since this is should be merged ASAP.

@flokli
Copy link
Contributor

flokli commented Jan 21, 2021

Thanks!

@thiagokokada
Copy link
Contributor Author

@flokli Wait, yeah, I did them: https://github.com/NixOS/nixpkgs/pull/108909/files#diff-27164ac6e7f2a68c13050fa6e230c23671056d1357c534e79bb1d2969110bddeR214-R231

Well, let me investigate why they're not working. I have some tests in my #110350 branch, so this will make it easier.

@thiagokokada
Copy link
Contributor Author

thiagokokada commented Jan 21, 2021

Whoops, found the issue. Only tappingDragLock was missing.

Ok, opening the PR ASAP.

@thiagokokada
Copy link
Contributor Author

Fixed it here: #110403

berberman pushed a commit to berberman/nixpkgs that referenced this pull request Jan 22, 2021
eadwu added a commit to eadwu/nixos-configuration that referenced this pull request Jan 25, 2021
mnacamura added a commit to mnacamura/etc-nixos that referenced this pull request May 1, 2021
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

5 participants