-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
117 lines (109 loc) · 3.49 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{
description = "Gitar Nix integration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
};
};
outputs = { self, nixpkgs, rust-overlay, crane, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
inherit (pkgs) lib;
rust = (pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "llvm-tools-preview" ];
});
craneLib = (crane.mkLib pkgs).overrideToolchain rust;
src = lib.cleanSourceWith {
src = craneLib.path ./.;
};
commonArgs = {
inherit src;
strictDeps = true;
nativeBuildInputs = [
pkgs.pkg-config
];
buildInputs = [
pkgs.openssl
];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
gr = craneLib.buildPackage (commonArgs // {
pname = "gr";
inherit cargoArtifacts;
});
gitcleanbranches = pkgs.writeScriptBin "git-clean-branches" ''
# ref: https://gist.github.com/jordilin/08b6fed14b358dcbdf40c485c4daa730
git branch -r --merged |
grep origin |
grep -v '>' |
grep -v main |
xargs -L1 |
cut -d"/" -f2- |
xargs git push origin --delete
'';
releaseScript = builtins.readFile ./release.sh;
release = pkgs.writeShellScriptBin "release" releaseScript;
scripts = [
gitcleanbranches
release
];
in
with pkgs;
{
checks = {
inherit gr;
};
packages = {
default = gr;
inherit gr;
};
devShells.default = craneLib.devShell {
inputsFrom = [ gr ];
checks = self.checks.${system};
packages = [
rust-analyzer
cargo-tarpaulin
cargo-audit
cargo-watch
# cargo-edit provides cargo upgrade for Cargo.toml
# See note cargo upgrade stuck on fetch
# https://github.com/killercup/cargo-edit/issues/869#issuecomment-1696223822
# run CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git cargo fetch
# and CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git cargo upgrade
cargo-edit
# cargo llvm-cov --html (alternative to tarpaulin needs
# llvm-tools-preview extension)
cargo-llvm-cov
cargo-nextest
sccache
just
python311Packages.requests
python311Packages.black
# Github actions locally for fast iteration
act
# Github actions linter
actionlint
# Documentation
mdbook
mdbook-toc
] ++ scripts;
shellHook = ''
rustc --version
rustversion=$(rustc --version | awk '{print $2}')
pythonversion=$(python --version | awk '{print $2}')
SHELL_NAME="rc-$rustversion|py-$pythonversion"
export PATH="./result/bin:$PATH"
'';
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
}
);
}