Skip to content

add a sample flake.nix #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ db

# Dependency directories (remove the comment below to include it)
# vendor/

# Add "use flake" in .envrc to get shell automatically with direnv+nix
/.envrc
/.direnv/
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.PHONY: proto test deps mocks
export GOPRIVATE=github.com/anyproto
export PATH:=deps:$(PATH)

all:
@set -e;
Expand Down Expand Up @@ -35,7 +34,7 @@ proto-execute:
mocks:
echo 'Generating mocks...'
go build -o deps go.uber.org/mock/mockgen
PATH=$(CURDIR)/deps:$(PATH) go generate ./...
go generate ./...

deps:
go mod download
Expand All @@ -47,4 +46,4 @@ test:

replace-gogo-strings:
@echo "Replacing 'github.com/gogo/protobuf' with 'github.com/anyproto/protobuf' in all files recursively..."
LC_CTYPE=C LANG=C find . -type f -name "*.go" | xargs sed -i '' "s|github.com/gogo/protobuf|github.com/anyproto/protobuf|g"
LC_CTYPE=C LANG=C find . -type f -name "*.go" | xargs sed -i "s|github.com/gogo/protobuf|github.com/anyproto/protobuf|g"
126 changes: 126 additions & 0 deletions flake.lock

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

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

outputs = { self, nixpkgs, drpc, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
config = { allowUnfree = true; };
};

any-protoc-gen-gogofaster = pkgs.callPackage ./nix/any-protoc-gen-gogofaster.nix {};
protoc-gen-go-drpc = drpc.defaultPackage.${system};
in {
devShell = pkgs.mkShell {
name = "any-sync";
nativeBuildInputs = [
# our forked proto generator
any-protoc-gen-gogofaster

# drpc generator
protoc-gen-go-drpc

pkgs.go_1_23
# pkgs.gox
pkgs.protobuf3_21
pkgs.pkg-config
pkgs.pre-commit
# todo: govvv, not packaged
];
};
});
}
15 changes: 15 additions & 0 deletions nix/any-protoc-gen-gogofaster.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.buildGoModule rec {
pname = "protoc-gen-gogofaster";
name = pname;
src = pkgs.fetchFromGitHub {
owner = "anyproto";
repo = "protobuf";
rev = "marshal-append";
hash = "sha256-TetJNcPn0/2Dym/JOLczGax4BEnsLKvJtTZIv1mTMdc=";
};

vendorHash = "sha256-nOL2Ulo9VlOHAqJgZuHl7fGjz/WFAaWPdemplbQWcak=";

doCheck = false;
}