-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
95 lines (88 loc) · 3.21 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
94
95
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nci.url = "github:yusdacra/nix-cargo-integration";
nci.inputs.nixpkgs.follows = "nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix.url = "github:numtide/treefmt-nix";
pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.flake-parts.flakeModules.easyOverlay
inputs.treefmt-nix.flakeModule
inputs.nci.flakeModule
inputs.pre-commit-hooks-nix.flakeModule
];
systems = ["x86_64-linux" "aarch64-darwin" "aarch64-linux"];
perSystem = {
system,
config,
pkgs,
...
}: {
treefmt = {
projectRootFile = "flake.nix";
programs.alejandra.enable = true;
programs.rustfmt.enable = true;
};
formatter = config.treefmt.build.wrapper;
pre-commit.check.enable = false;
pre-commit.settings = let
simplehook = cmd: {
enable = true;
name = cmd;
description = "Run ${cmd}";
entry = cmd;
pass_filenames = false;
};
in {
# fixed by running "nix fmt", see "treefmt"
hooks.alejandra.enable = true;
hooks.rustfmt.enable = true;
hooks.deadnix.enable = true;
hooks.cargocheck = simplehook "cargo check";
hooks.myclippy = simplehook "cargo clippy";
hooks.mytest = simplehook "cargo test";
};
nci = {
toolchainConfig = ./rust-toolchain.toml;
projects."fc-search".path = ./.;
crates."fc-search" = {
export = true;
depsDrvConfig.mkDerivation = {
nativeBuildInputs = [pkgs.pkg-config];
buildInputs = [pkgs.openssl];
};
drvConfig.mkDerivation = {
nativeBuildInputs = [pkgs.tailwindcss pkgs.pkg-config];
buildInputs =
[pkgs.openssl]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin
(with pkgs.darwin.apple_sdk.frameworks; [SystemConfiguration]);
};
};
};
devShells.default = config.nci.outputs."fc-search".devShell.overrideAttrs (old:
{
packages =
(old.packages or [])
++ [pkgs.bacon pkgs.samply pkgs.tailwindcss pkgs.drill pkgs.wrk pkgs.inferno pkgs.tokio-console];
shellHook = ''
${old.shellHook or ""}
${config.pre-commit.installationScript}
'';
}
// (pkgs.lib.optionalAttrs (system == "aarch64-linux") {
# use mold in the devshell on aarch64-linux for quicker iteration
LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${
builtins.toString
(pkgs.lib.makeLibraryPath [pkgs.openssl])
}";
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER = "${pkgs.llvmPackages.clangUseLLVM}/bin/clang";
RUSTFLAGS = "--cfg tokio_unstable -Clink-arg=-fuse-ld=${pkgs.mold}/bin/mold -Zthreads=0 -Zshare-generics=n";
}));
};
};
}