| 1 | { |
| 2 | description = "HyprKVM - Hyprland-native software KVM switch"; |
| 3 | |
| 4 | inputs = { |
| 5 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
| 6 | flake-utils.url = "github:numtide/flake-utils"; |
| 7 | rust-overlay = { |
| 8 | url = "github:oxalica/rust-overlay"; |
| 9 | inputs.nixpkgs.follows = "nixpkgs"; |
| 10 | }; |
| 11 | }; |
| 12 | |
| 13 | outputs = { self, nixpkgs, flake-utils, rust-overlay }: |
| 14 | flake-utils.lib.eachDefaultSystem (system: |
| 15 | let |
| 16 | pkgs = import nixpkgs { |
| 17 | inherit system; |
| 18 | overlays = [ rust-overlay.overlays.default ]; |
| 19 | }; |
| 20 | |
| 21 | # Build dependencies |
| 22 | buildDeps = with pkgs; [ |
| 23 | pkg-config |
| 24 | ]; |
| 25 | |
| 26 | # Runtime/library dependencies |
| 27 | libDeps = with pkgs; [ |
| 28 | # Wayland |
| 29 | wayland |
| 30 | wayland-protocols |
| 31 | |
| 32 | # For smithay-client-toolkit |
| 33 | libxkbcommon |
| 34 | |
| 35 | # TLS |
| 36 | openssl |
| 37 | |
| 38 | # GUI (Iced) dependencies |
| 39 | vulkan-loader |
| 40 | libGL |
| 41 | xorg.libX11 |
| 42 | xorg.libXcursor |
| 43 | xorg.libXrandr |
| 44 | xorg.libXi |
| 45 | ]; |
| 46 | |
| 47 | rustToolchain = pkgs.rust-bin.stable.latest.default.override { |
| 48 | extensions = [ "rust-src" "rust-analyzer" ]; |
| 49 | }; |
| 50 | in |
| 51 | { |
| 52 | # Development shell |
| 53 | devShells.default = pkgs.mkShell { |
| 54 | buildInputs = buildDeps ++ libDeps ++ [ |
| 55 | rustToolchain |
| 56 | ]; |
| 57 | |
| 58 | # Set up pkg-config paths |
| 59 | PKG_CONFIG_PATH = pkgs.lib.makeSearchPath "lib/pkgconfig" libDeps; |
| 60 | |
| 61 | # For wayland-scanner |
| 62 | WAYLAND_PROTOCOLS = "${pkgs.wayland-protocols}/share/wayland-protocols"; |
| 63 | |
| 64 | # Graphics library paths for GUI |
| 65 | LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath libDeps; |
| 66 | |
| 67 | shellHook = '' |
| 68 | echo "HyprKVM development shell" |
| 69 | echo "Rust: $(rustc --version)" |
| 70 | echo "" |
| 71 | echo "Run 'cargo build' to compile" |
| 72 | ''; |
| 73 | }; |
| 74 | |
| 75 | # Package (without GUI for smaller binary) |
| 76 | packages.default = pkgs.rustPlatform.buildRustPackage { |
| 77 | pname = "hyprkvm"; |
| 78 | version = "0.5.1"; |
| 79 | src = ./.; |
| 80 | |
| 81 | cargoLock = { |
| 82 | lockFile = ./Cargo.lock; |
| 83 | }; |
| 84 | |
| 85 | nativeBuildInputs = buildDeps; |
| 86 | buildInputs = libDeps; |
| 87 | |
| 88 | # Builds both hyprkvm (daemon) and hyprkvm-ctl (CLI) |
| 89 | # buildRustPackage automatically installs all workspace binaries |
| 90 | |
| 91 | meta = with pkgs.lib; { |
| 92 | description = "Hyprland-native software KVM switch"; |
| 93 | longDescription = '' |
| 94 | HyprKVM enables seamless keyboard/mouse control transfer between |
| 95 | Linux machines running Hyprland. Move past your last workspace |
| 96 | to switch to another machine. |
| 97 | ''; |
| 98 | homepage = "https://github.com/tenseleyFlow/hyprKVM"; |
| 99 | license = licenses.mit; |
| 100 | platforms = platforms.linux; |
| 101 | mainProgram = "hyprkvm"; |
| 102 | }; |
| 103 | }; |
| 104 | |
| 105 | # Package with GUI support |
| 106 | packages.gui = pkgs.rustPlatform.buildRustPackage { |
| 107 | pname = "hyprkvm"; |
| 108 | version = "0.5.1"; |
| 109 | src = ./.; |
| 110 | |
| 111 | cargoLock = { |
| 112 | lockFile = ./Cargo.lock; |
| 113 | }; |
| 114 | |
| 115 | nativeBuildInputs = buildDeps ++ [ pkgs.makeWrapper ]; |
| 116 | buildInputs = libDeps; |
| 117 | |
| 118 | # Build with GUI feature |
| 119 | buildFeatures = [ "gui" ]; |
| 120 | |
| 121 | # Wrap binary to include graphics library paths |
| 122 | postInstall = '' |
| 123 | wrapProgram $out/bin/hyprkvm \ |
| 124 | --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath libDeps} |
| 125 | ''; |
| 126 | |
| 127 | meta = with pkgs.lib; { |
| 128 | description = "Hyprland-native software KVM switch (with GUI)"; |
| 129 | longDescription = '' |
| 130 | HyprKVM enables seamless keyboard/mouse control transfer between |
| 131 | Linux machines running Hyprland. Move past your last workspace |
| 132 | to switch to another machine. |
| 133 | |
| 134 | This package includes the GUI configuration tool. |
| 135 | ''; |
| 136 | homepage = "https://github.com/tenseleyFlow/hyprKVM"; |
| 137 | license = licenses.mit; |
| 138 | platforms = platforms.linux; |
| 139 | mainProgram = "hyprkvm"; |
| 140 | }; |
| 141 | }; |
| 142 | } |
| 143 | ); |
| 144 | } |