Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Commit 3616c38

Browse files
authored
Small Nix documentation improvements (#162)
- Make using Nix the preferred way of building kernels (over Docker). - Add documentation for `pythonCheckInputs`.
1 parent 9e61fba commit 3616c38

3 files changed

Lines changed: 51 additions & 12 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ See [dockerfiles/README.md](./dockerfiles/README.md) for more options, including
4343
# 📚 Documentation
4444

4545
- [Writing Hub kernels](./docs/writing-kernels.md)
46-
- [Building kernels with Docker](./docs/docker.md)
4746
- [Building kernels with Nix](./docs/nix.md)
47+
- [Building kernels with Docker](./docs/docker.md) (for systems without Nix)
4848
- [Local kernel development](docs/local-dev.md) (IDE integration)
4949
- [Why Nix?](./docs/why-nix.md)
5050

docs/docker.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Using the kernel builder with Docker
22

33
<!-- toc -->
4+
45
- [Using the kernel builder with Docker](#using-the-kernel-builder-with-docker)
56
- [Quick Start](#quick-start)
67
- [CLI Interface](#cli-interface)
@@ -16,7 +17,12 @@
1617
- [Building from URL](#building-from-url)
1718
- [Available Docker Images](#available-docker-images)
1819
- [Development](#development)
19-
<!-- tocstop -->
20+
<!-- tocstop -->
21+
22+
**Warning**: we strongly recommend [building kernels with Nix](nix.md).
23+
Using Nix directly makes it easier to cache all dependencies and is more
24+
robust. We provide a Docker image for systems where Nix cannot be
25+
installed.
2026

2127
## Quick Start
2228

@@ -204,12 +210,13 @@ docker run --rm \
204210

205211
The kernel-builder is available in different variants with specific tags:
206212

207-
| Tag | Description |
208-
| --- | ----------- |
209-
| `[SHA]` | Specific commit hash version (example: `ghcr.io/huggingface/kernel-builder:abc123`) |
210-
| `user-[SHA]` | Non root user variant (use when specific permissions are needed) |
213+
| Tag | Description |
214+
| ------------ | ----------------------------------------------------------------------------------- |
215+
| `[SHA]` | Specific commit hash version (example: `ghcr.io/huggingface/kernel-builder:abc123`) |
216+
| `user-[SHA]` | Non root user variant (use when specific permissions are needed) |
211217

212218
All images are available from the GitHub Container Registry:
219+
213220
```
214221
ghcr.io/huggingface/kernel-builder
215222
```

docs/nix.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Using the kernel builder with Nix
22

33
The kernel builder uses Nix for building kernels. You can build or
4-
run the kernels directly if you have [Nix installed](https://nixos.org/download/)
5-
on your system. On systems without Nix you can use the [Docker](./docker.md)
6-
image, which is a wrapper around Nix.
4+
run the kernels directly if you have Nix installed on your system.
5+
We recommend installing Nix in the following way:
6+
7+
- Linux: use the [official Nix installer](https://nixos.org/download/).
8+
- macOS: use the [Determinate Nix installer](https://docs.determinate.systems/determinate-nix/).
79

810
## Getting started
911

@@ -35,9 +37,6 @@ cd examples/activation
3537
nix build . -L
3638
```
3739

38-
You can put this `flake.nix` in your own kernel's root directory to
39-
get add Nix support to your kernel.
40-
4140
## Shell for local development
4241

4342
`kernel-builder` provides shells for developing kernels. In such a shell,
@@ -82,6 +81,39 @@ nix develop -L .#test
8281
python -m pytest tests
8382
```
8483

84+
## Adding test dependencies to development shells
85+
86+
You can add test dependencies to a development or testing shell. Adapt
87+
the kernel's `flake.nix` to use the `pythonCheckInputs` option:
88+
89+
```nix
90+
{
91+
description = "Flake for my kernel";
92+
93+
inputs = {
94+
kernel-builder.url = "github:huggingface/kernel-builder";
95+
};
96+
97+
outputs =
98+
{
99+
self,
100+
kernel-builder,
101+
}:
102+
kernel-builder.lib.genFlakeOutputs {
103+
path = ./.;
104+
rev = self.shortRev or self.dirtyShortRev or self.lastModifiedDate;
105+
106+
# The einops and numpy test dependencies are added here:
107+
pythonCheckInputs = pkgs: with pkgs; [ einops numpy ];
108+
};
109+
}
110+
```
111+
112+
The available packages can be found on [search.nixos.org](https://search.nixos.org/packages?channel=25.05&query=python312Packages).
113+
114+
Keep in mind that these additional dependencies will only be available to
115+
the Nix shells, not the final kernel uploaded to the Hub.
116+
85117
## Building a kernel without `flake.nix`
86118

87119
If a kernels source directory does not have a `flake.nix` file, you can build the

0 commit comments

Comments
 (0)