Skip to content

Commit

Permalink
Merge pull request #97 from symbiont-io/bazel-nix
Browse files Browse the repository at this point in the history
bazel: add initial nix support
  • Loading branch information
symbiont-stevan-andjelkovic authored Feb 4, 2021
2 parents 5512a8a + 3213dd1 commit 347e42b
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 39 deletions.
8 changes: 6 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
build --action_env=GOPRIVATE=github.com/symbiont-io
run --action_env=GOPRIVATE=github.com/symbiont-io
build --action_env=GOPRIVATE=github.com/symbiont-io \
--host_platform=@io_tweag_rules_nixpkgs//nixpkgs/platforms:host \
--crosstool_top=@local_config_cc//:toolchain
run --action_env=GOPRIVATE=github.com/symbiont-io \
--host_platform=@io_tweag_rules_nixpkgs//nixpkgs/platforms:host \
--crosstool_top=@local_config_cc//:toolchain
39 changes: 37 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@ workspace(name = "detsys_workspace")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Nix
http_archive(
name = "io_tweag_rules_nixpkgs",
strip_prefix = "rules_nixpkgs-0.7.0",
urls = ["https://github.com/tweag/rules_nixpkgs/archive/v0.7.0.tar.gz"],
)

load("@io_tweag_rules_nixpkgs//nixpkgs:repositories.bzl", "rules_nixpkgs_dependencies")
rules_nixpkgs_dependencies()

load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl",
"nixpkgs_cc_configure",
"nixpkgs_git_repository",
"nixpkgs_package",
"nixpkgs_python_configure",
)

# Same revision as we pinned with niv in nix/sources.json. For ticket to add
# niv support, see https://github.com/tweag/rules_nixpkgs/issues/127 .
nixpkgs_git_repository(
name = "nixpkgs",
revision = "cf7475d2061ac3ada4b226571a4a1bb91420b578",
sha256 = "a68da1275af117cf314305aeb86cc9f1cacfa68c8b984efd68ac473d3e4bf6f3"
)

nixpkgs_cc_configure(repository = "@nixpkgs//:default.nix")

nixpkgs_python_configure(
python3_attribute_path = "python3",
repository = "@nixpkgs//:default.nix",
)

# Golang
http_archive(
name = "io_bazel_rules_go",
sha256 = "6f111c57fd50baf5b8ee9d63024874dd2a014b069426156c55adbf6d3d22cb7b",
Expand All @@ -24,6 +57,10 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

# Use go from nixpkgs.
load("@io_tweag_rules_nixpkgs//nixpkgs:toolchains/go.bzl", "nixpkgs_go_configure")
nixpkgs_go_configure(repository = "@nixpkgs//:default.nix")

go_rules_dependencies()

# gazelle will put stuff here
Expand All @@ -33,6 +70,4 @@ load("//:gazelle-ws.bzl", "gazelle_ws")
# gazelle:repository_macro gazelle-ws.bzl%gazelle_ws
gazelle_ws()

go_register_toolchains(version = "1.15.5")

gazelle_dependencies()
38 changes: 26 additions & 12 deletions gazelle-ws.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ def gazelle_ws():
sum = "h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=",
version = "v0.0.0-20151022065526-2efee857e7cf",
)
go_repository(
name = "com_github_andreyvit_diff",
importpath = "github.com/andreyvit/diff",
sum = "h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=",
version = "v0.0.0-20170406064948-c7f18ee00883",
)

