Some checks failed
CI / build (push) Has been cancelled
CI / check (push) Has been cancelled
CI / test (macos-latest) (push) Has been cancelled
CI / test (ubuntu-latest) (push) Has been cancelled
CI / test (windows-latest) (push) Has been cancelled
CI / docs (push) Has been cancelled
- Add flake.nix with package (including examples) and dev shell - Track Cargo.lock (removed from .gitignore) as required by the nix build - Change debug_assert! to assert! in UsbIpResponse::to_bytes() so invariant checks fire in release mode, fixing the byte_serialize_invalid_usbip_ret_submit #[should_panic] test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
65 lines
1.6 KiB
Nix
65 lines
1.6 KiB
Nix
{
|
|
description = "A library to run USB/IP server";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
rustc
|
|
cargo
|
|
pkg-config
|
|
];
|
|
|
|
buildInputs = with pkgs; [
|
|
libusb1
|
|
] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [
|
|
udev
|
|
];
|
|
|
|
usbip = pkgs.rustPlatform.buildRustPackage {
|
|
pname = "usbip";
|
|
version = "0.8.0";
|
|
|
|
src = self;
|
|
|
|
cargoHash = "sha256-PiJvE9CWbNIZif/ku3G+A7g5vSzl2O80a33NZdgmFL4=";
|
|
|
|
inherit nativeBuildInputs buildInputs;
|
|
|
|
buildFeatures = [ "serde" ];
|
|
|
|
# Build both the library and all examples
|
|
cargoBuildFlags = [ "--examples" ];
|
|
|
|
postInstall = ''
|
|
for f in target/*/release/examples/{hid_keyboard,cdc_acm_serial,host}; do
|
|
[ -f "$f" ] && install -Dm755 "$f" "$out/bin/$(basename $f)"
|
|
done
|
|
'';
|
|
|
|
meta = with pkgs.lib; {
|
|
description = "A library to run USB/IP server";
|
|
homepage = "https://github.com/jiegec/usbip";
|
|
license = licenses.mit;
|
|
mainProgram = "host";
|
|
};
|
|
};
|
|
in
|
|
{
|
|
packages = {
|
|
default = usbip;
|
|
inherit usbip;
|
|
};
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
inherit nativeBuildInputs buildInputs;
|
|
};
|
|
});
|
|
}
|