-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
94 lines (80 loc) · 2.56 KB
/
Copy pathflake.nix
File metadata and controls
94 lines (80 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{
description = "Securely share and access USB devices over the internet using Iroh and USBIP";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
# Clean source using Crane's helper
src = craneLib.cleanCargoSource ./.;
# Define build arguments shared between dependency build and actual package
commonArgs = {
inherit src;
strictDeps = true;
nativeBuildInputs = [
pkgs.pkg-config
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
(pkgs.writeShellScriptBin "sw_vers" ''
echo "14.5"
'')
];
buildInputs = [
pkgs.libusb1
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
];
};
# Cache dependencies separately
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
pname = "iroh-usbip-deps";
});
# Build the actual crate
iroh-usbip = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
});
in
{
packages.default = iroh-usbip;
devShells.default = pkgs.mkShell {
inputsFrom = [ iroh-usbip ];
packages = [
rustToolchain
pkgs.pkg-config
pkgs.libusb1
pkgs.just
pkgs.git-cliff
pkgs.gh
pkgs.python3
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
pkgs.usbutils
];
IROH_USBIP_IN_DEV_SHELL = "1";
};
checks = {
inherit iroh-usbip;
clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
fmt = craneLib.cargoFmt {
inherit src;
};
test = craneLib.cargoTest (commonArgs // {
inherit cargoArtifacts;
});
};
});
}