go_repository(
name = "com_github_apache_thrift",
importpath = "github.com/apache/thrift",
Expand Down Expand Up @@ -827,8 +834,8 @@ def gazelle_ws():
go_repository(
name = "com_github_mattn_go_runewidth",
importpath = "github.com/mattn/go-runewidth",
sum = "h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=",
version = "v0.0.4",
sum = "h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=",
version = "v0.0.9",
)
go_repository(
name = "com_github_mattn_go_sqlite3",
Expand Down Expand Up @@ -1178,6 +1185,13 @@ def gazelle_ws():
sum = "h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=",
version = "v0.0.0-20170313163322-e2103e2c3529",
)
go_repository(
name = "com_github_sergi_go_diff",
importpath = "github.com/sergi/go-diff",
sum = "h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=",
version = "v1.1.0",
)

go_repository(
name = "com_github_shopify_sarama",
importpath = "github.com/Shopify/sarama",
Expand Down Expand Up @@ -1400,8 +1414,8 @@ def gazelle_ws():
go_repository(
name = "in_gopkg_check_v1",
importpath = "gopkg.in/check.v1",
sum = "h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=",
version = "v1.0.0-20180628173108-788fd7840127",
sum = "h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=",
version = "v1.0.0-20190902080502-41f04d3bba15",
)
go_repository(
name = "in_gopkg_cheggaaa_pb_v1",
Expand Down Expand Up @@ -1461,8 +1475,8 @@ def gazelle_ws():
go_repository(
name = "in_gopkg_yaml_v2",
importpath = "gopkg.in/yaml.v2",
sum = "h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=",
version = "v2.2.2",
sum = "h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=",
version = "v2.2.4",
)
go_repository(
name = "io_etcd_go_bbolt",
Expand Down Expand Up @@ -1579,14 +1593,14 @@ def gazelle_ws():
go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=",
version = "v0.0.0-20190412213103-97732733099d",
sum = "h1:XtNJkfEjb4zR3q20BBBcYUykVOEMgZeIUOpBPfNYgxg=",
version = "v0.0.0-20201017003518-b09fb700fbb7",
)
go_repository(
name = "org_golang_x_text",
importpath = "golang.org/x/text",
sum = "h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=",
version = "v0.3.0",
sum = "h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=",
version = "v0.3.3",
)
go_repository(
name = "org_golang_x_time",
Expand All @@ -1598,8 +1612,8 @@ def gazelle_ws():
go_repository(
name = "org_golang_x_tools",
importpath = "golang.org/x/tools",
sum = "h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs=",
version = "v0.0.0-20191029190741-b9c20aec41a5",
sum = "h1:FDhOuMEY4JVRztM/gsbk+IKUQ8kj74bxZrgw87eMMVc=",
version = "v0.0.0-20180917221912-90fa682c2a6e",
)
go_repository(
name = "org_golang_x_xerrors",
Expand Down
16 changes: 12 additions & 4 deletions src/debugger/internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "internal",
srcs = ["debugger.go"],
srcs = [
"debugger.go",
"sequence.go",
],
importpath = "github.com/symbiont-io/detsys-testkit/src/debugger/internal",
visibility = ["//src/debugger:__subpackages__"],
deps = [
"//src/lib",
"@com_github_evanphx_json_patch//:json-patch",
"@com_github_mattn_go_sqlite3//:go-sqlite3",
"@com_github_nsf_jsondiff//:jsondiff",
"@com_github_andreyvit_diff//:diff",
],
)

go_test(
name = "internal_test",
srcs = ["debugger_test.go" "sequence_test.go"],
srcs = [
"debugger_test.go",
"sequence_test.go",
],
embed = [":internal"],
deps = ["//src/lib"],
deps = [
"//src/lib",
"@com_github_andreyvit_diff//:diff",
],
)
7 changes: 0 additions & 7 deletions src/executor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@ go_library(
deps = [
"//src/lib",
"@com_github_evanphx_json_patch//:json-patch",
"@com_github_mattn_go_sqlite3//:go-sqlite3",
"@org_uber_go_zap//:zap",
"@org_uber_go_zap//zapcore",
],
)

go_test(
name = "lib_test",
srcs = ["executor_test.go"],
embed = [":executor"],
)

go_test(
name = "executor_test",
srcs = ["executor_test.go"],
Expand Down
2 changes: 1 addition & 1 deletion src/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func TestSchedulerContractFault(t *testing.T) {
func TestSchedulerContractOutput(t *testing.T) {
output := []lib.OutEvent{
lib.OutEvent{
To: "client:0",
To: lib.Singleton("client:0"),
Args: &lib.ClientResponse{
Id: 0,
Response: Value{1},
Expand Down
2 changes: 1 addition & 1 deletion src/lib/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ go_library(
"ldfi.go",
"lib.go",
"marshaler.go",
"topology.go",
"scheduler.go",
"topology.go",
"util.go",
],
importpath = "github.com/symbiont-io/detsys-testkit/src/lib",
Expand Down
14 changes: 4 additions & 10 deletions src/logger/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_binary(
name = "logger",
embed = [":logger_lib"],
visibility = ["//visibility:public"],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "logger_lib",
srcs = ["main.go"],
srcs = ["lib.go"],
importpath = "github.com/symbiont-io/detsys-testkit/src/logger",
visibility = ["//visibility:private"],
deps = [
"@com_github_mattn_go_sqlite3//:go-sqlite3",
"//src/lib",
],
)
)

0 comments on commit 347e42b

Please sign in to comment.