diff --git a/flake.nix b/flake.nix --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,7 @@ localOverlay = import ./nix/overlay.nix; overlays = [ localOverlay + (_: _: { commSrc = toString self; }) ]; # Since we build for many systems (e.g. aarch64, x86_64-linux), we diff --git a/nix/blob.nix b/nix/blob.nix new file mode 100644 --- /dev/null +++ b/nix/blob.nix @@ -0,0 +1,40 @@ +{ stdenv +, lib +, rustPlatform +, fetchFromGitHub +, commSrc +, protobuf_3_15_cmake +, dockerTools +}: + +let + blob = rustPlatform.buildRustPackage rec { + pname = "blob"; + version = "0.0.1"; + + src = commSrc; + + prePatch = "cd services/blob"; + + cargoLock.lockFile = ../services/blob/Cargo.lock; + + nativeBuildInputs = [ + protobuf_3_15_cmake + ]; + + # Expose docker image for linux platforms + passthru = lib.optionalAttrs stdenv.isLinux { + dockerImage = dockerTools.buildImage { + name = "comm-blob"; + tag = "latest"; + contents = [ blob ]; + config.Cmd = [ "/bin/blob" ]; + } + }; + + meta = with lib; { + license = licenses.mit; + }; + }; +in + blob diff --git a/nix/overlay.nix b/nix/overlay.nix --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -49,6 +49,8 @@ nativeBuildInputs = (o.nativeBuildInputs or []) ++ [ prev.cmake ]; }); + comm-blob = final.callPackage ./blob.nix { }; + protobuf_3_15_cmake = prev.callPackage ./protobuf_3_15.nix { }; devShells.default = final.callPackage ./dev-shell.nix { };