-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
78 lines (65 loc) · 2.04 KB
/
flake.nix
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
{
description = "Rigol DP832 TUI";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
advisory-db.url = "github:rustsec/advisory-db";
advisory-db.flake = false;
};
outputs = {
self,
advisory-db,
nixpkgs,
crane,
flake-utils,
}:
nixpkgs.lib.recursiveUpdate
(flake-utils.lib.eachSystem [
"aarch64-darwin"
"aarch64-linux"
"x86_64-linux"
] (system: let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.mkLib pkgs;
cargoToml = nixpkgs.lib.importTOML ./dp832/Cargo.toml;
inherit (cargoToml.package) version;
pname = cargoToml.package.name;
src = craneLib.cleanCargoSource self;
buildInputs = nixpkgs.lib.optional pkgs.stdenv.isDarwin pkgs.libiconv;
cargoArtifacts = craneLib.buildDepsOnly {
inherit src buildInputs pname version;
};
in {
packages.default = craneLib.buildPackage {
inherit cargoArtifacts src buildInputs pname version;
};
apps.default = {
type = "app";
program = "${self.packages.${system}.default}/bin/dp832";
};
checks = let
nixSrc = nixpkgs.lib.sources.sourceFilesBySuffices self [".nix"];
in {
pkg = self.packages.${system}.default;
audit = craneLib.cargoAudit {
inherit src advisory-db;
};
clippy = craneLib.cargoClippy {
inherit cargoArtifacts src pname version;
cargoClippyExtraArgs = "-- --deny warnings";
};
rustfmt = craneLib.cargoFmt {
inherit cargoArtifacts src pname version;
};
alejandra = pkgs.runCommand "alejandra" {} ''
${pkgs.alejandra}/bin/alejandra --check ${nixSrc}
touch $out
'';
};
})) {
overlays.default = final: prev: {
dp832 = self.packages.${prev.system}.default;
};
};
}