AndyFilter / YeetMouse

A fork of a fork of the Linux mouse driver with acceleration. Now with GUI and some other improvements!
GNU General Public License v2.0
19 stars 1 forks source link

Add nix flake files #1

Closed kitten closed 2 weeks ago

kitten commented 2 weeks ago

Hiya :wave:

Thanks for making this fork! I've been browsing around the leetmouse repository and noticed this fork, and decided to set your fork up in my system instead of the main leetmouse repo.

Totally not expecting this to be merged, but thought I'd open a PR anyway. I made a little Nix flake to build the driver, GUI, and added a NixOS module to set it up on my system.

Anyway, I just wanted to pop in to leave a PR here in case it does end up being useful.

This is very barebones; and again, not sure if it's wise to open a PR for this, but maybe it does turn out to be useful somehow ✌️

74k1 commented 2 weeks ago

LGTM! & Awesome fork find btw! Looking forward to use this. :)

Q: Why is flake.nix and flake.lock in a separate nix/ directory?

also, noob question about nix, wouldn't that mean I would have to do something like this then:

{
  inputs = {
    yeetmouse.url = "github:AndyFilter/YeetMouse/master?dir=nix";
  };
}

instead of

{
  inputs = {
    yeetmouse.url = "github:AndyFilter/YeetMouse";
  };
}
kitten commented 2 weeks ago

I've placed it in a nix/ folder for now, since this is very much an "unsolicited" PR πŸ˜… so I've modelled it after what wezterm does with a subfolder, to keep the nix files separate and packed away. So, that does indeed mean that ?dir=nix is needed, but it's mostly to keep the files out of sight, depending on whether this will even be merged and whether @AndyFilter is interested in this.

I might move it around though in my own fork, if that fork (of a fork of a fork πŸ˜„) does end up living on

AndyFilter commented 2 weeks ago

Hey!

Your PR looks awesome, I'd love to make the project more accessible to the less technical ones. Though I personally use Ubuntu, and (as one might guess) I am the "less technical one" when it comes to all the Linux stuff. But nonetheless this looks like a huge step in making the program more accessible. I've looked through the files of your PR, and tbh. I have no idea, what's going on there, but I'll make sure everything is safe and sound and I'll think about merging the changes.

Though I have one question at the end. Is the installation process using the files you added automated? I mean it in like, "will people understand how to use it, or does it require an additional instruction in the Readme"?

Again, thank you for your work!

kitten commented 2 weeks ago

I added a small readme to nix/README.md to make sure it's clear how to use this flake. I can move things around of course, but hope this works fine for now πŸ™Œ

74k1 commented 2 weeks ago

I'm getting a nixos-rebuild error when trying to enable yeetmouse in my configuration.nix as per the new README & using the first method of configuring it with

hardware = {
  yeetmouse = {
    enable = true;
    parameters = {
      ScrollsPerTick = 1;
    };
  };
};
error: builder for '/nix/store/8canzikwvagrlr6jhmaiiq59ldlgczim-linux-6.6.54-modules.drv' failed with exit code 1;
       last 3 log lines:
       > created 6 symlinks in user environment
       > inconsistent kernel versions: 6.11.2
       > 6.6.54

I don't understand why it tries to build with the 6.11.2 kernel, when the kernel on the nixos-unstable branch is at 6.6.54..

kitten commented 2 weeks ago

@74k1: Ah, nice catch! Sorry about that πŸ˜… That's what I get for simply copying files from my local setup over. I forgot to adjust the used kernel to boot.kernelPackages.kernel and to change the default to pkgs.linuxPackages.kernel.

That should be done now in the latest commit, and override will now accept a kernel input on the package.

74k1 commented 2 weeks ago

Thanks a lot for the patch! @kitten :+1:

I was able to rebuild my system and got to testing straight away. LGTM :heart:

Kernel Works GUI doesn't (probably just a wayland issue on my end)

kitten commented 2 weeks ago

I did skip some of the patchelf steps, so I just added that. Maybe that was your issue πŸ€” Assuming hardware.opengl/graphics is enabled though it should work. I've been testing on a NixOS Distribution with KDE Plasma 6 on Wayland. The window should open with XWayland.

74k1 commented 2 weeks ago

Good to know. I'm getting the following when I try to run yeetmouse with sudo. Am on Hyprland. When running the yeetmouse gui without sudo, the window shows up.

$ sudo yeetmouse
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
Authorization required, but no authorization protocol specified

GLFW Error 65550: Failed to detect any supported platform
yeetmouse: External/ImGui/imgui.cpp:4432: ImGuiIO& ImGui::GetIO(): Assertion `GImGui != __null && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"' failed.
zsh: IOT instruction  sudo yeetmouse

So again, likely faulty on my end. But thanks for the Troubleshooting.

PR looks really good imo :+1: Very glad we can declare the parameters in nix now. Works like a charm!

AndyFilter commented 2 weeks ago

I've looked on the internet for more information about the issue you (@74k1) experienced (error: XDG_RUNTIME_DIR is invalid or not set in the environment.), and I found some possible solutions. One of the more occurring one was to run the program with some specific environment variables set, like so:

sudo pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "$(pwd)/YeetMouseGui"

(run from the directory gui/, where the YeetMouseGui binary is).

If that doesn't help, I don't really know what will, I've experienced this issue once, and after this error the program would just continue to run normally.

I've tried to reproduce the issue on my (almost) fresh install of Ubuntu 22.04, and it worked with no issues, both on Wayland and Xorg (keep in mind it was on a VM). Therefor I'm gonna pretend like this is a NixOS specific issue for now.

Again, I'm not too experienced with Linux as a whole, and I've never heard about NixOS, so if this is some easy to fix issue, please tell me and we can move on. But I'd like to fix problems like these first.

74k1 commented 2 weeks ago

Hello again

Thank you (@AndyFilter) for the troubleshooting as well. Just wanted to confirm that this issue was only happening on my machine due to bad configuration on my end. I've tested the following just now with the help of my friend and it works! :+1:

All I needed was to use sudo -E to keep my env variables. (like XDG_RUNTIME_DIR for example) and an Authentication Agent for Hyprland as stated here (I didn't have anything polkit related before)

I'm sorry to anyone waiting for the delay of this merge because of me.

AndyFilter commented 2 weeks ago

https://github.com/AndyFilter/YeetMouse/pull/1/files#diff-344adf682bbe2185cd290e6c26804fac7a8153d490ea6895c521806094b5fbd4R38

  --replace "#define NUM_USAGES 32" "#define NUM_USAGES 90"

(sorry, I have no idea how to make cool reference to a file with a preview)

After looking at the code I got a bit curious as to what is this line used for? I know there was an issue where some devices were not being recognized because this value was too small (16), but I don't know what consequences can bring raising this value.

(Also, sorry if I'm being picky, it just looks like an odd addition)

kitten commented 2 weeks ago

Oh, sorry, forgot to remove that from debugging πŸ˜… Let me do another scan of the package.nix and see what to remove

74k1 commented 1 week ago

Hey @kitten Ever since https://github.com/AndyFilter/YeetMouse/commit/a0a28b14e2ae7b6551f35d85191a404e1ce4b543 I've been having the issue that my mouse isn't moving at all when Yeetmouse is enabled. I'm guessing that https://github.com/AndyFilter/YeetMouse/pull/2 should fix this issue?