-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathchecks.nix
More file actions
186 lines (178 loc) · 5.42 KB
/
Copy pathchecks.nix
File metadata and controls
186 lines (178 loc) · 5.42 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
{
pkgs,
version,
}:
{
github-actions = pkgs.stdenv.mkDerivation {
pname = "scip-github-actions";
inherit version;
src = ./.;
nativeBuildInputs = [
pkgs.action-validator
pkgs.git
];
buildPhase = ''
# action-validator >=0.7 calls `git ls-files` to discover workflows;
# initialise a throwaway repo so it works inside the Nix sandbox.
git init -q
git add -A
for f in .github/workflows/*.yml .github/workflows/*.yaml; do
[ -e "$f" ] && action-validator -v "$f"
done
'';
installPhase = "touch $out";
};
formatting = pkgs.stdenv.mkDerivation {
pname = "scip-formatting";
inherit version;
src = ./.;
nativeBuildInputs = with pkgs; [
buf
go
gotools
nixfmt
prettier
];
buildPhase = ''
prettier --check '**/*.{ts,js(on)?,md,yml}'
BUF_CACHE_DIR=$(mktemp -d) buf format --diff --exit-code scip.proto
gofmt -d . | tee /dev/stderr | diff /dev/null -
goimports -d . | tee /dev/stderr | diff /dev/null -
nixfmt --check *.nix
'';
installPhase = "touch $out";
};
dotnet-bindings =
let
csprojVersion = builtins.head (
builtins.match ".*<Version>([^<]+)</Version>.*" (builtins.readFile ./bindings/dotnet/Scip.csproj)
);
in
assert pkgs.lib.assertMsg (
csprojVersion == version
) "Version mismatch in bindings/dotnet/Scip.csproj: expected ${version}, got ${csprojVersion}";
pkgs.buildDotnetModule {
pname = "scip-bindings-dotnet";
inherit version;
src = ./bindings/dotnet;
projectFile = "Scip.csproj";
# Regenerate with:
# nix build .#checks.x86_64-linux.dotnet-bindings.passthru.fetch-deps
# ./result bindings/dotnet/deps.json
nugetDeps = ./bindings/dotnet/deps.json;
dotnet-sdk = pkgs.dotnetCorePackages.sdk_10_0;
# A library has nothing to publish; the nupkg is the artifact.
dontPublish = true;
packNupkg = true;
# LICENSE is a symlink to the repository root (matches
# bindings/{haskell,rust,typescript}) and packing follows it.
prePatch = ''
cp --remove-destination ${./LICENSE} LICENSE
'';
};
go-bindings = pkgs.buildGoModule {
pname = "scip-bindings-go";
inherit version;
src = ./.;
modRoot = "./bindings/go/scip";
vendorHash = "sha256-f36BsvI5AWAnuxe2BWD5Bkb6Xb3kdIkkSw3Td2QlcrA=";
env.GOWORK = "off";
buildTags = [ "asserts" ];
subPackages = [
"."
"memtest"
"testutil"
];
installPhase = "touch $out";
};
haskell-bindings =
let
cabal = pkgs.haskellPackages.callCabal2nix "scip" ./bindings/haskell { };
in
assert pkgs.lib.assertMsg (
cabal.version == version
) "Version mismatch in bindings/haskell/scip.cabal: expected ${version}, got ${cabal.version}";
cabal.overrideAttrs (oldAttrs: {
prePatch = ''
cp --remove-destination ${./LICENSE} LICENSE
'';
postPatch = (oldAttrs.postPatch or "") + ''
${pkgs.haskellPackages.cabal-install}/bin/cabal check
'';
});
reprolang =
let
reprolangVersion = (builtins.fromJSON (builtins.readFile ./reprolang/package.json)).version;
in
assert pkgs.lib.assertMsg (
reprolangVersion == version
) "Version mismatch in reprolang/package.json: expected ${version}, got ${reprolangVersion}";
pkgs.buildGoModule {
pname = "scip-reprolang";
inherit version;
src = ./.;
modRoot = "./reprolang";
vendorHash = "sha256-xSQqFbrbqhzxSGcW/ig3jkDRHMVxVXYaLOi3wMs/PMc=";
proxyVendor = true;
env.GOWORK = "off";
buildInputs = [ pkgs.tree-sitter ];
subPackages = [
"grammar"
"repro"
];
installPhase = "touch $out";
};
reprolang-generated = pkgs.stdenv.mkDerivation {
pname = "scip-reprolang-generated";
inherit version;
src = ./.;
nativeBuildInputs = with pkgs; [
nodejs
prettier
tree-sitter
];
buildPhase = ''
cd reprolang
cp -r grammar grammar-before
tree-sitter generate --abi 14 --output grammar
prettier --write 'grammar/grammar.json' 'grammar/node-types.json'
diff -rq grammar-before grammar
'';
installPhase = "touch $out";
};
rust-bindings =
let
cargoTomlVersion =
(builtins.fromTOML (builtins.readFile ./bindings/rust/Cargo.toml)).package.version;
in
assert pkgs.lib.assertMsg (
cargoTomlVersion == version
) "Version mismatch in bindings/rust/Cargo.toml: expected ${version}, got ${cargoTomlVersion}";
pkgs.rustPlatform.buildRustPackage {
pname = "scip-bindings-rust";
inherit version;
src = ./bindings/rust;
cargoLock = {
lockFile = ./bindings/rust/Cargo.lock;
};
};
typescript-bindings =
let
packageJsonVersion =
(builtins.fromJSON (builtins.readFile ./bindings/typescript/package.json)).version;
in
assert pkgs.lib.assertMsg (packageJsonVersion == version)
"Version mismatch in bindings/typescript/package.json: expected ${version}, got ${packageJsonVersion}";
pkgs.buildNpmPackage {
pname = "scip-bindings-typescript";
inherit version;
src = ./bindings/typescript;
npmDepsHash = "sha256-OiM5KpWXA5DTEtVeWH7AXpo7Ttg4NWY6OLx2WTRPGfE=";
buildPhase = ''
runHook preBuild
npm run build
runHook postBuild
'';
installPhase = "touch $out";
};
}