generated from RustLangES/cfworker-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
122 lines (104 loc) · 2.36 KB
/
default.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
118
119
120
121
122
inputs @ {
pkgs,
lib ? pkgs.lib,
stdenv ? pkgs.stdenv,
crane,
fenix,
flake-utils,
...
}: let
# fenix: rustup replacement for reproducible builds
toolchain = fenix.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-3jVIIf5XPnUU1CRaTyAiO0XHVbJl12MSx3eucTXCjtE=";
};
# crane: cargo and artifacts manager
craneLib = crane.overrideToolchain toolchain;
nativeBuildInputs = with pkgs; [
esbuild
worker-build
wasm-pack
wasm-bindgen-cli
binaryen
];
buildInputs = with pkgs;
[
openssl
pkg-config
]
++ lib.optionals stdenv.buildPlatform.isDarwin [
pkgs.libiconv
];
cargoToml = path:
craneLib.crateNameFromCargoToml {
src = craneLib.cleanCargoSource path;
};
commonArgs = {
inherit buildInputs nativeBuildInputs;
pname = "worker";
strictDeps = true;
doCheck = false;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
./crates/backend
./crates/models
./crates/shared
];
};
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
worker = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts;
pname = "worker";
inherit (cargoToml ./crates/backend) version;
buildPhaseCargoCommand = ''
cd crates/backend
HOME=$(mktemp -d fake-homeXXXX)
worker-build --release --mode no-install
'';
installPhaseCommand = "cp -r build $out";
});
devShellBuildInputs =
nativeBuildInputs
++ buildInputs
++ (with pkgs; [
toolchain
cargo-make
taplo
# deno
nodejs
nodePackages.pnpm
# nodePackages.prettier
# nodePackages.typescript-language-server
# nodePackages.svelte-language-server
(import ./nix/wrangler.nix inputs)
]);
in {
# `nix run .#zellij`
apps.zellij = flake-utils.lib.mkApp {
drv = pkgs.writeShellApplication {
name = "run-zellij";
runtimeInputs = with pkgs;
devShellBuildInputs
++ [
zellij
];
text = ''
zellij --layout ${./nix/zellij/layout.kdl}
'';
};
};
# `nix build`
packages.default = worker;
# `nix develop`
devShells = {
default = craneLib.devShell {
buildInputs =
devShellBuildInputs;
};
};
}