-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdefault.nix
More file actions
95 lines (82 loc) · 1.92 KB
/
default.nix
File metadata and controls
95 lines (82 loc) · 1.92 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
{
pkgs,
lib ? pkgs.lib,
stdenv ? pkgs.stdenv,
crane,
fenix,
wrangler-fix,
...
}: let
# fenix: rustup replacement for reproducible builds
toolchain = fenix.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-KUm16pHj+cRedf8vxs/Hd2YWxpOrWZ7UOrwhILdSJBU=";
};
# crane: cargo and artifacts manager
craneLib = crane.overrideToolchain toolchain;
nativeBuildInputs = with pkgs; [
worker-build
wasm-pack
wasm-bindgen-cli
binaryen
];
buildInputs = with pkgs;
[
openssl
pkg-config
autoPatchelfHook
]
++ lib.optionals stdenv.buildPlatform.isDarwin [
pkgs.libiconv
];
cargoToml = path:
craneLib.crateNameFromCargoToml {
src = craneLib.cleanCargoSource path;
};
worker = craneLib.buildPackage {
pname = "worker";
inherit (cargoToml ./crates/backend) version;
doCheck = false;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
./crates/backend
./crates/models
./crates/shared
];
};
buildPhaseCargoCommand = ''
cd crates/backend
HOME=$(mktemp -d fake-homeXXXX) worker-build --release --mode no-install
cd ../..
'';
# Custom build command is provided, so this should be enabled
doNotPostBuildInstallCargoBinaries = true;
installPhaseCommand = ''
cp -r ./crates/backend/build/ $out
'';
nativeBuildInputs = with pkgs; [esbuild] ++ nativeBuildInputs;
inherit buildInputs;
};
in {
# `nix build .#backend`
packages.backend = worker;
# `nix develop`
devShells = {
default = craneLib.devShell {
buildInputs =
nativeBuildInputs
++ buildInputs
++ (with pkgs; [
toolchain
cargo-make
taplo
nodejs
nodePackages.pnpm
wrangler-fix.wrangler
]);
};
};
}