2
0
Fork 0
genodepkgs/README.md

244 lines
8.0 KiB
Markdown
Raw Normal View History

2020-01-24 14:45:31 +01:00
```
______ __ __
/ ____/__ ____ ____ ____/ /__ ____ / / ____ ______
/ / __/ _ \/ __ \/ __ \/ __ / _ \/ __ \/ / / __ `/ ___/
/ /_/ / __/ / / / /_/ / /_/ / __/ /_/ / , \ /_/ (__ )
\____/\___/_/ /_/\____/\__,_/\___/ .___/_/ \_\_, /____/
/_/ /____/
```
2019-09-24 02:17:43 +02:00
2020-04-05 10:01:11 +02:00
[Genodepkgs](https://git.sr.ht/~ehmry/genodepkgs) is nexus of
2020-01-24 14:45:31 +01:00
[Nix](https://nixos.org/nix/) expressions related to the
[Genode OS framework](https://genode.org).
2019-09-24 02:17:43 +02:00
2020-04-08 10:22:49 +02:00
**IRC:** irc://oftc.net/#genodepkgs
2020-01-27 11:46:41 +01:00
2020-04-08 10:22:49 +02:00
**Mailing List:** https://lists.sr.ht/~ehmry/genodepkgs
2020-01-27 11:46:41 +01:00
2020-01-24 14:45:31 +01:00
# Contributing
2019-09-24 02:17:43 +02:00
2020-04-05 10:01:11 +02:00
At the moment every user needs to also act as distro developer, designing how
packaging works needs to be done before packages can be submitted at will.
2020-01-24 14:45:31 +01:00
Patches can be submitted and issues reported via the
2020-04-05 10:01:11 +02:00
[mailing list](https://lists.sr.ht/~ehmry/genodepkgs). The mailing list is the
2020-01-24 14:45:31 +01:00
minimum viable mechanism for community development, and may be replaced later.
2019-09-30 13:39:26 +02:00
2020-01-24 14:45:31 +01:00
The worksites at the moment are:
2019-09-30 13:39:26 +02:00
2020-04-05 10:01:11 +02:00
- Generation of documentation on internal types and functions. By generating a
comprehensive single document early, we should be able to refactor and prune
2020-01-24 14:45:31 +01:00
the internals faster.
2019-09-30 13:39:26 +02:00
2020-04-08 10:22:49 +02:00
- Port tests to the NixOS test harness.
2020-01-24 14:45:31 +01:00
2020-04-05 10:01:11 +02:00
- Patching standard Nixpkgs packages via an overlay. Workflow and tooling
2020-01-24 14:45:31 +01:00
needs to be explored for building emulated UNIX environments.
- LLVM testing and upstreaming patches.
- Formalizing Dhall configuration types.
- Configuration validation via a service routing prover.
2020-04-08 10:22:49 +02:00
# Packaging
Packaging is done using standard Nixpkgs methods, a `stdenv` is available for
cross-compilation. See [Solo5](./packages/solo5/default.nix) as an example.
# System description format
The high-level interface to system building are boot descriptions. These Dhall
documents describe the configuration of an [Init](https://genode.org/documentation/genode-foundations/19.05/system_configuration/The_init_component.html)
instance and a store of ROM (Read-Only Memory) modules. These description can be
used to build firmware-like binary images or merged and nested within other
descriptions. In theory these descriptions can arrange file-systems, but those
functions are missing.
The description schema is documented as code:
https://git.sr.ht/~ehmry/dhall-genode/tree/master/Boot/package.dhall
2020-01-24 14:45:31 +01:00
# Nix Flakes
2020-04-05 10:01:11 +02:00
This repository is structured as a Nix flake, which is an experimental extension
of Nix tooling. The flakes capable Nix frontend is available from Nixpkgs as
2020-01-24 14:45:31 +01:00
`nixFlakes`.
## Switching to flakes
2020-04-05 10:01:11 +02:00
All users regardless of distro must add the following to
2020-01-24 14:45:31 +01:00
*~/.config/nix/nix.conf* to enable flakes:
```
experimental-features = nix-command flakes ca-references
```
NixOS users may switch to flakes using the following configuration:
```nix
{ pkgs, ... }:
{
nix.package = pkgs.nixFlakes;
# The following enables the use of a binary cache
nix.binaryCaches = [ "https://cache.server7.hq.c3d2.de" ];
nix.binaryCachePublicKeys = [
"cache.server7.hq.c3d2.de:x8JLRG26zRZ8ysYZLEkPxuAYuK1VSJi/aMAEIs2Lv+U="
];
}
```
Non-NixOS users may install flakes using the following shell commands:
```sh
$ curl https://nixos.org/nix/install | sh
$ nix-env -iA nixpkgs.nixFlakes
```
Add will want to add this to their */etc/nix/nix.conf* file:
```
substituters = https://cache.nixos.org/ https://cache.server7.hq.c3d2.de/
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.server7.hq.c3d2.de:x8JLRG26zRZ8ysYZLEkPxuAYuK1VSJi/aMAEIs2Lv+U=
```
## Building from flakes
### As a user
```sh
$ nix flake add genodepkgs git+https://git.sr.ht/~ehmry/genodepkgs
2020-01-25 12:39:54 +01:00
$ nix build genodepkgs#checks.x86_64-linux-x86_64-genode.nova-pci
2020-01-24 14:45:31 +01:00
# View the log if the result is already cached:
2020-01-25 12:39:54 +01:00
$ nix log genodepkgs#checks.x86_64-linux-x86_64-genode.nova-pci
2020-01-24 14:45:31 +01:00
```
### As a hacker
```sh
$ git clone https://git.sr.ht/~ehmry/genodepkgs
$ cd genodepkgs
2020-01-25 12:39:54 +01:00
$ nix build .#checks.x86_64-linux-x86_64-genode.nova-pci
2020-01-24 14:45:31 +01:00
# View the log if the result is already cached:
2020-01-25 12:39:54 +01:00
$ nix log .#checks.x86_64-linux-x86_64-genode.nova-pci
2020-01-24 14:45:31 +01:00
```
# Toolchain
The Genode Labs toolchain is available here only for Linux and in binary form.
2020-04-05 10:01:11 +02:00
However, an experimental LLVM cross-compiler is provided here. Bootstrapping GCC
2020-01-24 14:45:31 +01:00
has not been practical due to its recursive autotools build system.
# Building
2020-04-05 10:01:11 +02:00
Bootstrapping the build tooling can take several hours on a laptop, therefore it
is recommended enable the binary caches and to farm massive rebuilds to large
multicore machines. The Nix flake is prepared for continuous builds with a
[Hydra](https://nixos.org/hydra/), but only the experimental flakes capable
2020-01-24 14:45:31 +01:00
Hydra.
2020-02-06 12:33:11 +01:00
# Testing
2020-04-05 10:01:11 +02:00
Tests are performed using QEMU and a test driver similiar to what is used by
NixOS (ours has not been ported to Python however). The test artifacts are built
2020-02-06 12:33:11 +01:00
as follows:
```shell
# Build a test log from a QEMU test run:
nix build .#checks.x86_64-linux-x86_64-genode.nova-solo5-net
# Build an ISO of the test run:
nix build .#checks.x86_64-linux-x86_64-genode.nova-solo5-net.iso
# Build the [SOTEST](https://opensource.sotest.io/) artifacts of a test run.
nix build .#checks.x86_64-linux-x86_64-genode.nova-solo5-net.sotest
```
# Tips and tricks
## Render a Dhall Init configuration to XML
```shell
echo ./config.dhall | nix app genodepkgs#render-init > config.xml
```
## Build a Genode Labs Make target
```shell
nix app genodepkgs#genode-make "test/bomb"
```
## Enter an environment compatible with the Genode Labs build scripts
```shell
nix dev-shell genodepkgs
cd $GENODE_DIR
make -C build/x86_64 run/bomb
```
2020-01-24 14:45:31 +01:00
# Glossary
Some of terms that follow are necessary for understanding packaging methodology,
Others are simply introduced as an aid to the reader:
- *Upstream* - repositories packaged by expressions in this repository
- *Downstream* - repositories depending on this repository
2020-04-05 10:01:11 +02:00
- *OS ABI* - The binary interface to an operating system. In the case of Genode
this does not include kernel interfaces, as system calls are abstracted via
2020-01-24 14:45:31 +01:00
dynamically linked procedures.
2020-04-05 10:01:11 +02:00
- `localSystem` - the CPU and OS ABI pair used to evaluate and compile
packages. Genode cannot natively instantiate Nix derivations, therefore it
2020-01-24 14:45:31 +01:00
cannot be a `localSystem` ABI.
2020-04-05 10:01:11 +02:00
- `crossSystem` - the target CPU and OS ABI pair for packages. In the common
case the ABI will be Genode. In the case of tooling it may be the same as
`localSystem`. For software that runs bare-metal the CPU is significant but
2020-01-28 14:11:47 +01:00
ABI is irrelevant.
2020-01-24 14:45:31 +01:00
2020-01-28 14:11:47 +01:00
- `buildPlatform` - equivalent to `localSystem`.
2020-01-24 14:45:31 +01:00
- `hostPlatform` - the platform on which a package will execute.
2020-04-05 10:01:11 +02:00
- `targetPlatform` - the platform for which a package will produce artifacts.
This is only significant for software such as compilers. The respective
2020-01-24 14:45:31 +01:00
build, host, and target platform of a compiler that was built on a Solaris,
2020-04-05 10:01:11 +02:00
executes on Genode, and produces only Haiku binaries would be Solaris,
2020-01-24 14:45:31 +01:00
Genode, and Haiku.
2020-04-05 10:01:11 +02:00
- *Flake* - a code repository containing a `flake.nix` file describing
2020-01-28 14:11:47 +01:00
dependency repositories. The evaluation of flakes may only form ascyclic
2020-01-24 14:45:31 +01:00
graphs. Repositories packaged here may themselves contain a `flake.nix`
file that refers to this repository, but these repositories cannot be inputs
to the Genodepkgs flake.
2020-04-05 10:01:11 +02:00
- *Genode core* - Genode component of highest privilege. The core is located
conceptually at the bottom and root of the component tree. Core might be
directly above the kernel, or acting as the kernel. The role of core is a
2020-01-28 14:11:47 +01:00
subset of the role of the kernel in a monolithic system.
- *Lower* - lowering a subsystem is moving it closer to the Genode core
and increasing privilege.
2020-04-05 10:01:11 +02:00
- *Raise* - raising a subsystem is moving it further away from the Genode core
2020-01-28 14:11:47 +01:00
and decreasing privilege.
2020-01-24 14:45:31 +01:00
- *Package* - *undefined*
# Legal
2020-04-05 10:01:11 +02:00
This repository is for trivial packaging algebra and metadata that exists only
for the sake of richer and more meaningful code in external repositories. All
works committed to this repository, unless otherwise noted, shall be implicitly
2020-01-24 14:45:31 +01:00
licensed under a [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/deed)
public domain dedication.
![CC0 PUBLIC DOMAIN](.CC0-1.0.png)