2022-10-04 16:32:44 +00:00
|
|
|
{
|
|
|
|
description =
|
|
|
|
"A scalable, distributed, collaborative, document-graph database, for the realtime web";
|
|
|
|
|
|
|
|
inputs = {
|
2023-07-25 11:37:43 +00:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05-small";
|
2022-10-04 16:32:44 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils/v1.0.0";
|
|
|
|
crane = {
|
2023-07-25 11:37:43 +00:00
|
|
|
url = "github:ipetkov/crane/v0.12.2";
|
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;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = inputs:
|
|
|
|
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
|
|
|
|
|
2023-05-11 18:43:41 +00:00
|
|
|
nativeSystems = [ aarch64-darwin aarch64-linux x86_64-darwin x86_64-linux ];
|
2022-10-04 16:32:44 +00:00
|
|
|
|
|
|
|
# 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>
|
|
|
|
in flake-utils.lib.eachSystem nativeSystems (system:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
|
|
|
|
util = import ./pkg/nix/util.nix {
|
|
|
|
inherit system;
|
|
|
|
inherit (pkgs) lib;
|
|
|
|
systems = flake-utils.lib.system;
|
|
|
|
flake = self;
|
|
|
|
};
|
|
|
|
|
2023-06-06 15:38:11 +00:00
|
|
|
mkRustToolchain = {target, extraComponents ? []}:
|
2022-10-04 16:32:44 +00:00
|
|
|
with fenix.packages.${system};
|
2023-06-06 15:38:11 +00:00
|
|
|
combine ([
|
2022-10-04 16:32:44 +00:00
|
|
|
stable.rustc
|
|
|
|
stable.cargo
|
|
|
|
targets.${target}.stable.rust-std
|
2023-06-06 15:38:11 +00:00
|
|
|
] ++ extraComponents);
|
2022-10-04 16:32:44 +00:00
|
|
|
|
|
|
|
buildPlatform = pkgs.stdenv.buildPlatform.config;
|
|
|
|
|
|
|
|
# Make platforms available as variables to prevent typos
|
|
|
|
in with util.platforms;
|
|
|
|
|
|
|
|
rec {
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
# nix build .#static-binary
|
|
|
|
static-binary = packages.x86_64-unknown-linux-musl;
|
|
|
|
|
2022-12-08 16:33:12 +00:00
|
|
|
# nix build .#wasm
|
|
|
|
wasm = packages.wasm32-unknown-unknown;
|
|
|
|
|
2022-10-04 16:32:44 +00:00
|
|
|
# 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;
|
2023-06-06 15:38:11 +00:00
|
|
|
rustToolchain = mkRustToolchain { inherit target; };
|
2022-10-04 16:32:44 +00:00
|
|
|
}) 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;
|
|
|
|
|
2022-12-08 16:33:12 +00:00
|
|
|
# nix develop .#wasm
|
|
|
|
wasm = devShells.wasm32-unknown-unknown;
|
|
|
|
|
2022-10-04 16:32:44 +00:00
|
|
|
# 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;
|
|
|
|
};
|
2023-06-06 15:38:11 +00:00
|
|
|
extraComponents = with fenix.packages.${system}; [ targets.${target}.stable.rust-src rust-analyzer targets.${target}.stable.rustfmt ];
|
|
|
|
rustToolchain = mkRustToolchain { inherit target extraComponents; };
|
2022-10-04 16:32:44 +00:00
|
|
|
buildSpec = spec.buildSpec;
|
|
|
|
in pkgs.mkShell (buildSpec // {
|
|
|
|
hardeningDisable = [ "fortify" ];
|
|
|
|
|
|
|
|
depsBuildBuild = buildSpec.depsBuildBuild or [ ]
|
2023-08-03 09:55:06 +00:00
|
|
|
++ [ rustToolchain ] ++ (with pkgs; [ nixfmt cargo-watch wasm-pack pre-commit cargo-make]);
|
2022-10-04 16:32:44 +00:00
|
|
|
|
|
|
|
inherit (util) SURREAL_BUILD_METADATA;
|
|
|
|
})) util.platforms);
|
|
|
|
|
|
|
|
# nix run
|
|
|
|
apps.default = flake-utils.lib.mkApp { drv = packages.default; };
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|