Skip to content

Commit f0bba32

Browse files
authored
Merge pull request #103 from tweag/cb/stack-nixpkgs
Use stack from nixpkgs
2 parents c4cd8d0 + c81e712 commit f0bba32

File tree

6 files changed

+58
-15
lines changed

6 files changed

+58
-15
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
build --host_platform=@rules_nixpkgs_core//platforms:host
2+
13
# Remote Cache Configuration
24
build:remote-cache --bes_results_url=https://app.buildbuddy.io/invocation/
35
build:remote-cache --bes_backend=grpcs://remote.buildbuddy.io

.github/workflows/workflow.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ jobs:
4242
- name: Configure
4343
run: |
4444
cat >>.bazelrc.local <<EOF
45-
build --host_platform=@io_tweag_rules_nixpkgs//nixpkgs/platforms:host
4645
build --config=remote-cache
4746
build --repository_cache=~/repo-cache/
4847
EOF
@@ -75,7 +74,7 @@ jobs:
7574
- name: Test for buildifier suggestions
7675
uses: tweag/run-nix-shell@v0
7776
with:
78-
run: bazel run //:buildifier-diff
77+
run: bazel test //:buildifier-test
7978

8079
all_ci_tests:
8180
runs-on: ubuntu-latest

BUILD.bazel

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
1+
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier", "buildifier_test")
22

33
exports_files(["defs.bzl"])
44

5-
buildifier(
6-
name = "buildifier-diff",
5+
_lint_warnings = [
6+
"-module-docstring", # disable module docstrings
7+
]
8+
9+
buildifier_test(
10+
name = "buildifier-test",
11+
buildifier = "@buildifier//:buildifier",
712
diff_command = "diff -u",
8-
mode = "diff",
13+
lint_mode = "warn",
14+
lint_warnings = _lint_warnings,
15+
no_sandbox = True,
16+
workspace = ":WORKSPACE",
917
)
1018

1119
buildifier(
1220
name = "buildifier",
13-
lint_mode = "warn",
21+
buildifier = "@buildifier//:buildifier",
22+
lint_mode = "fix",
23+
lint_warnings = _lint_warnings,
1424
)

WORKSPACE

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ rules_haskell_dependencies()
6565
load(
6666
"@rules_nixpkgs_core//:nixpkgs.bzl",
6767
"nixpkgs_local_repository",
68+
"nixpkgs_package",
6869
)
6970
load(
7071
"@rules_nixpkgs_python//:python.bzl",
@@ -78,7 +79,15 @@ nixpkgs_local_repository(
7879

7980
nixpkgs_python_configure(repository = "@nixpkgs")
8081

81-
load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot")
82+
nixpkgs_package(
83+
name = "stack",
84+
attribute_path = "stack",
85+
repository = "@nixpkgs",
86+
)
87+
88+
load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot", "use_stack")
89+
90+
use_stack("@stack//:bin/stack")
8291

8392
######################################
8493
# Haskell dependencies and toolchain
@@ -195,9 +204,14 @@ gazelle_dependencies()
195204
# Buildifier preamble
196205
#######################
197206

198-
http_archive(
199-
name = "com_github_bazelbuild_buildtools",
200-
sha256 = "53119397bbce1cd7e4c590e117dcda343c2086199de62932106c80733526c261",
201-
strip_prefix = "buildtools-8.2.1",
202-
url = "https://github.com/bazelbuild/buildtools/archive/refs/tags/v8.2.1.tar.gz",
207+
nixpkgs_package(
208+
name = "buildifier",
209+
attribute_path = "buildifier",
210+
build_file_content = """\
211+
filegroup(
212+
name = "buildifier",
213+
srcs = ["bin/buildifier"],
214+
visibility = ["//visibility:public"]
215+
)""",
216+
repository = "@nixpkgs",
203217
)

example/WORKSPACE

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ rules_haskell_dependencies()
5353
load(
5454
"@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl",
5555
"nixpkgs_local_repository",
56+
"nixpkgs_package",
5657
"nixpkgs_python_configure",
5758
)
5859

@@ -63,7 +64,15 @@ nixpkgs_local_repository(
6364

6465
nixpkgs_python_configure(repository = "@nixpkgs")
6566

66-
load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot")
67+
nixpkgs_package(
68+
name = "stack",
69+
attribute_path = "stack",
70+
repository = "@nixpkgs",
71+
)
72+
73+
load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot", "use_stack")
74+
75+
use_stack("@stack//:bin/stack")
6776

6877
######################################
6978
# Haskell dependencies and toolchain

tests/alternative-deps/WORKSPACE

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ rules_haskell_dependencies()
5353
load(
5454
"@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl",
5555
"nixpkgs_local_repository",
56+
"nixpkgs_package",
5657
"nixpkgs_python_configure",
5758
)
5859

@@ -63,7 +64,15 @@ nixpkgs_local_repository(
6364

6465
nixpkgs_python_configure(repository = "@nixpkgs")
6566

66-
load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot")
67+
nixpkgs_package(
68+
name = "stack",
69+
attribute_path = "stack",
70+
repository = "@nixpkgs",
71+
)
72+
73+
load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot", "use_stack")
74+
75+
use_stack("@stack//:bin/stack")
6776

6877
######################################
6978
# Haskell dependencies and toolchain

0 commit comments

Comments
 (0)