Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
ac421c24f8 | |||
c8507bb500 |
4 changed files with 119 additions and 78 deletions
|
@ -121,7 +121,7 @@ surrealdb = { version = "2", path = "sdk", features = [
|
||||||
surrealdb-core = { version = "2", path = "core" }
|
surrealdb-core = { version = "2", path = "core" }
|
||||||
tempfile = "3.8.1"
|
tempfile = "3.8.1"
|
||||||
thiserror = "1.0.63"
|
thiserror = "1.0.63"
|
||||||
tokio = { version = "1.40.0", features = ["macros", "signal"] }
|
tokio = { version = "1", features = ["macros", "signal"] }
|
||||||
tokio-stream = "0.1"
|
tokio-stream = "0.1"
|
||||||
tokio-tungstenite = "0.23.1"
|
tokio-tungstenite = "0.23.1"
|
||||||
tokio-util = { version = "0.7.11", features = ["io"] }
|
tokio-util = { version = "0.7.11", features = ["io"] }
|
||||||
|
|
|
@ -168,14 +168,14 @@ serial_test = "2.0.0"
|
||||||
temp-dir = "0.1.11"
|
temp-dir = "0.1.11"
|
||||||
test-log = { version = "0.2.13", features = ["trace"] }
|
test-log = { version = "0.2.13", features = ["trace"] }
|
||||||
time = { version = "0.3.36", features = ["serde"] }
|
time = { version = "0.3.36", features = ["serde"] }
|
||||||
tokio = { version = "1.40.0", features = ["macros", "sync", "rt-multi-thread"] }
|
tokio = { version = "1", features = ["macros", "sync", "rt-multi-thread"] }
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
wiremock = "0.6.0"
|
wiremock = "0.6.0"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
pharos = "0.5.3"
|
pharos = "0.5.3"
|
||||||
ring = { version = "0.17.7", features = ["wasm32_unknown_unknown_js"] }
|
ring = { version = "0.17.7", features = ["wasm32_unknown_unknown_js"] }
|
||||||
tokio = { version = "1.40.0", default-features = false, features = [
|
tokio = { version = "1", default-features = false, features = [
|
||||||
"rt",
|
"rt",
|
||||||
"sync",
|
"sync",
|
||||||
] }
|
] }
|
||||||
|
@ -187,7 +187,7 @@ wasmtimer = { version = "0.2.0", default-features = false, features = [
|
||||||
ws_stream_wasm = "0.7.4"
|
ws_stream_wasm = "0.7.4"
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
tokio = { version = "1.40.0", default-features = false, features = [
|
tokio = { version = "1", default-features = false, features = [
|
||||||
"macros",
|
"macros",
|
||||||
"io-util",
|
"io-util",
|
||||||
"io-std",
|
"io-std",
|
||||||
|
|
183
flake.nix
183
flake.nix
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
description =
|
description = "A scalable, distributed, collaborative, document-graph database, for the realtime web";
|
||||||
"A scalable, distributed, collaborative, document-graph database, for the realtime web";
|
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11-small";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11-small";
|
||||||
|
@ -19,7 +18,8 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs:
|
outputs =
|
||||||
|
inputs:
|
||||||
with inputs;
|
with inputs;
|
||||||
|
|
||||||
# Make systems available as variables to prevent typos
|
# Make systems available as variables to prevent typos
|
||||||
|
@ -29,12 +29,19 @@
|
||||||
# are used to express the output but not themselves paths in the output.
|
# are used to express the output but not themselves paths in the output.
|
||||||
let
|
let
|
||||||
|
|
||||||
nativeSystems = [ aarch64-darwin aarch64-linux x86_64-darwin x86_64-linux ];
|
nativeSystems = [
|
||||||
|
aarch64-darwin
|
||||||
|
aarch64-linux
|
||||||
|
x86_64-darwin
|
||||||
|
x86_64-linux
|
||||||
|
];
|
||||||
|
|
||||||
# Build the output set for each default system and map system sets into
|
in
|
||||||
# attributes, resulting in paths such as:
|
# Build the output set for each default system and map system sets into
|
||||||
# nix build .#packages.x86_64-linux.<name>
|
# attributes, resulting in paths such as:
|
||||||
in flake-utils.lib.eachSystem nativeSystems (system:
|
# nix build .#packages.x86_64-linux.<name>
|
||||||
|
flake-utils.lib.eachSystem nativeSystems (
|
||||||
|
system:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -47,81 +54,115 @@
|
||||||
flake = self;
|
flake = self;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkRustToolchain = {target, extraComponents ? []}:
|
mkRustToolchain =
|
||||||
|
{
|
||||||
|
target,
|
||||||
|
extraComponents ? [ ],
|
||||||
|
}:
|
||||||
with fenix.packages.${system};
|
with fenix.packages.${system};
|
||||||
combine ([
|
combine (
|
||||||
stable.rustc
|
[
|
||||||
stable.cargo
|
stable.rustc
|
||||||
targets.${target}.stable.rust-std
|
stable.cargo
|
||||||
] ++ extraComponents);
|
targets.${target}.stable.rust-std
|
||||||
|
]
|
||||||
|
++ extraComponents
|
||||||
|
);
|
||||||
|
|
||||||
buildPlatform = pkgs.stdenv.buildPlatform.config;
|
buildPlatform = pkgs.stdenv.buildPlatform.config;
|
||||||
|
|
||||||
# Make platforms available as variables to prevent typos
|
in
|
||||||
in with util.platforms;
|
# Make platforms available as variables to prevent typos
|
||||||
|
with util.platforms;
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
packages = {
|
packages =
|
||||||
# nix build
|
{
|
||||||
default =
|
# nix build
|
||||||
packages.${buildPlatform} or packages.x86_64-unknown-linux-gnu;
|
default = packages.${buildPlatform} or packages.x86_64-unknown-linux-gnu;
|
||||||
|
|
||||||
# nix build .#docker-image
|
# nix build .#docker-image
|
||||||
docker-image = import ./pkg/nix/drv/docker.nix {
|
docker-image = import ./pkg/nix/drv/docker.nix {
|
||||||
inherit util;
|
inherit util;
|
||||||
inherit (pkgs) cacert dockerTools;
|
inherit (pkgs) cacert dockerTools;
|
||||||
package = packages.x86_64-unknown-linux-gnu;
|
package = packages.x86_64-unknown-linux-gnu;
|
||||||
};
|
|
||||||
|
|
||||||
# nix build .#static-binary
|
|
||||||
static-binary = packages.x86_64-unknown-linux-musl;
|
|
||||||
|
|
||||||
# nix build .#wasm
|
|
||||||
wasm = packages.wasm32-unknown-unknown;
|
|
||||||
|
|
||||||
# nix build .#windows-binary
|
|
||||||
windows-binary = packages.x86_64-pc-windows-gnu;
|
|
||||||
} // (pkgs.lib.attrsets.mapAttrs (target: _:
|
|
||||||
let
|
|
||||||
spec =
|
|
||||||
import ./pkg/nix/spec/${target}.nix { inherit pkgs target util; };
|
|
||||||
in import ./pkg/nix/drv/binary.nix {
|
|
||||||
inherit pkgs util spec crane;
|
|
||||||
rustToolchain = mkRustToolchain { inherit target; };
|
|
||||||
}) util.platforms);
|
|
||||||
|
|
||||||
devShells = {
|
|
||||||
# nix develop
|
|
||||||
default =
|
|
||||||
devShells.${buildPlatform} or devShells.x86_64-unknown-linux-gnu;
|
|
||||||
|
|
||||||
# nix develop .#static-binary
|
|
||||||
static-binary = devShells.x86_64-unknown-linux-musl;
|
|
||||||
|
|
||||||
# nix develop .#wasm
|
|
||||||
wasm = devShells.wasm32-unknown-unknown;
|
|
||||||
|
|
||||||
# nix develop .#windows-binary
|
|
||||||
windows-binary = devShells.x86_64-pc-windows-gnu;
|
|
||||||
} // (pkgs.lib.attrsets.mapAttrs (target: _:
|
|
||||||
let
|
|
||||||
spec = (import ./pkg/nix/spec/${target}.nix) {
|
|
||||||
inherit pkgs target util;
|
|
||||||
};
|
};
|
||||||
extraComponents = with fenix.packages.${system}; [ targets.${target}.stable.rust-src rust-analyzer targets.${target}.stable.rustfmt ];
|
|
||||||
rustToolchain = mkRustToolchain { inherit target extraComponents; };
|
|
||||||
buildSpec = spec.buildSpec;
|
|
||||||
in pkgs.mkShell (buildSpec // {
|
|
||||||
hardeningDisable = [ "fortify" ];
|
|
||||||
|
|
||||||
depsBuildBuild = buildSpec.depsBuildBuild or [ ]
|
# nix build .#static-binary
|
||||||
++ [ rustToolchain ] ++ (with pkgs; [ nixfmt cargo-watch wasm-pack pre-commit cargo-make]);
|
static-binary = packages.x86_64-unknown-linux-musl;
|
||||||
|
|
||||||
inherit (util) SURREAL_BUILD_METADATA;
|
# nix build .#wasm
|
||||||
})) util.platforms);
|
wasm = packages.wasm32-unknown-unknown;
|
||||||
|
|
||||||
|
# nix build .#windows-binary
|
||||||
|
windows-binary = packages.x86_64-pc-windows-gnu;
|
||||||
|
}
|
||||||
|
// (pkgs.lib.attrsets.mapAttrs (
|
||||||
|
target: _:
|
||||||
|
let
|
||||||
|
spec = import ./pkg/nix/spec/${target}.nix { inherit pkgs target util; };
|
||||||
|
in
|
||||||
|
import ./pkg/nix/drv/binary.nix {
|
||||||
|
inherit
|
||||||
|
pkgs
|
||||||
|
util
|
||||||
|
spec
|
||||||
|
crane
|
||||||
|
;
|
||||||
|
rustToolchain = mkRustToolchain { inherit target; };
|
||||||
|
}
|
||||||
|
) util.platforms);
|
||||||
|
|
||||||
|
devShells =
|
||||||
|
{
|
||||||
|
# nix develop
|
||||||
|
default = devShells.${buildPlatform} or devShells.x86_64-unknown-linux-gnu;
|
||||||
|
|
||||||
|
# nix develop .#static-binary
|
||||||
|
static-binary = devShells.x86_64-unknown-linux-musl;
|
||||||
|
|
||||||
|
# nix develop .#wasm
|
||||||
|
wasm = devShells.wasm32-unknown-unknown;
|
||||||
|
|
||||||
|
# nix develop .#windows-binary
|
||||||
|
windows-binary = devShells.x86_64-pc-windows-gnu;
|
||||||
|
}
|
||||||
|
// (pkgs.lib.attrsets.mapAttrs (
|
||||||
|
target: _:
|
||||||
|
let
|
||||||
|
spec = (import ./pkg/nix/spec/${target}.nix) { inherit pkgs target util; };
|
||||||
|
extraComponents = with fenix.packages.${system}; [
|
||||||
|
targets.${target}.stable.rust-src
|
||||||
|
rust-analyzer
|
||||||
|
targets.${target}.stable.rustfmt
|
||||||
|
];
|
||||||
|
rustToolchain = mkRustToolchain { inherit target extraComponents; };
|
||||||
|
buildSpec = spec.buildSpec;
|
||||||
|
in
|
||||||
|
pkgs.mkShell (
|
||||||
|
buildSpec
|
||||||
|
// {
|
||||||
|
hardeningDisable = [ "fortify" ];
|
||||||
|
|
||||||
|
depsBuildBuild =
|
||||||
|
buildSpec.depsBuildBuild or [ ]
|
||||||
|
#++ [ rustToolchain ]
|
||||||
|
++ (with pkgs; [
|
||||||
|
nixfmt
|
||||||
|
cargo-watch
|
||||||
|
wasm-pack
|
||||||
|
pre-commit
|
||||||
|
cargo-make
|
||||||
|
]);
|
||||||
|
|
||||||
|
inherit (util) SURREAL_BUILD_METADATA;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
) util.platforms);
|
||||||
|
|
||||||
# nix run
|
# nix run
|
||||||
apps.default = flake-utils.lib.mkApp { drv = packages.default; };
|
apps.default = flake-utils.lib.mkApp { drv = packages.default; };
|
||||||
|
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ serial_test = "2.0.0"
|
||||||
temp-dir = "0.1.11"
|
temp-dir = "0.1.11"
|
||||||
test-log = { version = "0.2.13", features = ["trace"] }
|
test-log = { version = "0.2.13", features = ["trace"] }
|
||||||
time = { version = "0.3.36", features = ["serde"] }
|
time = { version = "0.3.36", features = ["serde"] }
|
||||||
tokio = { version = "1.40.0", features = ["macros", "sync", "rt-multi-thread"] }
|
tokio = { version = "1", features = ["macros", "sync", "rt-multi-thread"] }
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
ulid = { version = "1.1.0", features = ["serde"] }
|
ulid = { version = "1.1.0", features = ["serde"] }
|
||||||
wiremock = "0.6.0"
|
wiremock = "0.6.0"
|
||||||
|
@ -132,7 +132,7 @@ wiremock = "0.6.0"
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
pharos = "0.5.3"
|
pharos = "0.5.3"
|
||||||
ring = { version = "0.17.7", features = ["wasm32_unknown_unknown_js"] }
|
ring = { version = "0.17.7", features = ["wasm32_unknown_unknown_js"] }
|
||||||
tokio = { version = "1.40.0", default-features = false, features = [
|
tokio = { version = "1", default-features = false, features = [
|
||||||
"rt",
|
"rt",
|
||||||
"sync",
|
"sync",
|
||||||
] }
|
] }
|
||||||
|
@ -144,7 +144,7 @@ wasmtimer = { version = "0.2.0", default-features = false, features = [
|
||||||
ws_stream_wasm = "0.7.4"
|
ws_stream_wasm = "0.7.4"
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
tokio = { version = "1.40.0", default-features = false, features = [
|
tokio = { version = "1", default-features = false, features = [
|
||||||
"macros",
|
"macros",
|
||||||
"io-util",
|
"io-util",
|
||||||
"io-std",
|
"io-std",
|
||||||
|
|
Loading…
Reference in a new issue