-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add nix support(#80) * chore: nix flake update * update actions
- Loading branch information
Showing
9 changed files
with
306 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Binary Cache | ||
|
||
on: [push, pull_request, workflow_dispatch] | ||
jobs: | ||
nix: | ||
name: "Build" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- uses: DeterminateSystems/nix-installer-action@main | ||
with: | ||
logger: pretty | ||
- uses: DeterminateSystems/magic-nix-cache-action@main | ||
- uses: cachix/cachix-action@v14 | ||
with: | ||
name: lan-mouse | ||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | ||
|
||
- name: Build lan-mouse | ||
run: nix build --print-build-logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
/target | ||
.gdbinit | ||
.idea/ | ||
.vs/ | ||
.vs/ | ||
.vscode/ | ||
.direnv/ | ||
result |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
description = "Nix Flake for lan-mouse"; | ||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||
rust-overlay = { | ||
url = "github:oxalica/rust-overlay"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
outputs = { | ||
self, | ||
nixpkgs, | ||
rust-overlay, | ||
... | ||
}: let | ||
inherit (nixpkgs) lib; | ||
genSystems = lib.genAttrs [ | ||
"x86_64-linux" | ||
]; | ||
pkgsFor = system: | ||
import nixpkgs { | ||
inherit system; | ||
|
||
overlays = [ | ||
rust-overlay.overlays.default | ||
]; | ||
}; | ||
mkRustToolchain = pkgs: | ||
pkgs.rust-bin.stable.latest.default.override { | ||
extensions = ["rust-src"]; | ||
}; | ||
pkgs = genSystems (system: import nixpkgs {inherit system;}); | ||
in { | ||
packages = genSystems (system: rec { | ||
default = pkgs.${system}.callPackage ./nix {}; | ||
lan-mouse = default; | ||
}); | ||
homeManagerModules.default = import ./nix/hm-module.nix self; | ||
devShells = genSystems (system: let | ||
pkgs = pkgsFor system; | ||
rust = mkRustToolchain pkgs; | ||
in { | ||
default = pkgs.mkShell { | ||
packages = with pkgs; [ | ||
rust | ||
rust-analyzer-unwrapped | ||
pkg-config | ||
xorg.libX11 | ||
gtk4 | ||
libadwaita | ||
xorg.libXtst | ||
]; | ||
|
||
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library"; | ||
}; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Nix Flake Usage | ||
|
||
## run | ||
|
||
```bash | ||
nix run github:feschber/lan-mouse | ||
|
||
# with params | ||
nix run github:feschber/lan-mouse -- --help | ||
|
||
``` | ||
|
||
## home-manager module | ||
|
||
add input | ||
|
||
```nix | ||
inputs = { | ||
lan-mouse.url = "github:feschber/lan-mouse"; | ||
} | ||
``` | ||
|
||
enable lan-mouse | ||
|
||
``` nix | ||
{ | ||
inputs, | ||
... | ||
}: { | ||
# add the home manager module | ||
imports = [inputs.lan-mouse.homeManagerModules.default]; | ||
programs.lan-mouse = { | ||
enable = true; | ||
# systemd = false; | ||
# package = inputs.lan-mouse.packages.${pkgs.stdenv.hostPlatform.system}.default | ||
}; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
rustPlatform, | ||
lib, | ||
pkgs, | ||
}: | ||
rustPlatform.buildRustPackage { | ||
pname = "lan-mouse"; | ||
version = "0.6.0"; | ||
|
||
nativeBuildInputs = with pkgs; [ | ||
pkg-config | ||
cmake | ||
buildPackages.gtk4 | ||
]; | ||
|
||
buildInputs = with pkgs; [ | ||
xorg.libX11 | ||
gtk4 | ||
libadwaita | ||
xorg.libXtst | ||
]; | ||
|
||
src = builtins.path { | ||
name = "lan-mouse"; | ||
path = lib.cleanSource ../.; | ||
}; | ||
|
||
cargoLock.lockFile = ../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; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
self: { | ||
config, | ||
pkgs, | ||
lib, | ||
... | ||
}: | ||
with lib; let | ||
cfg = config.programs.lan-mouse; | ||
defaultPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default; | ||
in { | ||
options.programs.lan-mouse = with types; { | ||
enable = mkEnableOption "Whether or not to enable lan-mouse."; | ||
package = mkOption { | ||
type = with types; nullOr package; | ||
default = defaultPackage; | ||
defaultText = literalExpression "inputs.lan-mouse.packages.${pkgs.stdenv.hostPlatform.system}.default"; | ||
description = '' | ||
The lan-mouse package to use. | ||
By default, this option will use the `packages.default` as exposed by this flake. | ||
''; | ||
}; | ||
systemd = mkOption { | ||
type = types.bool; | ||
default = pkgs.stdenv.isLinux; | ||
description = "Whether to enable to systemd service for lan-mouse."; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
systemd.user.services.lan-mouse = lib.mkIf cfg.systemd { | ||
Unit = { | ||
Description = "Systemd service for Lan Mouse"; | ||
Requires = ["graphical-session.target"]; | ||
}; | ||
Service = { | ||
Type = "simple"; | ||
ExecStart = "${cfg.package}/bin/lan-mouse --daemon"; | ||
}; | ||
Install.WantedBy = [ | ||
(lib.mkIf config.wayland.windowManager.hyprland.systemd.enable "hyprland-session.target") | ||
(lib.mkIf config.wayland.windowManager.sway.systemd.enable "sway-session.target") | ||
]; | ||
}; | ||
|
||
home.packages = [ | ||
cfg.package | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default |