-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
80 lines (73 loc) · 2.23 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
{
description = "NQueens solutions";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Utility functions to configure for multiple systems
flake-utils.url = "github:numtide/flake-utils";
};
# `inputs @` allows all the inputs to be accessed later if they're unnamed in the args.
outputs = {
self,
flake-utils,
nixpkgs,
pre-commit-hooks,
...
}:
with flake-utils;
lib.eachSystem [lib.system.aarch64-linux lib.system.x86_64-linux] (system: let
pkgs = import nixpkgs {inherit system;};
in {
# Install devshell packages
devShells.default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit) shellHook;
packages = with pkgs; [
# General formatters/tools
deadnix
nixfmt
nodePackages.prettier
statix
shellcheck
# Generic C++ packages
cmake
gcc
ninja
clang
# Boost is needed for this repo
# (boost159.override { enableStatic = true; })
(boost.override {
enableStatic = true;
enableShared = true;
components = [
"unit_test_framework"
];
})
pkg-config
];
CMAKE_GENERATOR = "Ninja";
};
checks = {
# Add pre-commit-hooks. Note that these only run on the files in a commit unless running `nix flake check`.
pre-commit = pre-commit-hooks.lib.${system}.run {
src = ./.;
default_stages = ["commit"];
hooks = {
# Format any nix files
alejandra.enable = true;
# Lint/format the shell files.
shellcheck.enable = true;
# Format any changed files
# Formatting settings are contained in .clang-format
clang-format = {
enable = true;
types_or = ["c" "c++"];
excludes = ["catch.hpp"];
};
};
};
};
});
}