You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve examples/ subfolder with cross-compilation and more docs (#25)
- Adds examples for cross-compilation of EIFs in `./examples`, and gives
more detail on what commands to run in order to build EIFs.
- Fixes a bug where the examples lockfile would fail to find the parent
flake if the flake is not already in the Nix store.
- Updates architecture diagram to reflect changes from
#24
- Removes quick start example as it is redundant with `./examples/` and
means maintaining an extra flake in markdown
Copy file name to clipboardExpand all lines: README.md
+19-47Lines changed: 19 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,66 +8,38 @@ You can think of it as an alternative to `nitro-cli build-enclave` for building
8
8
- give users complete control over their enclave images, providing additional options like BYOK (Bring Your Own Kernel)
9
9
- easily build EIFs on systems other than Amazon Linux, including M1+ Macs (e.g, it's possible to build an x86_64 Linux EIF on an ARM Mac)
10
10
11
-
We recommend [this excellent blog post](https://blog.trailofbits.com/2024/02/16/a-few-notes-on-aws-nitro-enclaves-images-and-attestation) to learn more about the EIF Nitro image format in general.
11
+
12
+
> We wrote [a blog post](https://monzo.com/blog/securing-our-software-supply-chain-better-with-reproducible-builds-for)
13
+
> about our motivation for building this tooling at Monzo. We recommend you read it if you use AWS Nitro Enclaves
14
+
> and you are wondering why you might want to use it.
15
+
> We also recommend [this other excellent blog post](https://blog.trailofbits.com/2024/02/16/a-few-notes-on-aws-nitro-enclaves-images-and-attestation) to learn more about the EIF Nitro image format in general.
12
16
13
17
14
18
The tradeoffs between using this repo and AWS' `nitro-cli` are:
| EIF userspace input | Docker container | plain files, including nix packages and unpacked OCI images
18
-
| EIF bootstrap input | pre-compiled kernel binary provided by AWS | use pre-compiled kernel by AWS or bring your own kernel (see [example](./examples/README.md))
| Source-reproducible | no, uses pre-compiled blobs provided by AWS | yes, can be built entirely from source
21
-
| Bit-by-bit reproducible EIFs | no, EIFs are timestamped | yes, building the same EIF will result in the same SHA256
22
-
| cross-architecture EIFs | yes, if you provide a container for the right architecture | yes, if you provide binaries for the right architecture
23
-
| OS* | [Amazon Linux](https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave-cli-install.html) unless you [compile `nitro-cli` from source](https://github.com/aws/aws-nitro-enclaves-cli/tree/main/docs) for other Linux. No MacOS. | any Linux or MacOS with a Nix installation
| EIF userspace input | Docker container | plain files, including nix packages and unpacked OCI images |
23
+
| EIF bootstrap input | pre-compiled kernel binary provided by AWS | use pre-compiled kernel by AWS or bring your own kernel (see [example](./examples/README.md)) |
| Source-reproducible | no, uses pre-compiled blobs provided by AWS | yes, can be built entirely from source |
26
+
| Bit-by-bit reproducible EIFs | no, EIFs are timestamped | yes, building the same EIF will result in the same SHA256 |
27
+
| cross-architecture EIFs | yes, if you provide a container for the right architecture | yes, if you provide binaries for the right architecture |
28
+
| OS*|[Amazon Linux](https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave-cli-install.html) unless you [compile `nitro-cli` from source](https://github.com/aws/aws-nitro-enclaves-cli/tree/main/docs) for other Linux. No MacOS. | any Linux or MacOS with a Nix installation |
25
29
26
30
(*): OS for building EIFs. Note that
27
31
- to make EIFs on a Mac, you have to be able to cross-compile the userspace binaries from Darwin to Linux
28
32
- even if you make an EIF on a Mac, it can still only run on Linux.
29
33
30
34
## Examples
31
35
32
-
Flake quick start, to build an enclave with nixpkgs' `hello` :
You can find examples in [`examples/`](./examples/README.md).
65
37
66
-
See more examples in [`examples/`](./examples/).
38
+
Note that you need to install [Nix](https://nixos.org/) and [enable flakes](https://nixos.wiki/wiki/Flakes) to use this repo.
67
39
68
40
## Design
69
41
70
-
monzo/aws-nitro-util is made up of a small CLI that wraps [aws/aws-nitro-enclaves-image-format](https://github.com/aws/aws-nitro-enclaves-image-format/) (which allows building an EIF from a specific file structure) and of Nix utilities to reproducibly build the CLI and its inputs.
42
+
monzo/aws-nitro-util compiles a CLI from [aws/aws-nitro-enclaves-image-format](https://github.com/aws/aws-nitro-enclaves-image-format/) (which allows building an EIF from a specific file structure) and of Nix utilities to reproducibly build AWS' tooling, the EIF, and its dependencies.
71
43
72
44
A typical EIF build would look like the following:
73
45
@@ -96,7 +68,7 @@ graph TD
96
68
yourRepo("your source code \n or OCI image")
97
69
end
98
70
initBin("init \n compiled init.c \n (or bring your own)")
Examples are structured as a single flake containing packages of potential EIFs.
3
+
You need to install [Nix](https://nixos.org/) and [enable flakes](https://nixos.wiki/wiki/Flakes) to use this repo.
4
+
Examples are structured as an additional Nix flake containing [derivations](https://zero-to-nix.com/concepts/derivations) (ie, build recipes, like Dockerfiles) for potential EIFs.
4
5
5
6
To see the overall plumbing to use the aws-nitro-util flake, see [flake.nix](./flake.nix).
6
7
7
8
To see examples for specific EIFs, see the individual package definitions:
8
9
9
10
- Booting an enclave with a shell script only: [`withShellScript.nix`](./withShellScript.nix)
10
-
- Booting an enclave with your own, compiled-from-source kernel: [`bringYourOwnKernel.nix`](./bringYourOwnKernel.nix)
11
+
- Booting an enclave with your own, compiled-from-source kernel: [`bringYourOwnKernel.nix`](./bringYourOwnKernel.nix)
12
+
13
+
## Building the examples
14
+
15
+
### To show what examples can be built
16
+
17
+
```bash
18
+
nix flake show
19
+
```
20
+
21
+
### To build `shellScriptEif` for your current architecture:
22
+
```bash
23
+
nix build '.#shellScriptEif'
24
+
```
25
+
Note this will produce an `aarch64-linux` EIF if you are running it in an ARM Mac.
26
+
27
+
28
+
### To build for a different architecture via a remote builder
29
+
Nix allows compiling 'natively' for other architectures by building in a different machine.
30
+
31
+
To do this you need to set up a [linux remote builder](https://nix.dev/manual/nix/2.18/advanced-topics/distributed-builds) first.
32
+
This can be any machine you can SSH into, including a VM.
33
+
34
+
Then, for example, to compile EIFs natively for `x86_64-linux` on an ARM Mac:
0 commit comments