-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathflake.nix
More file actions
167 lines (149 loc) · 4.28 KB
/
Copy pathflake.nix
File metadata and controls
167 lines (149 loc) · 4.28 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
{
description = "Cryptographically verifiable Code REviews";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
flake-utils.url = "github:numtide/flake-utils";
flakebox.url = "github:rustshop/flakebox";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
flakebox,
flake-compat,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
projectName = "cargo-crev";
flakeboxLib = flakebox.lib.mkLib pkgs {
config = {
github.ci.buildOutputs = [ ".#ci.${projectName}" ];
just.importPaths = [ "justfile.custom.just" ];
just.rules.watch.enable = false;
toolchain.components = [
"rustc"
"cargo"
"clippy"
"rust-analyzer"
"rust-src"
"rustfmt"
];
};
};
# All paths needed for building the workspace
buildPaths = [
"Cargo.toml"
"Cargo.lock"
"cargo-crev"
"crev-common"
"crev-data"
"crev-lib"
"crev-wot"
"skills"
];
buildSrc = flakeboxLib.filterSubPaths {
root = builtins.path {
name = projectName;
path = ./.;
};
paths = buildPaths;
};
nativeBuildInputs = with pkgs; [
pkg-config
perl
];
buildInputs =
with pkgs;
[
openssl
]
++ lib.optionals stdenv.isDarwin [
libiconv
curl
libgit2
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreFoundation
];
multiBuild = (flakeboxLib.craneMultiBuild { }) (
craneLib':
let
craneLib = craneLib'.overrideArgs {
pname = projectName;
src = buildSrc;
inherit nativeBuildInputs buildInputs;
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib/";
};
in
rec {
workspaceDeps = craneLib.buildWorkspaceDepsOnly { };
workspace = craneLib.buildWorkspace {
cargoArtifacts = workspaceDeps;
};
tests = craneLib.cargoNextest {
cargoArtifacts = workspace;
};
clippy = craneLib.cargoClippy {
cargoArtifacts = workspaceDeps;
};
cargoFmt = craneLib.cargoFmt { };
cargo-crev = craneLib.buildPackage {
cargoArtifacts = workspaceDeps;
cargoExtraArgs = "--bin cargo-crev";
};
}
);
treefmt =
pkgs.runCommand "treefmt-check"
{
nativeBuildInputs = [
pkgs.treefmt
pkgs.nixfmt-rfc-style
pkgs.rustfmt
];
src = self;
}
''
cp -r $src work && chmod -R u+w work
cd work
treefmt --ci
touch $out
'';
cargo-crev-container = pkgs.dockerTools.buildLayeredImage {
name = projectName;
contents = [ multiBuild.cargo-crev ];
config = {
Cmd = [ "${multiBuild.cargo-crev}/bin/cargo-crev" ];
};
};
in
{
packages = {
treefmt = treefmt;
default = multiBuild.cargo-crev;
cargo-crev = multiBuild.cargo-crev;
container = {
cargo-crev = cargo-crev-container;
};
};
legacyPackages = multiBuild;
devShells = flakeboxLib.mkShells {
packages = nativeBuildInputs ++ buildInputs;
shellHook = ''
# auto-install git hooks
dot_git="$(git rev-parse --git-common-dir)"
if [[ ! -d "$dot_git/hooks" ]]; then mkdir "$dot_git/hooks"; fi
for hook in misc/git-hooks/* ; do ln -sf "$(pwd)/$hook" "$dot_git/hooks/" ; done
${pkgs.git}/bin/git config commit.template misc/git-hooks/commit-template.txt
'';
};
}
);
}