2022-10-04 16:32:44 +00:00
|
|
|
{
|
2024-09-21 19:24:52 +00:00
|
|
|
description = "A scalable, distributed, collaborative, document-graph database, for the realtime web";
|
2022-10-04 16:32:44 +00:00
|
|
|
|
|
|
|
inputs = {
|
2023-12-01 15:16:28 +00:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11-small";
|
2022-10-04 16:32:44 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils/v1.0.0";
|
|
|
|
crane = {
|
2024-03-27 21:01:40 +00:00
|
|
|
url = "github:ipetkov/crane/v0.16.3";
|
2022-10-04 16:32:44 +00:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
fenix = {
|
|
|
|
url = "github:nix-community/fenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-09-21 19:24:52 +00:00
|
|
|
outputs =
|
|
|
|
inputs:
|
2022-10-04 16:32:44 +00:00
|
|
|
with inputs;
|
|
|
|
|
|
|
|
# Make systems available as variables to prevent typos
|
|
|
|
with flake-utils.lib.system;
|
|
|
|
|
|
|
|
# let-in expressions, very similar to Rust's let bindings. These names
|
|
|
|
# are used to express the output but not themselves paths in the output.
|
|
|
|
let
|
|
|
|
|
2024-09-21 19:24:52 +00:00
|
|
|
nativeSystems = [
|
|
|
|
aarch64-darwin
|
|
|
|
aarch64-linux
|
|
|
|
x86_64-darwin
|
|
|
|
x86_64-linux
|
|
|
|
];
|
2022-10-04 16:32:44 +00:00
|
|
|
|
2024-09-21 19:24:52 +00:00
|
|
|
in
|
|
|
|
# Build the output set for each default system and map system sets into
|
|
|
|
# attributes, resulting in paths such as:
|
|
|
|
# nix build .#packages.x86_64-linux.<name>
|
|
|
|
flake-utils.lib.eachSystem nativeSystems (
|
|
|
|
system:
|
2022-10-04 16:32:44 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
|
|
|
|
util = import ./pkg/nix/util.nix {
|
|
|
|
inherit system;
|
|
|
|
inherit (pkgs) lib;
|
|
|
|
systems = flake-utils.lib.system;
|
|
|
|
flake = self;
|
|
|
|
};
|
|
|
|
|
2024-09-21 19:24:52 +00:00
|
|
|
mkRustToolchain =
|
|
|
|
{
|
|
|
|
target,
|
|
|
|
extraComponents ? [ ],
|
|
|
|
}:
|
2022-10-04 16:32:44 +00:00
|
|
|
with fenix.packages.${system};
|
2024-09-21 19:24:52 +00:00
|
|
|
combine (
|
|
|
|
[
|
|
|
|
stable.rustc
|
|
|
|
stable.cargo
|
|
|
|
targets.${target}.stable.rust-std
|
|
|
|
]
|
|
|
|
++ extraComponents
|
|
|
|
);
|
2022-10-04 16:32:44 +00:00
|
|
|
|
|
|
|
buildPlatform = pkgs.stdenv.buildPlatform.config;
|
|
|
|
|
2024-09-21 19:24:52 +00:00
|
|
|
in
|
|
|
|
# Make platforms available as variables to prevent typos
|
|
|
|
with util.platforms;
|
2022-10-04 16:32:44 +00:00
|
|
|
|
|
|
|
rec {
|
2024-09-21 19:24:52 +00:00
|
|
|
packages =
|
|
|
|
{
|
|
|
|
# nix build
|
|
|
|
default = packages.${buildPlatform} or packages.x86_64-unknown-linux-gnu;
|
|
|
|
|
|
|
|
# nix build .#docker-image
|
|
|
|
docker-image = import ./pkg/nix/drv/docker.nix {
|
|
|
|
inherit util;
|
|
|
|
inherit (pkgs) cacert dockerTools;
|
|
|
|
package = packages.x86_64-unknown-linux-gnu;
|
2022-10-04 16:32:44 +00:00
|
|
|
};
|
|
|
|
|
2024-09-21 19:24:52 +00:00
|
|
|
# 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 [ ]
|
|
|
|
#++ [ rustToolchain ]
|
|
|
|
++ (with pkgs; [
|
|
|
|
nixfmt
|
|
|
|
cargo-watch
|
|
|
|
wasm-pack
|
|
|
|
pre-commit
|
|
|
|
cargo-make
|
|
|
|
]);
|
|
|
|
|
|
|
|
inherit (util) SURREAL_BUILD_METADATA;
|
|
|
|
}
|
|
|
|
)
|
|
|
|
) util.platforms);
|
2022-10-04 16:32:44 +00:00
|
|
|
|
|
|
|
# nix run
|
|
|
|
apps.default = flake-utils.lib.mkApp { drv = packages.default; };
|
|
|
|
|
2024-09-21 19:24:52 +00:00
|
|
|
}
|
|
|
|
);
|
2022-10-04 16:32:44 +00:00
|
|
|
}
|