-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathflake.nix
More file actions
141 lines (117 loc) · 4.56 KB
/
flake.nix
File metadata and controls
141 lines (117 loc) · 4.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
{
nixConfig = {
extra-trusted-substituters = [ "https://nix-community.cachix.org" ];
extra-trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ];
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; # Latest stable release
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
};
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs@{ self, fenix, crane, flake-parts, advisory-db, ... }:
flake-parts.lib.mkFlake { inherit self inputs; } ({ withSystem, ... }: {
systems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
perSystem = { lib, config, self', inputs', pkgs, system, ... }:
let
rustToolchain = fenix.packages.${system}.stable.toolchain;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
# File filters for including additional files in the build
includeFileFilter = path: type:
let
# Define file extensions to include
extensions = [ "md" "json" "proto" ];
# Check if path matches any of the extensions
matchesExtension = builtins.any (ext:
builtins.match (".*\\." + ext + "$") path != null
) extensions;
in
matchesExtension || (craneLib.filterCargoSources path type);
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
commonArgs = {
src = lib.cleanSourceWith {
src = ./.;
filter = includeFileFilter;
name = "source";
};
pname = "rs1090";
version = version;
nativeBuildInputs = with pkgs; [
pkg-config
openssl
python3
bzip2
# soapysdr
protobuf
] ++ lib.optionals pkgs.stdenv.isLinux [
lld
rustPlatform.bindgenHook # issue with stdbool.h on nix flake check
];
buildInputs = with pkgs; [
# soapysdr
] ++ lib.optionals pkgs.stdenv.isDarwin [
libiconv
];
# Minimal environment
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
RUSTFLAGS = lib.optionalString pkgs.stdenv.isLinux
"-C linker=${pkgs.gcc}/bin/gcc -C link-arg=--verbose";
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in
{
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self.checks;
buildInputs = with pkgs; [ rustToolchain pkg-config openssl ] ++
commonArgs.buildInputs;
nativeBuildInputs = commonArgs.nativeBuildInputs;
};
packages = {
default = self'.packages.jet1090;
jet1090 = craneLib.buildPackage (commonArgs // {
pname = "jet1090";
cargoExtraFlags = "--features rtlsdr,ssh,sero -p jet1090";
meta.mainProgram = "jet1090";
inherit cargoArtifacts;
# disable the default check phase (which includes doctests)
# On macOS, we need to run checks to ensure compatibility
# On Linux, we disable checks due to linking issues at the
# doctest stage. (TODO work on a fix for this)
doCheck = pkgs.stdenv.isDarwin;
});
};
checks =
{
fmt = craneLib.cargoFmt (commonArgs);
# audit = craneLib.cargoAudit (commonArgs // { inherit advisory-db; });
rustdoc = craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; });
clippy-check = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-features -- --deny warnings";
});
test-check = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
});
}
# build packages as part of the checks
// (lib.mapAttrs' (key: value: lib.nameValuePair (key + "-package") value) self'.packages);
formatter = pkgs.nixpkgs-fmt;
};
});
}