-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathflake.nix
93 lines (81 loc) · 2.69 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{
description = "Tool for pointing out issues in Nixpkgs packages";
inputs = {
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, flake-compat, nixpkgs, utils }: {
overlays = {
default =
final:
prev:
{
nixpkgs-hammering =
let
rust-checks = prev.rustPlatform.buildRustPackage {
pname = "rust-checks";
version = (prev.lib.importTOML ./rust-checks/Cargo.toml).package.version;
src = ./rust-checks;
cargoLock.lockFile = ./rust-checks/Cargo.lock;
};
# Find all of the binaries installed by rust-checks. Note, if this changes
# in the future to use wrappers or something else that pollute the bin/
# directory, this logic will have to grow.
rust-check-names = let
binContents = builtins.readDir "${rust-checks}/bin";
in
prev.lib.mapAttrsToList (name: type: assert type == "regular"; name) binContents;
in
prev.runCommand "nixpkgs-hammering" {
buildInputs = with prev; [
python3
makeWrapper
];
passthru = {
inherit rust-checks;
exePath = "/bin/nixpkgs-hammer";
};
} ''
install -D ${./tools/nixpkgs-hammer} $out/bin/nixpkgs-hammer
patchShebangs $out/bin/nixpkgs-hammer
wrapProgram "$out/bin/nixpkgs-hammer" \
--prefix PATH ":" ${prev.lib.makeBinPath [
prev.nix
rust-checks
]} \
--set AST_CHECK_NAMES ${prev.lib.concatStringsSep ":" rust-check-names}
cp -r ${./overlays} $out/overlays
cp -r ${./lib} $out/lib
'';
};
};
} // utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs { inherit system; };
in {
packages = rec {
default = nixpkgs-hammering;
nixpkgs-hammering = (self.overlays.default pkgs pkgs).nixpkgs-hammering;
};
apps = rec {
nixpkgs-hammer = utils.lib.mkApp {
drv = self.packages.${system}.nixpkgs-hammering;
};
default = nixpkgs-hammer;
};
devShells = {
default =
pkgs.mkShell {
buildInputs = with pkgs; [
python3
rustc
cargo
rust-analyzer
];
};
};
});
}