Skip to content

Commit 204edf2

Browse files
committed
Add Bazel comparison
1 parent de3cd0e commit 204edf2

File tree

6 files changed

+67
-27
lines changed

6 files changed

+67
-27
lines changed

comparison.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Comparison with other tools
2+
3+
This document aims to highlight the differences between zb and other tools.
4+
5+
(bazel)=
6+
## Bazel
7+
8+
Bazel and zb share the very similar goal to build software in a reproducible manner.
9+
zb mostly differs in how it achieves the goal:
10+
11+
- Bazel requires reworking the build graph to be written in terms of [Bazel rules][].
12+
This typically requires surrounding tooling (IDEs, etc.) to be Bazel-aware.
13+
Setting up a zb build process is less involved
14+
because it leverages existing build tooling appropriate for each ecosystem.
15+
You can easily run `zb derivation env` on any build step
16+
to obtain a `.env` file to emulate the build environment.
17+
- zb uses Lua instead of [Starlark][], Bazel's bespoke Python-like language.
18+
zb uses Lua to leverage existing learning resources for Lua.
19+
- Bazel has different APIs for [creating rules][Bazel rules API] and [macros][Bazel macros].
20+
zb does not draw such a distinction:
21+
all build steps invoke a single program.
22+
zb functions can be written to automate creation of build steps.
23+
- zb build artifacts have a consistent file path across hosts
24+
and can have dependencies on other build artifacts.
25+
This eliminates the need for [runfiles][]
26+
and makes dynamic linking simpler.
27+
28+
[Bazel rules]: https://bazel.build/rules
29+
[Bazel rules API]: https://bazel.build/extending/rules
30+
[Bazel macros]: https://bazel.build/extending/macros
31+
[runfiles]: https://bazel.build/reference/be/common-definitions#common.data
32+
[Starlark]: https://bazel.build/rules/language
33+
34+
(nix)=
35+
## Nix
36+
37+
Many of the techniques in zb were pioneered by the [Nix][] package manager.
38+
zb is built on the principles in the [original paper by Eelco Dolstra][@dolstra_purely_2006],
39+
but differs in some key ways:
40+
41+
- zb is focused on building software, not managing packages.
42+
We don't anticipate a large, central package repository for zb
43+
nor a Linux distribution.
44+
There's a lot of overlap in dependency management,
45+
but the audience and affordances differ in subtle ways.
46+
- zb deliberately focuses on broad usability.
47+
For example, zb supports Windows
48+
and uses Lua instead of a domain-specific language.
49+
- zb uses content-addressed derivations.
50+
This is a long-standing [experimental feature in Nix][ca-derivations],
51+
whereas zb does not even support Nix's default "input-addressed" mode.
52+
This was chosen to simplify the architecture,
53+
enable build optimizations,
54+
and prevent build artifact corruption.
55+
56+
[ca-derivations]: https://nix.dev/manual/nix/2.24/development/experimental-features.html#xp-feature-ca-derivations
57+
[@dolstra_purely_2006]: https://edolstra.github.io/pubs/phd-thesis.pdf
58+
[Nix]: https://nixos.org/

conf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
extensions = [
2222
'myst_parser',
2323
'sphinx.ext.githubpages',
24+
'sphinx_reredirects',
2425
'zbluadomain',
2526
'zbtemplatefuncs',
2627
]
@@ -36,8 +37,6 @@
3637
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
3738
primary_domain = 'lua'
3839

39-
40-
4140
# -- Options for HTML output -------------------------------------------------
4241
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
4342

@@ -58,3 +57,7 @@
5857
'pkg/index': 'gopkg.html.jinja',
5958
'pkg/zbstore': 'gopkg.html.jinja',
6059
}
60+
61+
redirects = {
62+
'vs-nix': 'comparison.html',
63+
}

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
python = pkgs.python3.withPackages (ps: [
1313
ps.myst-parser
1414
ps.sphinx
15+
ps.sphinx-reredirects
1516
]);
1617
in
1718
{

index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ If you're new to zb, check out the [Getting Started guide](getting-started.md).
1010
## What is zb?
1111

1212
zb is a tool for reproducibly building software, similar to [Bazel][].
13+
(See the [comparison page](comparison.md#bazel) if you're curious to know the differences.)
1314
When a software build process is [reproducible][@wikipedia_reproducible_2025],
1415
it will produce the exact same output
1516
when given the same inputs.
@@ -73,7 +74,7 @@ zb simplifies reproducible builds.
7374
Installation <install>
7475
getting-started
7576
admin/index
76-
vs-nix
77+
comparison
7778
```
7879

7980
```{toctree}

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
sphinx==8.2.3
2+
sphinx-reredirects==0.1.6
23
myst-parser==4.0.1

vs-nix.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)