Skip to content

Commit

Permalink
Merge pull request #1616 from anyproto/go-4166-add-nix-devshell-with-…
Browse files Browse the repository at this point in the history
…build-deps

add nix flake with devShell
  • Loading branch information
zarkone authored Sep 26, 2024
2 parents 4bd81c7 + 71de5d4 commit 29aaa25
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 1 deletion.
16 changes: 15 additions & 1 deletion docs/Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ We need to have protoc binary (3.x version) and libprotoc headers in orderto bui
```
apt install protobuf-compiler libprotoc-dev
```

#### Nix

Repository provides `flake.nix` with `devShell` which has all the build dependencies (excluding tentivy-go pre-compiled libraries yet).

```bash
nix develop .
```
> [!TIP]
> It is also convenient to use nix shell with [direnv](https://direnv.net/) with [nix-direnv](https://github.com/nix-community/nix-direnv),
> which enables `devShell` when you `cd` into directory.
>
> With direnv, you can also switch environments per project in your code editor: [emacs-direnv](https://github.com/wbolster/emacs-direnv)
### Install custom protoc
`make setup-protoc` to install grpc-web plugin (see [Protogen](https://github.com/anyproto/anytype-heart/blob/main/docs/Protogen.md) for additional information)

Expand All @@ -44,4 +58,4 @@ Instructions to setup environment for Android: [here](https://github.com/anyprot

Parameters:
- `ANY_SYNC_NETWORK=/path/to/network.yml` — build using self-hosted [network configuration](https://tech.anytype.io/anytype-heart/configuration)
2. `make protos-java` to generate java protobuf bindings into `dist/android/pb`
2. `make protos-java` to generate java protobuf bindings into `dist/android/pb`
59 changes: 59 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
description = "";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.0.tar.gz";
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
config = { allowUnfree = true; };
};
in {
devShell = pkgs.mkShell {
name = "anytype-heart";
nativeBuildInputs = [
pkgs.protoc-gen-grpc-web
pkgs.go_1_22
pkgs.gox
pkgs.protobuf3_20
pkgs.pkg-config
pkgs.pre-commit
# todo: govvv, not packaged
];
};
});
}

0 comments on commit 29aaa25

Please sign in to comment.