-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
99 lines (84 loc) · 3.17 KB
/
Copy pathflake.nix
File metadata and controls
99 lines (84 loc) · 3.17 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/5954d3359cc7178623da6c7fd23dc7f7504d7187";
git-hooks.url = "github:cachix/git-hooks.nix";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, git-hooks, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = import nixpkgs { inherit system; };
manet = import ./nix/manet.nix { inherit pkgs; };
manet-fstack = import ./nix/manet.nix { inherit pkgs; useFStack = true; };
python-with-packages = pkgs.python3.withPackages (py-pkgs: [
py-pkgs.jinja2
py-pkgs.lxml
py-pkgs.websockets
]);
in
{
packages = {
default = manet;
inherit manet;
inherit manet-fstack;
};
checks = {
pre-commit = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
actionlint.enable = true;
clang-format.enable = true;
clang-tidy = {
name = "clang-tidy";
enable = true;
entry =
let
# clang-tidy requires the compile_commands.json (from debug):
presets = (
builtins.fromJSON (builtins.readFile ./CMakePresets.json)
).configurePresets;
debugPreset =
builtins.head (builtins.filter (p: p.name == "debug") presets);
# build/debug
buildDir = debugPreset.binaryDir;
# -D{name}={value} for all entries in debugPreset
cmakeFlags = pkgs.lib.concatStringsSep " " (pkgs.lib.mapAttrsToList
(name: value: "-D${name}=${builtins.toString value}")
debugPreset.cacheVariables);
# cmake configure first
script = pkgs.writeShellScriptBin "clang-tidy" ''
set -euo pipefail
${pkgs.cmake}/bin/cmake -S . -B ${buildDir} ${cmakeFlags}
exec ${pkgs.clang-tools}/bin/clang-tidy -p ${buildDir} "$@"
'';
in
"${script}/bin/clang-tidy";
files = "(^CMakePresets\\.json$)|((^|/)CMakeLists\\.txt$)|\\.(c|h|cc|hpp)$";
language = "system";
};
cmake-format.enable = true;
end-of-file-fixer.enable = true;
nixpkgs-fmt.enable = true;
trim-trailing-whitespace.enable = true;
};
};
};
devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [
jq
lcov
python-with-packages
self.checks.${system}.pre-commit.enabledPackages
valgrind
];
inputsFrom = [ manet manet-fstack ];
NIX_ENFORCE_NO_NATIVE = 0;
shellHook = ''
ROOT="$(${pkgs.git}/bin/git rev-parse --show-toplevel)"
${self.checks.${system}.pre-commit.shellHook}
'';
};
};
});
}