Skip to content

Commit

Permalink
feat: support macOS Nix
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyklim committed Oct 5, 2024
1 parent 5abb654 commit 91fbd29
Show file tree
Hide file tree
Showing 15 changed files with 3,293 additions and 2,371 deletions.
2 changes: 2 additions & 0 deletions .bazelrc_shared
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
common --announce_rc
common --color=yes

build --host_platform=@rules_nixpkgs_core//platforms:host

build --experimental_strict_action_env

build --strategy=ScalaCompile=worker
Expand Down
46 changes: 41 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ http_archive(
load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
name = "deps",
name = "annex_deps",
artifacts = [
"com.github.scopt:scopt_3:4.1.0",
"org.scala-sbt:librarymanagement-core_3:2.0.0-alpha12",
"org.scala-sbt:librarymanagement-coursier_3:2.0.0-alpha6",
"org.scala-sbt:librarymanagement-core_3:2.0.0-M2",
"org.scala-sbt:librarymanagement-coursier_3:2.0.0-alpha8",
],
fetch_sources = True,
maven_install_json = "//:deps_install.json",
maven_install_json = "@rules_scala3//:annex_deps_install.json",
repositories = [
"https://repo1.maven.org/maven2",
"https://repo.maven.apache.org/maven2",
Expand All @@ -31,9 +31,45 @@ maven_install(
],
)

load("@deps//:defs.bzl", "pinned_maven_install")
load("@annex_deps//:defs.bzl", "pinned_maven_install")

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

rules_cc_version = "0.0.9"

http_archive(
name = "rules_cc",
sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
strip_prefix = "rules_cc-" + rules_cc_version,
url = "https://github.com/bazelbuild/rules_cc/archive/{}.tar.gz".format(rules_cc_version),
)

rules_nixpkgs_tag = "705ee3b26cf49e990cddbbe6f60510fa46d50904"

http_archive(
name = "io_tweag_rules_nixpkgs",
sha256 = "f2c927815c18c088f02ff81caf9903f9c0b2596ac6e6bd40534bc299af9dc0d7",
strip_prefix = "rules_nixpkgs-" + rules_nixpkgs_tag,
url = "https://github.com/tweag/rules_nixpkgs/archive/{}.tar.gz".format(rules_nixpkgs_tag),
)

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

rules_nixpkgs_dependencies()

load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_local_repository", "nixpkgs_cc_configure")

nixpkgs_local_repository(
name = "nixpkgs",
nix_file = "//:nixpkgs.nix",
nix_file_deps = [
"//:flake.lock",
"//:flake.nix",
],
)

nixpkgs_cc_configure(repository = "@nixpkgs")

# ---

Expand Down
2,354 changes: 2,354 additions & 0 deletions annex_deps_install.json

Large diffs are not rendered by default.

152 changes: 76 additions & 76 deletions annex_install.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions deps/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ scala_binary(
scala = "//scala:bootstrap_3",
visibility = ["//visibility:public"],
deps = [
"@deps//:com_github_scopt_scopt_3",
"@deps//:org_scala_sbt_librarymanagement_core_3",
"@deps//:org_scala_sbt_librarymanagement_coursier_3",
"@annex_deps//:com_github_scopt_scopt_3",
"@annex_deps//:org_scala_sbt_librarymanagement_core_3",
"@annex_deps//:org_scala_sbt_librarymanagement_coursier_3",
],
)
1,491 changes: 0 additions & 1,491 deletions deps_install.json

This file was deleted.

8 changes: 7 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
deps-update:
rg -l 'maven_install_json' --glob '*.bzl' --glob 'WORKSPACE' | xargs sed -i 's/maven_install_json/#maven_install_json/g'

bazel run @annex_deps//:pin
bazel run @annex//:pin
bazel run @annex_scalafmt//:pin
bazel run @annex_proto//:pin
cd tests && bazel run @annex_test//:pin

deps-install:
rg -l '#maven_install_json' --glob '*.bzl' --glob 'WORKSPACE' | xargs sed -i 's/#maven_install_json/maven_install_json/g'

REPIN=1 bazel run @unpinned_annex_deps//:pin
REPIN=1 bazel run @unpinned_annex//:pin
REPIN=1 bazel run @unpinned_annex_scalafmt//:pin
REPIN=1 bazel run @unpinned_annex_proto//:pin
cd tests && REPIN=1 bazel run @unpinned_annex_test//:pin

deps-outdated:
bazel run @annex//:outdated
bazel run @annex_deps//:outdated
bazel run @annex_scalafmt//:outdated
bazel run @annex_proto//:outdated
cd tests && bazel run @annex_test//:outdated
Expand Down
7 changes: 7 additions & 0 deletions nixpkgs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
_:

with builtins;
let
flake = getFlake (toString ./.);
in
flake.inputs.nixpkgs.legacyPackages.${currentSystem}
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ in
mkShell {
name = "rules_scala-env";
nativeBuildInputs = [ jdk ];
buildInputs = [ bash bazel_7 bazel-buildtools python3 just fd nixpkgs-fmt ];
buildInputs = [ bash bazel_7 bazel-buildtools python3 just fd ripgrep gnused nixpkgs-fmt ];
LOCALE_ARCHIVE = lib.optionals stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
}
35 changes: 35 additions & 0 deletions tests/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,41 @@ http_archive(
url = "https://github.com/bazelbuild/rules_jvm_external/archive/{}.tar.gz".format(rules_jvm_external_tag),
)

rules_cc_version = "0.0.9"

http_archive(
name = "rules_cc",
sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
strip_prefix = "rules_cc-" + rules_cc_version,
url = "https://github.com/bazelbuild/rules_cc/archive/{}.tar.gz".format(rules_cc_version),
)

rules_nixpkgs_tag = "705ee3b26cf49e990cddbbe6f60510fa46d50904"

http_archive(
name = "io_tweag_rules_nixpkgs",
sha256 = "f2c927815c18c088f02ff81caf9903f9c0b2596ac6e6bd40534bc299af9dc0d7",
strip_prefix = "rules_nixpkgs-" + rules_nixpkgs_tag,
url = "https://github.com/tweag/rules_nixpkgs/archive/{}.tar.gz".format(rules_nixpkgs_tag),
)

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

rules_nixpkgs_dependencies()

load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_local_repository", "nixpkgs_cc_configure")

nixpkgs_local_repository(
name = "nixpkgs",
nix_file = "//:nixpkgs.nix",
nix_file_deps = [
"//:flake.lock",
"//:flake.nix",
],
)

nixpkgs_cc_configure(repository = "@nixpkgs")

local_repository(
name = "rules_scala3",
path = "../",
Expand Down
Loading

0 comments on commit 91fbd29

Please sign in to comment.