2023-08-27 22:10:16 +02:00
|
|
|
{
|
|
|
|
description = "rebacs";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
rust-overlay = {
|
|
|
|
url = "github:oxalica/rust-overlay";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-utils.follows = "flake-utils";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
crane = {
|
|
|
|
url = "github:ipetkov/crane";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-utils.follows = "flake-utils";
|
|
|
|
rust-overlay.follows = "rust-overlay";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane}:
|
|
|
|
flake-utils.lib.eachDefaultSystem
|
|
|
|
(system:
|
|
|
|
let
|
|
|
|
overlays = [ (import rust-overlay) ];
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system overlays;
|
|
|
|
};
|
|
|
|
|
|
|
|
rustToolchain = pkgs.rust-bin.nightly.latest.default;
|
|
|
|
|
|
|
|
protoFilter = path: _type: builtins.match ".*proto$" path != null;
|
2023-09-05 17:14:14 +02:00
|
|
|
protoOrCargo = path: type: (protoFilter path type) || (craneLib.filterCargoSources path type);
|
2023-08-27 22:10:16 +02:00
|
|
|
|
|
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
|
|
|
src = pkgs.lib.cleanSourceWith {
|
|
|
|
src = craneLib.path ./.;
|
|
|
|
filter = protoOrCargo;
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs; [ rustToolchain pkg-config ];
|
|
|
|
buildInputs = with pkgs; [ protobuf ];
|
|
|
|
|
|
|
|
commonArgs = {
|
|
|
|
inherit src buildInputs nativeBuildInputs;
|
|
|
|
};
|
|
|
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
|
|
|
|
|
|
bin = craneLib.buildPackage (commonArgs // {
|
|
|
|
inherit cargoArtifacts;
|
|
|
|
});
|
|
|
|
|
|
|
|
dockerImage = pkgs.dockerTools.buildImage {
|
|
|
|
name = "rebacs";
|
|
|
|
tag = "latest";
|
|
|
|
config = {
|
2023-09-05 17:14:14 +02:00
|
|
|
Cmd = [ "${bin}/bin/rebacs_server" ];
|
2023-08-27 22:10:16 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
with pkgs;
|
|
|
|
{
|
|
|
|
packages = {
|
|
|
|
inherit bin dockerImage;
|
|
|
|
default = bin;
|
|
|
|
};
|
|
|
|
devShells.default = mkShell {
|
|
|
|
inputsFrom = [ bin ];
|
|
|
|
};
|
2023-09-28 17:43:24 +02:00
|
|
|
hydra.build = bin;
|
2023-08-27 22:10:16 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|