-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrelease.nix
More file actions
190 lines (172 loc) · 6.55 KB
/
Copy pathrelease.nix
File metadata and controls
190 lines (172 loc) · 6.55 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
187
188
189
190
{ system ? builtins.currentSystem }:
let
inputs = import ./nix/tamal { inherit system; };
inherit (pkgs) lib stdenv;
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ (import ./overlay.nix) ];
config = {
allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"reaper"
"win-sdk"
"xwin-fetch-msvc"
];
microsoftVisualStudioLicenseAccepted = true;
};
};
treefmtEval = (import inputs.treefmt).evalModule pkgs {
projectRootFile = "release.nix";
programs = {
nixpkgs-fmt.enable = true;
rustfmt.enable = true;
taplo.enable = true;
mdformat.enable = true;
yamlfmt.enable = true;
};
};
in
{
inherit pkgs;
default = pkgs.cargo-reaper;
fmt = treefmtEval.config.build.wrapper;
docs = pkgs.stdenvNoCC.mkDerivation {
pname = "cargo-reaper-docs";
version = pkgs.cargo-reaper.version;
src = lib.cleanSourceWith {
src = lib.cleanSource ./docs;
filter = path: type: baseNameOf path != "book";
};
nativeBuildInputs = [ pkgs.mdbook ];
buildPhase = ''
runHook preBuild
mdbook build --dest-dir $out .
runHook postBuild
'';
dontInstall = true;
};
checks = {
inherit (pkgs) cargo-reaper;
inherit (pkgs.cargo-reaper.passthru.tests)
cargo-clippy
cargo-doc
cargo-deny
;
fmt = treefmtEval.config.build.check (lib.cleanSourceWith {
src = lib.cleanSource ./.;
filter = path: type: baseNameOf path != "target";
});
test-cargo-reaper-build-package-manifest = pkgs.callPackage ./nix/tests/plugin_manifests/package_manifest { };
test-cargo-reaper-build-workspace-manifest = pkgs.callPackage ./nix/tests/plugin_manifests/workspace_manifest { };
test-cargo-reaper-build-workspace-package-manifest = pkgs.callPackage ./nix/tests/plugin_manifests/workspace_package_manifest { };
test-cargo-reaper-new-ext = pkgs.callPackage ./nix/tests/new-ext { };
test-cargo-reaper-new-vst = pkgs.callPackage ./nix/tests/new-vst { };
test-cargo-reaper-list-package-manifest = pkgs.callPackage ./nix/tests/list-package-manifest { };
test-cargo-reaper-list-workspace-manifest = pkgs.callPackage ./nix/tests/list-workspace-manifest { };
test-cargo-reaper-list-workspace-package-manifest = pkgs.callPackage ./nix/tests/list-workspace-package-manifest { };
};
crossChecks = lib.optionalAttrs stdenv.isLinux {
test-cargo-reaper-build-cross-windows =
let
winPkgs = pkgs.pkgsCross.x86_64-windows;
inherit (winPkgs.stdenv.hostPlatform.rust) rustcTarget;
fenix = pkgs.callPackage inputs.fenix { };
rustToolchain = fenix.combine [
(fenix.stable.withComponents [ "cargo" "rustc" ])
fenix.targets.${rustcTarget}.stable.rust-std
];
winRustPlatform = pkgs.rustPlatform.overrideScope (rfinal: rprev: {
# Override `buildRustPackage` with our windows toolchain
inherit (pkgs.makeRustPlatform {
rustc = rustToolchain;
cargo = rustToolchain;
})
buildRustPackage;
});
in
winRustPlatform.buildReaperExtension (
let
inherit (pkgs) llvmPackages;
inherit (winPkgs) windows;
envTarget = builtins.replaceStrings [ "-" ] [ "_" ] rustcTarget;
envTargetUpper = lib.toUpper envTarget;
CC = "${llvmPackages.clang-unwrapped}/bin/clang-cl";
# Flags forwarded to clang-cl by cc-rs so it can locate MSVC headers and libs.
CFLAGS = lib.concatStringsSep " " [
"/vctoolsdir ${windows.sdk}/crt"
"/winsdkdir ${windows.sdk}/sdk"
];
in
{
package = "package_manifest";
plugin = "reaper_package_ext";
target = rustcTarget;
src = lib.cleanSourceWith {
src = lib.cleanSource ./nix/tests/plugin_manifests/package_manifest;
filter = path: type: baseNameOf path != "target" && !lib.hasSuffix ".nix" (baseNameOf path);
};
strictDeps = true; # Enforce only buildPlatform deps in sandbox path
nativeBuildInputs = with llvmPackages; [
clang-unwrapped # clang-cl (C/C++ compiler)
bintools-unwrapped # lld-link (linker)
llvm # llvm-lib (MSVC lib.exe equivalent, used by cc-rs)
];
"CC_${envTarget}" = CC;
"CXX_${envTarget}" = CC;
"CFLAGS_${envTarget}" = CFLAGS;
"CXXFLAGS_${envTarget}" = CFLAGS;
"AR_${envTarget}" = "${llvmPackages.llvm}/bin/llvm-lib";
"CARGO_TARGET_${envTargetUpper}_LINKER" = "${llvmPackages.bintools-unwrapped}/bin/lld-link";
"CARGO_TARGET_${envTargetUpper}_RUSTFLAGS" = lib.concatStringsSep " " [
"-C link-arg=/LIBPATH:${windows.sdk}/crt/lib/x64"
"-C link-arg=/LIBPATH:${windows.sdk}/sdk/lib/ucrt/x64"
"-C link-arg=/LIBPATH:${windows.sdk}/sdk/lib/um/x64"
];
# Checks could be ran using wine64, but in this case we only care
# that the package was built and the output is the expected format
doCheck = false;
doInstallCheck = true;
installCheckPhase = ''
test -f $out/lib/reaper_package_ext.dll
file_output=$(file $out/lib/reaper_package_ext.dll)
echo "$file_output"
echo "$file_output" |
grep -q "PE32+ executable for MS Windows.*(DLL), x86-64" || {
echo "ERROR: not a PE32+ DLL";
exit 1;
}
imports=$(llvm-objdump -p $out/lib/reaper_package_ext.dll | grep "DLL Name")
echo "$imports"
echo "$imports" |
grep -q "VCRUNTIME140.dll" || {
echo "ERROR: VCRUNTIME140.dll not imported (not an MSVC ABI DLL)";
exit 1;
}
echo "$imports" |
grep -qiE "libgcc|libstdc\+\+|msvcrt\.dll" && {
echo "ERROR: MinGW runtime imported (not an MSVC ABI DLL)";
exit 1;
}
true
'';
}
);
};
nixosTests = {
test-cargo-reaper-link = pkgs.callPackage ./nixos/tests/link { };
test-cargo-reaper-run = pkgs.callPackage ./nixos/tests/run { };
test-cargo-reaper-clean = pkgs.callPackage ./nixos/tests/clean { };
};
devShell = pkgs.mkShell {
inputsFrom = builtins.attrValues pkgs.cargo-reaper.passthru.tests;
packages = with pkgs; [
nil
nixtamal
mdbook
cargo-reaper
rust-analyzer
reaper
] ++ lib.optionals stdenv.isLinux [
xdotool
];
};
}