[GH-ISSUE #80] Feature Proposal: Add lan-mouse to Nix Package Manager #28

Closed
opened 2026-05-05 22:05:18 -06:00 by gitea-mirror · 11 comments
Owner

Originally created by @beyertom on GitHub (Jan 24, 2024).
Original GitHub issue: https://github.com/feschber/lan-mouse/issues/80

I want to propose to add lan-mouse also to the nix package manager and/or home-manager.

I tried to achieve it with a locally defined package:

{
  stdenv,
  fetchCrate,
  rustPlatform,
  fetchFromGitHub,
  lib,
  pkgs,
}:
rustPlatform.buildRustPackage rec {
  pname = "lan-mouse";
  version = "20240124";

  nativeBuildInputs = [pkgs.pkg-config pkgs.cmake];

  buildInputs = [
    pkgs.xorg.libX11
    pkgs.gtk4
    pkgs.libadwaita
    pkgs.xorg.libXtst
  ];

  src = fetchFromGitHub {
    owner = "feschber";
    repo = "lan-mouse";
    rev = "8084b52cfc8c661baa43fbea158e0b44cd0ae203";
    hash = "sha256-6sX2cAL7nVfSyvimqi3Oc5yVUYuSMiYjbRyleo0wKRY=";
  };

  cargoLock.lockFile = "${src}/Cargo.lock";

  cargoLock.outputHashes = {
    "reis-0.1.0" = "sha256-sRZqm6QdmgqfkTjEENV8erQd+0RL5z1+qjdmY18W3bA=";
  };

  # Set Environment Variables
  RUST_BACKTRACE = "full";

  meta = with lib; {
    description = "Lan Mouse is a mouse and keyboard sharing software";
    longDescription = ''
      Lan Mouse is a mouse and keyboard sharing software similar to universal-control on Apple devices. It allows for using multiple pcs with a single set of mouse and keyboard. This is also known as a Software KVM switch.
      The primary target is Wayland on Linux but Windows and MacOS and Linux on Xorg have partial support as well (see below for more details).
    '';
    mainProgram = "lan-mouse";
    platforms = platforms.all;
  };
}

But the build fails:

       >    Compiling itoa v1.0.10
       >    Compiling humantime v2.1.0
       >    Compiling ryu v1.0.16
       >    Compiling tempfile v3.8.1
       >    Compiling async-channel v2.1.1
       > error: failed to run custom build command for `lan-mouse v0.5.0 (/build/source)`
       > note: To improve backtraces for build dependencies, set the CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.
       >
       > Caused by:
       >   process didn't exit successfully: `/build/source/target/release/build/lan-mouse-9f2f7fca0f4f9dcf/build-script-build` (exit status: 101)
       >   --- stderr
       >   thread 'main' panicked at /build/cargo-vendor-dir/glib-build-tools-0.18.0/src/lib.rs:33:10:
       >   called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
       >   stack backtrace:
       >      0:     0x5555555740eb - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h85e32f8f7b08f729
       >      1:     0x5555555a6530 - core::fmt::write::hae1cf5cde4ee2188
       >      2:     0x555555569375 - std::io::Write::write_fmt::h4ae54bff47727b29
       >      3:     0x555555573ec4 - std::sys_common::backtrace::print::hea248a594c5888cf
       >      4:     0x555555574a27 - std::panicking::default_hook::{{closure}}::h545cae1ad29f25d2
       >      5:     0x555555574774 - std::panicking::default_hook::hc1d7fee5faf0cc8a
       >      6:     0x555555574f88 - std::panicking::rust_panic_with_hook::h0e7975574d129b7c
       >      7:     0x555555574e6e - std::panicking::begin_panic_handler::{{closure}}::h420dcc10a77211ab
       >      8:     0x555555574306 - std::sys_common::backtrace::__rust_end_short_backtrace::he6597460302ecd4a
       >      9:     0x555555574bd2 - rust_begin_unwind
       >     10:     0x55555555d445 - core::panicking::panic_fmt::h3cf3338e18ada46e
       >     11:     0x55555555d403 - core::result::unwrap_failed::h22597ad5fa95281f
       >     12:     0x55555555efb0 - core::result::Result<T,E>::unwrap::h3c2a74cbb44f24c8
       >     13:     0x55555555de1e - glib_build_tools::compile_resources::hf7bc486b080714e8
       >     14:     0x555555562fbb - build_script_build::main::h61a7a6bb6051409b
       >     15:     0x555555561493 - core::ops::function::FnOnce::call_once::hc9e72346df2f6a18
       >     16:     0x555555560f26 - std::sys_common::backtrace::__rust_begin_short_backtrace::h8b820a1e1a9c9eb7
       >     17:     0x555555560f79 - std::rt::lang_start::{{closure}}::h531539a55ef140d4
       >     18:     0x555555574ac4 - std::panicking::try::h839c5e98485eaaba
       >     19:     0x55555557e4fb - std::rt::lang_start_internal::h6a4b333c7c2ab7bd
       >     20:     0x555555560f57 - std::rt::lang_start::h5efff1c9729f8d82
       >     21:     0x555555562fd5 - main
       >     22:     0x7ffff7ddc0ce - __libc_start_call_main
       >     23:     0x7ffff7ddc189 - __libc_start_main@GLIBC_2.2.5
       >     24:     0x55555555da95 - _start
       >     25:                0x0 - <unknown>
       > warning: build failed, waiting for other jobs to finish...
       For full logs, run 'nix log /nix/store/h55klm5rwz4phan0q1s3z3rijbhz2xb4-lan-mouse-20240124.drv'.
error: 1 dependencies of derivation '/nix/store/qr1w2a9fcrvwx02vanh4z1bwkab54y4b-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ja7hxw294a1wx10s599g87s9shixf2yv-lan-mouse-20240124-fish-completions.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9v9p30a3x92853n0216iji1q9vg9aaxk-man-paths.drv' failed to build
error: 1 dependencies of derivation '/nix/store/451cdyi0qfwr6iyappf728p5sjz0cxlc-home-manager-generation.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ar077jidk0ba8x9x5vb450kk7vv4fqqn-user-environment.drv' failed to build
error: 1 dependencies of derivation '/nix/store/byjp0n19xxf8s0hd9px9g4f74jkbfhra-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qd4s61ywr33jx8lhvsi28xs5xdbhchby-nixos-system-erde-24.05.20240121.612f972.drv' failed to build

I can compile lan-mouse with a nix-shell defined by this flake:

with import <nixpkgs> {};
  stdenv.mkDerivation {
    name = "rust-env";

    nativeBuildInputs = [pkgs.pkg-config pkgs.cmake pkgs.rustc pkgs.cargo];

    buildInputs = [
      pkgs.xorg.libX11
      pkgs.gtk4
      pkgs.libadwaita
      pkgs.xorg.libXtst
      pkgs.openssl
    ];

    # Set Environment Variables
    RUST_BACKTRACE = 1;
  }

Unfortuneately iam neither a rust nor a nix experst, so i dont understand whats going on.

Originally created by @beyertom on GitHub (Jan 24, 2024). Original GitHub issue: https://github.com/feschber/lan-mouse/issues/80 I want to propose to add lan-mouse also to the nix package manager and/or home-manager. I tried to achieve it with a locally defined package: ```nix { stdenv, fetchCrate, rustPlatform, fetchFromGitHub, lib, pkgs, }: rustPlatform.buildRustPackage rec { pname = "lan-mouse"; version = "20240124"; nativeBuildInputs = [pkgs.pkg-config pkgs.cmake]; buildInputs = [ pkgs.xorg.libX11 pkgs.gtk4 pkgs.libadwaita pkgs.xorg.libXtst ]; src = fetchFromGitHub { owner = "feschber"; repo = "lan-mouse"; rev = "8084b52cfc8c661baa43fbea158e0b44cd0ae203"; hash = "sha256-6sX2cAL7nVfSyvimqi3Oc5yVUYuSMiYjbRyleo0wKRY="; }; cargoLock.lockFile = "${src}/Cargo.lock"; cargoLock.outputHashes = { "reis-0.1.0" = "sha256-sRZqm6QdmgqfkTjEENV8erQd+0RL5z1+qjdmY18W3bA="; }; # Set Environment Variables RUST_BACKTRACE = "full"; meta = with lib; { description = "Lan Mouse is a mouse and keyboard sharing software"; longDescription = '' Lan Mouse is a mouse and keyboard sharing software similar to universal-control on Apple devices. It allows for using multiple pcs with a single set of mouse and keyboard. This is also known as a Software KVM switch. The primary target is Wayland on Linux but Windows and MacOS and Linux on Xorg have partial support as well (see below for more details). ''; mainProgram = "lan-mouse"; platforms = platforms.all; }; } ``` But the build fails: ```sh > Compiling itoa v1.0.10 > Compiling humantime v2.1.0 > Compiling ryu v1.0.16 > Compiling tempfile v3.8.1 > Compiling async-channel v2.1.1 > error: failed to run custom build command for `lan-mouse v0.5.0 (/build/source)` > note: To improve backtraces for build dependencies, set the CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation. > > Caused by: > process didn't exit successfully: `/build/source/target/release/build/lan-mouse-9f2f7fca0f4f9dcf/build-script-build` (exit status: 101) > --- stderr > thread 'main' panicked at /build/cargo-vendor-dir/glib-build-tools-0.18.0/src/lib.rs:33:10: > called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" } > stack backtrace: > 0: 0x5555555740eb - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h85e32f8f7b08f729 > 1: 0x5555555a6530 - core::fmt::write::hae1cf5cde4ee2188 > 2: 0x555555569375 - std::io::Write::write_fmt::h4ae54bff47727b29 > 3: 0x555555573ec4 - std::sys_common::backtrace::print::hea248a594c5888cf > 4: 0x555555574a27 - std::panicking::default_hook::{{closure}}::h545cae1ad29f25d2 > 5: 0x555555574774 - std::panicking::default_hook::hc1d7fee5faf0cc8a > 6: 0x555555574f88 - std::panicking::rust_panic_with_hook::h0e7975574d129b7c > 7: 0x555555574e6e - std::panicking::begin_panic_handler::{{closure}}::h420dcc10a77211ab > 8: 0x555555574306 - std::sys_common::backtrace::__rust_end_short_backtrace::he6597460302ecd4a > 9: 0x555555574bd2 - rust_begin_unwind > 10: 0x55555555d445 - core::panicking::panic_fmt::h3cf3338e18ada46e > 11: 0x55555555d403 - core::result::unwrap_failed::h22597ad5fa95281f > 12: 0x55555555efb0 - core::result::Result<T,E>::unwrap::h3c2a74cbb44f24c8 > 13: 0x55555555de1e - glib_build_tools::compile_resources::hf7bc486b080714e8 > 14: 0x555555562fbb - build_script_build::main::h61a7a6bb6051409b > 15: 0x555555561493 - core::ops::function::FnOnce::call_once::hc9e72346df2f6a18 > 16: 0x555555560f26 - std::sys_common::backtrace::__rust_begin_short_backtrace::h8b820a1e1a9c9eb7 > 17: 0x555555560f79 - std::rt::lang_start::{{closure}}::h531539a55ef140d4 > 18: 0x555555574ac4 - std::panicking::try::h839c5e98485eaaba > 19: 0x55555557e4fb - std::rt::lang_start_internal::h6a4b333c7c2ab7bd > 20: 0x555555560f57 - std::rt::lang_start::h5efff1c9729f8d82 > 21: 0x555555562fd5 - main > 22: 0x7ffff7ddc0ce - __libc_start_call_main > 23: 0x7ffff7ddc189 - __libc_start_main@GLIBC_2.2.5 > 24: 0x55555555da95 - _start > 25: 0x0 - <unknown> > warning: build failed, waiting for other jobs to finish... For full logs, run 'nix log /nix/store/h55klm5rwz4phan0q1s3z3rijbhz2xb4-lan-mouse-20240124.drv'. error: 1 dependencies of derivation '/nix/store/qr1w2a9fcrvwx02vanh4z1bwkab54y4b-home-manager-path.drv' failed to build error: 1 dependencies of derivation '/nix/store/ja7hxw294a1wx10s599g87s9shixf2yv-lan-mouse-20240124-fish-completions.drv' failed to build error: 1 dependencies of derivation '/nix/store/9v9p30a3x92853n0216iji1q9vg9aaxk-man-paths.drv' failed to build error: 1 dependencies of derivation '/nix/store/451cdyi0qfwr6iyappf728p5sjz0cxlc-home-manager-generation.drv' failed to build error: 1 dependencies of derivation '/nix/store/ar077jidk0ba8x9x5vb450kk7vv4fqqn-user-environment.drv' failed to build error: 1 dependencies of derivation '/nix/store/byjp0n19xxf8s0hd9px9g4f74jkbfhra-etc.drv' failed to build error: 1 dependencies of derivation '/nix/store/qd4s61ywr33jx8lhvsi28xs5xdbhchby-nixos-system-erde-24.05.20240121.612f972.drv' failed to build ``` I can compile lan-mouse with a nix-shell defined by this flake: ```nix with import <nixpkgs> {}; stdenv.mkDerivation { name = "rust-env"; nativeBuildInputs = [pkgs.pkg-config pkgs.cmake pkgs.rustc pkgs.cargo]; buildInputs = [ pkgs.xorg.libX11 pkgs.gtk4 pkgs.libadwaita pkgs.xorg.libXtst pkgs.openssl ]; # Set Environment Variables RUST_BACKTRACE = 1; } ``` Unfortuneately iam neither a rust nor a nix experst, so i dont understand whats going on.
Author
Owner

@feschber commented on GitHub (Jan 24, 2024):

Looking at the error, it looks like the glib-compile-resources command is missing:
1e2ab81eb3/glib-build-tools/src/lib.rs (L33)

Do you have the gtk4 development packages as a build dependency?

@ICE-GB I had a quick glance at your fork and you added some NIX-OS related things? Maybe you could help out here?

<!-- gh-comment-id:1908119513 --> @feschber commented on GitHub (Jan 24, 2024): Looking at the error, it looks like the `glib-compile-resources` command is missing: https://github.com/gtk-rs/gtk-rs-core/blob/1e2ab81eb302d4039170ce9948aaee21a7265672/glib-build-tools/src/lib.rs#L33 Do you have the gtk4 development packages as a build dependency? @ICE-GB I had a quick glance at your fork and you added some NIX-OS related things? Maybe you could help out here?
Author
Owner

@beyertom commented on GitHub (Jan 24, 2024):

I added gtk4 as buildInput, so i guess it should be available.

It works in my nix-shell flake with the same buildInput

<!-- gh-comment-id:1908128230 --> @beyertom commented on GitHub (Jan 24, 2024): I added gtk4 as buildInput, so i guess it should be available. It works in my nix-shell flake with the same buildInput
Author
Owner

@feschber commented on GitHub (Jan 24, 2024):

I have no prior experience with nix, but I would guess that you need the gtk4 development package.

<!-- gh-comment-id:1908131907 --> @feschber commented on GitHub (Jan 24, 2024): I have no prior experience with nix, but I would guess that you need the gtk4 development package.
Author
Owner

@beyertom commented on GitHub (Jan 24, 2024):

Thanks for the hint. I got it working:

{
  stdenv,
  fetchCrate,
  rustPlatform,
  fetchFromGitHub,
  lib,
  pkgs,
}:
rustPlatform.buildRustPackage rec {
  pname = "lan-mouse";
  version = "20240124";

  nativeBuildInputs = with pkgs; [
    pkg-config
    cmake
    buildPackages.gtk4
  ];

  buildInputs = with pkgs; [
    xorg.libX11
    gtk4
    libadwaita
    xorg.libXtst
  ];

  src = fetchFromGitHub {
    owner = "feschber";
    repo = "lan-mouse";
    rev = "8084b52cfc8c661baa43fbea158e0b44cd0ae203";
    hash = "sha256-qaPnTbfO1aabm4UsNKHXg/BoEnpNvNgqmIT4+tNG6Tw=";
  };

  cargoLock.lockFile = "${src}/Cargo.lock";

  cargoLock.outputHashes = {
    "reis-0.1.0" = "sha256-sRZqm6QdmgqfkTjEENV8erQd+0RL5z1+qjdmY18W3bA=";
  };

  # Set Environment Variables
  RUST_BACKTRACE = "full";

  meta = with lib; {
    description = "Lan Mouse is a mouse and keyboard sharing software";
    longDescription = ''
      Lan Mouse is a mouse and keyboard sharing software similar to universal-control on Apple devices. It allows for using multiple pcs with a single set of mouse and keyboard. This is also known as a Software KVM switch.
      The primary target is Wayland on Linux but Windows and MacOS and Linux on Xorg have partial support as well (see below for more details).
    '';
    mainProgram = "lan-mouse";
    platforms = platforms.all;
  };
}

I think that can be taken as a base for a nix package.

<!-- gh-comment-id:1908227135 --> @beyertom commented on GitHub (Jan 24, 2024): Thanks for the hint. I got it working: ```nix { stdenv, fetchCrate, rustPlatform, fetchFromGitHub, lib, pkgs, }: rustPlatform.buildRustPackage rec { pname = "lan-mouse"; version = "20240124"; nativeBuildInputs = with pkgs; [ pkg-config cmake buildPackages.gtk4 ]; buildInputs = with pkgs; [ xorg.libX11 gtk4 libadwaita xorg.libXtst ]; src = fetchFromGitHub { owner = "feschber"; repo = "lan-mouse"; rev = "8084b52cfc8c661baa43fbea158e0b44cd0ae203"; hash = "sha256-qaPnTbfO1aabm4UsNKHXg/BoEnpNvNgqmIT4+tNG6Tw="; }; cargoLock.lockFile = "${src}/Cargo.lock"; cargoLock.outputHashes = { "reis-0.1.0" = "sha256-sRZqm6QdmgqfkTjEENV8erQd+0RL5z1+qjdmY18W3bA="; }; # Set Environment Variables RUST_BACKTRACE = "full"; meta = with lib; { description = "Lan Mouse is a mouse and keyboard sharing software"; longDescription = '' Lan Mouse is a mouse and keyboard sharing software similar to universal-control on Apple devices. It allows for using multiple pcs with a single set of mouse and keyboard. This is also known as a Software KVM switch. The primary target is Wayland on Linux but Windows and MacOS and Linux on Xorg have partial support as well (see below for more details). ''; mainProgram = "lan-mouse"; platforms = platforms.all; }; } ``` I think that can be taken as a base for a nix package.
Author
Owner

@beyertom commented on GitHub (Jan 24, 2024):

I don't know if its helpfull for anyone, but i created a local module for lan-mouse with systemd autostart. Maybe someone can use it as an inspiration:

inputs @ {
  options,
  config,
  lib,
  pkgs,
  ...
}:
with lib;
with lib.piperin; let
  cfg = config.piperin.apps.lan-mouse;
in {
  options.piperin.apps.lan-mouse = with types; {
    enable = mkBoolOpt false "Whether or not to enable lan-mouse.";
  };

  config = mkIf cfg.enable {
    systemd.user.services.lan-mouse = {
      description = "Lan Mouse";
      after = ["graphical-session.target"];
      bindsTo = ["graphical-session.target"];
      wantedBy = ["graphical-session.target"];

      serviceConfig = {
        ExecStart = "${pkgs.piperin.lan-mouse}/bin/lan-mouse --daemon";
        Restart = "on-failure";
      };
    };

    environment.systemPackages = with pkgs; [
      piperin.lan-mouse
    ];
  };
}
<!-- gh-comment-id:1908284289 --> @beyertom commented on GitHub (Jan 24, 2024): I don't know if its helpfull for anyone, but i created a local module for lan-mouse with systemd autostart. Maybe someone can use it as an inspiration: ```nix inputs @ { options, config, lib, pkgs, ... }: with lib; with lib.piperin; let cfg = config.piperin.apps.lan-mouse; in { options.piperin.apps.lan-mouse = with types; { enable = mkBoolOpt false "Whether or not to enable lan-mouse."; }; config = mkIf cfg.enable { systemd.user.services.lan-mouse = { description = "Lan Mouse"; after = ["graphical-session.target"]; bindsTo = ["graphical-session.target"]; wantedBy = ["graphical-session.target"]; serviceConfig = { ExecStart = "${pkgs.piperin.lan-mouse}/bin/lan-mouse --daemon"; Restart = "on-failure"; }; }; environment.systemPackages = with pkgs; [ piperin.lan-mouse ]; }; } ```
Author
Owner

@ICE-GB commented on GitHub (Jan 25, 2024):

@ICE-GB I had a quick glance at your fork and you added some NIX-OS related things? Maybe you could help out here?

Sorry, I don't know much about nix and rust either, I can successfully build executables in ubuntu using the nix development environment I added, but I don't have experience building packages, the flake.nix I added is a reference to ironbar

<!-- gh-comment-id:1909597389 --> @ICE-GB commented on GitHub (Jan 25, 2024): > @ICE-GB I had a quick glance at your fork and you added some NIX-OS related things? Maybe you could help out here? Sorry, I don't know much about nix and rust either, I can successfully build executables in ubuntu using the nix development environment I added, but I don't have experience building packages, the flake.nix I added is a reference to ![ironbar](https://github.com/JakeStanger/ironbar)
Author
Owner

@ICE-GB commented on GitHub (Jan 25, 2024):

I don't know if its helpfull for anyone, but i created a local module for lan-mouse with systemd autostart. Maybe someone can use it as an inspiration:

Thanks for your work, it looks good and helpful.

<!-- gh-comment-id:1909607150 --> @ICE-GB commented on GitHub (Jan 25, 2024): > I don't know if its helpfull for anyone, but i created a local module for lan-mouse with systemd autostart. Maybe someone can use it as an inspiration: Thanks for your work, it looks good and helpful.
Author
Owner

@ICE-GB commented on GitHub (Jan 26, 2024):

I created a new branch nix-module added packages and homeManagerModule, it worked for me, hopefully it will help others!

<!-- gh-comment-id:1911366393 --> @ICE-GB commented on GitHub (Jan 26, 2024): I created a new [branch nix-module](https://github.com/ICE-GB/lan-mouse/tree/nix-module) added packages and homeManagerModule, it worked for me, hopefully it will help others!
Author
Owner

@feschber commented on GitHub (Jan 26, 2024):

Feel free to open a PR!

<!-- gh-comment-id:1911812552 --> @feschber commented on GitHub (Jan 26, 2024): Feel free to open a PR!
Author
Owner

@dudman commented on GitHub (Feb 9, 2024):

Would like to try this out on my new nixos, but I'm new to nixos and having trouble understanding how to install this flake. How long might it be until its included in rolling ? Thanks

<!-- gh-comment-id:1936338097 --> @dudman commented on GitHub (Feb 9, 2024): Would like to try this out on my new nixos, but I'm new to nixos and having trouble understanding how to install this flake. How long might it be until its included in rolling ? Thanks
Author
Owner

@feschber commented on GitHub (Feb 9, 2024):

I hope, I can find the time next week.
I'm Currently a little busy with exams and assignments...

<!-- gh-comment-id:1936433053 --> @feschber commented on GitHub (Feb 9, 2024): I hope, I can find the time next week. I'm Currently a little busy with exams and assignments...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/lan-mouse#28
No description provided.