https://github.com/numtide/bld
Build nix targets based on git repository directories
https://github.com/numtide/bld
buildbot-numtide monorepo nix
Last synced: about 1 year ago
JSON representation
Build nix targets based on git repository directories
- Host: GitHub
- URL: https://github.com/numtide/bld
- Owner: numtide
- Archived: true
- Created: 2022-09-06T22:08:15.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-31T10:48:17.000Z (over 1 year ago)
- Last Synced: 2025-03-31T11:33:23.658Z (over 1 year ago)
- Topics: buildbot-numtide, monorepo, nix
- Language: Go
- Homepage:
- Size: 69.3 KB
- Stars: 28
- Watchers: 10
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bld
**The experiment is over for now. For most use-cases, something like [blueprint](https://github.com/numtide/blueprint) is good enough.**
bld is an experimental build tool for monorepos inspired by Bazel, and
implemented with Nix. This is meant to evolve and its current form is not the
final one.
This tool has two sides: a CLI and a Nix library, that are meant to be able to
work together.
## Principles
We steal the notion of "targets" from Bazel, making each folder open-ended.
It should be possible to type `bld` in any folder and get the build output of
the current folder (and below?).
It should be possible to build any targets using purely `nix-build`.
## Usage
`$ bld --help`
```
Usage: bld
Flags:
-h, --help Show context-sensitive help.
--debug
Commands:
build []
Build target
list []
List available targets
run []
Run executable target
inspect []
Show build information about target
Run "bld --help" for more information on a command.
```
The following examples are from this repository.
To list all targets.
`$ bld list`
```A
bin
default
devShell
hello
```
To build a target.
`$ bld build hello`
```
INFO[0000] Building target target=hello
/nix/store/9a74wmrh6l9h012xza53ff58v0rx456d-hello
```
To run a target.
`$ bld run hello`
```
/nix/store/9a74wmrh6l9h012xza53ff58v0rx456d-hello
Hello, world!
```
This can be also used to pass flags:
`$ bld run hello -- --help`
```
/nix/store/9a74wmrh6l9h012xza53ff58v0rx456d-hello
Print a friendly, customizable greeting.
-t, --traditional use traditional greeting
-g, --greeting=TEXT use TEXT as the greeting message
--help display this help and exit
--version output version information and exit
Report bugs to: bug-hello@gnu.org
GNU Hello home page:
General help using GNU software:
```
To inspect a target.
`$ bld inspect hello`
```
{
"/nix/store/bn6wpa9yqibcy83d2iabh1s5k49lcpb7-hello.drv": {
"args": [
"-e",
"/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh"
],
"builder": "/nix/store/1b9p07z77phvv2hf6gm9f28syp39f1ag-bash-5.1-p16/bin/bash",
"env": {
"allowSubstitutes": "",
"buildCommand": "target=$out'/bin/hello'\nmkdir -p \"$(dirname \"$target\")\"\n\nif [ -e \"$textPath\" ]; then\n mv \"$textPath\" \"$target\"\nelse\n echo -n \"$text\" > \"$target\"\nfi\n\neval \"$checkPhase\"\n\n(test -n \"$executable\" && chmod +x \"$target\") || true\n",
"buildInputs": "",
"builder": "/nix/store/1b9p07z77phvv2hf6gm9f28syp39f1ag-bash-5.1-p16/bin/bash",
"checkPhase": "/nix/store/1b9p07z77phvv2hf6gm9f28syp39f1ag-bash-5.1-p16/bin/bash -n -O extglob \"$target\"\n",
"cmakeFlags": "",
"configureFlags": "",
"depsBuildBuild": "",
"depsBuildBuildPropagated": "",
"depsBuildTarget": "",
"depsBuildTargetPropagated": "",
"depsHostHost": "",
"depsHostHostPropagated": "",
"depsTargetTarget": "",
"depsTargetTargetPropagated": "",
"doCheck": "",
"doInstallCheck": "",
"enableParallelBuilding": "1",
"enableParallelChecking": "1",
"executable": "1",
"mesonFlags": "",
"name": "hello",
"nativeBuildInputs": "",
"out": "/nix/store/9a74wmrh6l9h012xza53ff58v0rx456d-hello",
"outputs": "out",
"passAsFile": "buildCommand text",
"patches": "",
"preferLocalBuild": "1",
"propagatedBuildInputs": "",
"propagatedNativeBuildInputs": "",
"stdenv": "/nix/store/p93ivxvrf3c2w02la2c6nppmkgdh08y3-stdenv-linux",
"strictDeps": "",
"system": "x86_64-linux",
"text": "#!/nix/store/1b9p07z77phvv2hf6gm9f28syp39f1ag-bash-5.1-p16/bin/bash\n/nix/store/y4mxrg8c6l09lb2szl69vwl4f6441i5k-hello-2.12.1/bin/hello\n\n"
},
"inputDrvs": {
"/nix/store/6pj63b323pn53gpw3l5kdh1rly55aj15-bash-5.1-p16.drv": [
"out"
],
"/nix/store/g6qkwa2xaq6i40cwl9bpjxi19m7q8121-hello-2.12.1.drv": [
"out"
],
"/nix/store/zq638s1j77mxzc52ql21l9ncl3qsjb2h-stdenv-linux.drv": [
"out"
]
},
"inputSrcs": [
"/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh"
],
"outputs": {
"out": {
"path": "/nix/store/9a74wmrh6l9h012xza53ff58v0rx456d-hello"
}
},
"system": "x86_64-linux"
}
}
```
## Future ideas
* Resolve the targets purely with Nix. It should be necessary to connect the
BUILD.nix files manually like currently.
* Snapshot nixpkgs. In order to speed-up nixpkgs, we want to be able to
snapshot the build outputs that we are going to use.
* Add nix evaluation caching to speed-up builds.
* Introduce incremental rebuild Nix libraries for various languages.
* Hook in pre-processing tools. It should be possible to update a third-party
package hash automatically.