downpatch

This commit is contained in:
Borodinov Ilya 2024-09-21 22:24:52 +03:00
parent 2269692fb3
commit c8507bb500
Signed by: noth
GPG key ID: 75503B2EF596D1BD
2 changed files with 113 additions and 72 deletions

View file

@ -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"] }

103
flake.nix
View file

@ -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
];
in
# Build the output set for each default system and map system sets into # Build the output set for each default system and map system sets into
# attributes, resulting in paths such as: # attributes, resulting in paths such as:
# nix build .#packages.x86_64-linux.<name> # nix build .#packages.x86_64-linux.<name>
in flake-utils.lib.eachSystem nativeSystems (system: flake-utils.lib.eachSystem nativeSystems (
system:
let let
@ -47,24 +54,32 @@
flake = self; flake = self;
}; };
mkRustToolchain = {target, extraComponents ? []}: mkRustToolchain =
{
target,
extraComponents ? [ ],
}:
with fenix.packages.${system}; with fenix.packages.${system};
combine ([ combine (
[
stable.rustc stable.rustc
stable.cargo stable.cargo
targets.${target}.stable.rust-std targets.${target}.stable.rust-std
] ++ extraComponents); ]
++ extraComponents
);
buildPlatform = pkgs.stdenv.buildPlatform.config; buildPlatform = pkgs.stdenv.buildPlatform.config;
in
# Make platforms available as variables to prevent typos # Make platforms available as variables to prevent typos
in with util.platforms; with util.platforms;
rec { rec {
packages = { packages =
{
# nix build # nix build
default = default = packages.${buildPlatform} or packages.x86_64-unknown-linux-gnu;
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 {
@ -81,19 +96,27 @@
# nix build .#windows-binary # nix build .#windows-binary
windows-binary = packages.x86_64-pc-windows-gnu; windows-binary = packages.x86_64-pc-windows-gnu;
} // (pkgs.lib.attrsets.mapAttrs (target: _: }
// (pkgs.lib.attrsets.mapAttrs (
target: _:
let let
spec = spec = import ./pkg/nix/spec/${target}.nix { inherit pkgs target util; };
import ./pkg/nix/spec/${target}.nix { inherit pkgs target util; }; in
in import ./pkg/nix/drv/binary.nix { import ./pkg/nix/drv/binary.nix {
inherit pkgs util spec crane; inherit
pkgs
util
spec
crane
;
rustToolchain = mkRustToolchain { inherit target; }; rustToolchain = mkRustToolchain { inherit target; };
}) util.platforms); }
) util.platforms);
devShells = { devShells =
{
# nix develop # nix develop
default = default = devShells.${buildPlatform} or devShells.x86_64-unknown-linux-gnu;
devShells.${buildPlatform} or devShells.x86_64-unknown-linux-gnu;
# nix develop .#static-binary # nix develop .#static-binary
static-binary = devShells.x86_64-unknown-linux-musl; static-binary = devShells.x86_64-unknown-linux-musl;
@ -103,25 +126,43 @@
# nix develop .#windows-binary # nix develop .#windows-binary
windows-binary = devShells.x86_64-pc-windows-gnu; windows-binary = devShells.x86_64-pc-windows-gnu;
} // (pkgs.lib.attrsets.mapAttrs (target: _: }
// (pkgs.lib.attrsets.mapAttrs (
target: _:
let let
spec = (import ./pkg/nix/spec/${target}.nix) { spec = (import ./pkg/nix/spec/${target}.nix) { inherit pkgs target util; };
inherit pkgs target util; extraComponents = with fenix.packages.${system}; [
}; targets.${target}.stable.rust-src
extraComponents = with fenix.packages.${system}; [ targets.${target}.stable.rust-src rust-analyzer targets.${target}.stable.rustfmt ]; rust-analyzer
targets.${target}.stable.rustfmt
];
rustToolchain = mkRustToolchain { inherit target extraComponents; }; rustToolchain = mkRustToolchain { inherit target extraComponents; };
buildSpec = spec.buildSpec; buildSpec = spec.buildSpec;
in pkgs.mkShell (buildSpec // { in
pkgs.mkShell (
buildSpec
// {
hardeningDisable = [ "fortify" ]; hardeningDisable = [ "fortify" ];
depsBuildBuild = buildSpec.depsBuildBuild or [ ] depsBuildBuild =
++ [ rustToolchain ] ++ (with pkgs; [ nixfmt cargo-watch wasm-pack pre-commit cargo-make]); buildSpec.depsBuildBuild or [ ]
#++ [ rustToolchain ]
++ (with pkgs; [
nixfmt
cargo-watch
wasm-pack
pre-commit
cargo-make
]);
inherit (util) SURREAL_BUILD_METADATA; inherit (util) SURREAL_BUILD_METADATA;
})) util.platforms); }
)
) util.platforms);
# nix run # nix run
apps.default = flake-utils.lib.mkApp { drv = packages.default; }; apps.default = flake-utils.lib.mkApp { drv = packages.default; };
}); }
);
} }