Add inline documentation
This commit is contained in:
parent
707ec1828c
commit
4c0a6e94f4
67
flake.nix
67
flake.nix
|
@ -6,15 +6,22 @@
|
|||
outputs = { self, nixpkgs, nimble }:
|
||||
let
|
||||
systems = {
|
||||
localSystem = [ "x86_64-linux" ];
|
||||
crossSystem = [ "aarch64-genode" "x86_64-genode" ];
|
||||
localSystem = [ "x86_64-linux" ]; # build platforms
|
||||
crossSystem = [ "aarch64-genode" "x86_64-genode" ]; # target platforms
|
||||
};
|
||||
systemSpace = nixpkgs.lib.cartesianProductOfSets systems;
|
||||
|
||||
forAllLocalSystems = f:
|
||||
systemSpace =
|
||||
# All combinations of build and target systems
|
||||
nixpkgs.lib.cartesianProductOfSets systems;
|
||||
|
||||
forAllLocalSystems =
|
||||
# Apply a function over all self-hosting (Linux) systems.
|
||||
f:
|
||||
nixpkgs.lib.genAttrs systems.localSystem (system: f system);
|
||||
|
||||
forAllCrossSystems = f:
|
||||
forAllCrossSystems =
|
||||
# Apply a function over all cross-compiled systems (Genode).
|
||||
f:
|
||||
with builtins;
|
||||
let
|
||||
f' = { localSystem, crossSystem }:
|
||||
|
@ -27,7 +34,9 @@
|
|||
attrSet = listToAttrs list;
|
||||
in attrSet;
|
||||
|
||||
forAllSystems = f:
|
||||
forAllSystems =
|
||||
# Apply a function over all Linux and Genode systems.
|
||||
f:
|
||||
(forAllCrossSystems f) // (forAllLocalSystems (system:
|
||||
f {
|
||||
inherit system;
|
||||
|
@ -38,7 +47,9 @@
|
|||
in rec {
|
||||
|
||||
overlay =
|
||||
# Overlay of fixes applied to Nixpkgs
|
||||
# Overlay of adjustments applied to Nixpkgs as well as
|
||||
# the "genodePackages" set which the "packages"
|
||||
# output of this flake is taken.
|
||||
import ./overlay { flake = self; };
|
||||
|
||||
lib =
|
||||
|
@ -46,16 +57,16 @@
|
|||
nixpkgs.lib.extend (final: prev: {
|
||||
inherit forAllSystems forAllLocalSystems forAllCrossSystems;
|
||||
|
||||
/* For a the name of a derivation output and a derivation,
|
||||
generate a set of { cap, closure, and path } for a singular
|
||||
file found within the subdirectory of the output with the
|
||||
same name as that output. In the case that the derivation
|
||||
does not have this named output, the subdirectory will be
|
||||
taken from the default output. This subdirectory must
|
||||
contain a single file, and the output must contain an
|
||||
ERIS manifest file.
|
||||
*/
|
||||
getEris = output: pkg:
|
||||
getEris =
|
||||
# For a the name of a derivation output and a derivation,
|
||||
# generate a set of { cap, closure, and path } for a singular
|
||||
# file found within the subdirectory of the output with the
|
||||
# same name as that output. In the case that the derivation
|
||||
# does not have this named output, the subdirectory will be
|
||||
# taken from the default output. This subdirectory must
|
||||
# contain a single file, and the output must contain an
|
||||
# ERIS manifest file.
|
||||
output: pkg:
|
||||
with builtins;
|
||||
let
|
||||
pkg' = prev.getOutput output pkg;
|
||||
|
@ -72,7 +83,10 @@
|
|||
}) erisInfo);
|
||||
in assert length caps == 1; head caps;
|
||||
|
||||
nixosSystem = { modules, ... }@args:
|
||||
nixosSystem =
|
||||
# A derivative of the function for generating Linux NixOS systems.
|
||||
# This one is not so well tested…
|
||||
{ modules, ... }@args:
|
||||
import "${nixpkgs}/nixos/lib/eval-config.nix" (args // {
|
||||
lib = final;
|
||||
|
||||
|
@ -147,10 +161,9 @@
|
|||
|
||||
});
|
||||
|
||||
/* The nixpkgs.legacyPackages after overlaying
|
||||
and with some additional Genode packages.
|
||||
*/
|
||||
legacyPackages = let f = import nixpkgs;
|
||||
legacyPackages =
|
||||
# The nixpkgs.legacyPackages set after overlaying.
|
||||
let f = import nixpkgs;
|
||||
in forAllSystems ({ system, localSystem, crossSystem }:
|
||||
if localSystem == crossSystem then
|
||||
f {
|
||||
|
@ -170,14 +183,16 @@
|
|||
|
||||
packages =
|
||||
# Genode native packages, not packages in the traditional
|
||||
# sense in that these cannot be installed within a profile
|
||||
# sense in that these cannot be installed within a profile.
|
||||
forAllCrossSystems ({ system, localSystem, crossSystem }:
|
||||
nixpkgs.lib.filterAttrs (n: v: v != null)
|
||||
self.legacyPackages.${system}.genodePackages);
|
||||
|
||||
devShell =
|
||||
# Development shell for working with the
|
||||
# upstream Genode source repositories
|
||||
# upstream Genode source repositories. Some
|
||||
# things are missing but everything referred
|
||||
# to by way of #!/usr/bin/ should be here.
|
||||
forAllLocalSystems (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
@ -217,11 +232,11 @@
|
|||
});
|
||||
|
||||
nixosModules =
|
||||
# Modules for composing Genode and NixOS
|
||||
# Modules for composing Genode and NixOS.
|
||||
import ./nixos-modules { flake = self; };
|
||||
|
||||
checks =
|
||||
# Checks for continous testing
|
||||
# Checks for continous testing.
|
||||
let tests = import ./tests;
|
||||
in with (forAllCrossSystems ({ system, localSystem, crossSystem }:
|
||||
tests {
|
||||
|
|
|
@ -28,7 +28,7 @@ let
|
|||
(attrs: { nativeBuildInputs = [ final.autoreconfHook ]; });
|
||||
|
||||
nullPkgs =
|
||||
# Nullify this packages to find problems early
|
||||
# Nullify these packages to find problems early.
|
||||
if hostPlatform.isGenode then
|
||||
builtins.listToAttrs (map (name: {
|
||||
inherit name;
|
||||
|
@ -46,12 +46,17 @@ in nullPkgs // {
|
|||
}) bash;
|
||||
|
||||
binutils-unwrapped = overrideAttrsTarget (attrs: {
|
||||
patches = attrs.patches ++ [ ./binutils/support-genode.patch ];
|
||||
patches = attrs.patches ++ [
|
||||
./binutils/support-genode.patch
|
||||
# Upstreamed, remove at next release.
|
||||
];
|
||||
nativeBuildInputs = attrs.nativeBuildInputs
|
||||
++ [ final.updateAutotoolsGnuConfigScriptsHook ];
|
||||
}) binutils-unwrapped;
|
||||
|
||||
cmake = overrideAttrsTarget (attrs: {
|
||||
cmake =
|
||||
# TODO: upstream
|
||||
overrideAttrsTarget (attrs: {
|
||||
postInstall = with stdenv; ''
|
||||
local MODULE="$out/share/cmake-${
|
||||
lib.versions.majorMinor attrs.version
|
||||
|
@ -85,21 +90,23 @@ in nullPkgs // {
|
|||
});
|
||||
};
|
||||
|
||||
gccForLibs = if targetPlatform.isGenode then
|
||||
final.genodePackages.genodeSources.toolchain.cc
|
||||
else
|
||||
prev.gccForLibs;
|
||||
|
||||
gdb = addPatchesTarget [ ./gdb/genode.patch ] gdb;
|
||||
gdb = addPatchesTarget [
|
||||
./gdb/genode.patch
|
||||
# Upstreamed, remove at next release.
|
||||
] gdb;
|
||||
|
||||
genodeLibcCross = callPackage ./libc { };
|
||||
|
||||
genodePackages = import ../packages {
|
||||
genodePackages =
|
||||
# The Genode-only packages.
|
||||
import ../packages {
|
||||
inherit flake;
|
||||
pkgs = final;
|
||||
};
|
||||
|
||||
grub2 = if stdenv.targetPlatform.isGenode then
|
||||
grub2 =
|
||||
# No need for a Genode build of GRUB.
|
||||
if stdenv.targetPlatform.isGenode then
|
||||
prev.buildPackages.grub2
|
||||
else
|
||||
prev.grub2;
|
||||
|
@ -111,12 +118,20 @@ in nullPkgs // {
|
|||
prev.libcCrossChooser name;
|
||||
|
||||
libsodium = overrideAttrsHost (attrs: {
|
||||
patches = (attrs.patches or [ ]) ++ [ ./libsodium/genode.patch ];
|
||||
patches = (attrs.patches or [ ]) ++ [
|
||||
./libsodium/genode.patch
|
||||
# https://github.com/jedisct1/libsodium/pull/1006
|
||||
];
|
||||
}) libsodium;
|
||||
|
||||
libkrb5 = autoreconfHost libkrb5;
|
||||
libkrb5 =
|
||||
# Do not want.
|
||||
autoreconfHost libkrb5;
|
||||
|
||||
libtool = overrideAttrsTarget (attrs: {
|
||||
libtool =
|
||||
# Autotools related nonesense. Better to compile
|
||||
# everything static than to deal with this one.
|
||||
overrideAttrsTarget (attrs: {
|
||||
nativeBuildInputs = with final;
|
||||
attrs.nativeBuildInputs ++ [ autoconf automake115x ];
|
||||
patches = ./libtool/genode.patch;
|
||||
|
@ -127,7 +142,9 @@ in nullPkgs // {
|
|||
libvpx = null;
|
||||
} libtoxcore;
|
||||
|
||||
linuxPackages = if hostPlatform.isGenode then {
|
||||
linuxPackages =
|
||||
# Dummy package.
|
||||
if hostPlatform.isGenode then {
|
||||
extend = _: final.linuxPackages;
|
||||
features = { };
|
||||
kernel.config = {
|
||||
|
@ -137,7 +154,10 @@ in nullPkgs // {
|
|||
} else
|
||||
linuxPackages;
|
||||
|
||||
llvmPackages_11 = callPackage ./llvm-11 ({
|
||||
llvmPackages_11 =
|
||||
# A copy of the LLVM expressions from Nixpkgs.
|
||||
# Nothing here is upstreamed.
|
||||
callPackage ./llvm-11 ({
|
||||
inherit (stdenvAdapters) overrideCC;
|
||||
buildLlvmTools = buildPackages.llvmPackages_11.tools;
|
||||
targetLlvmLibraries = targetPackages.llvmPackages_11.libraries;
|
||||
|
@ -146,9 +166,14 @@ in nullPkgs // {
|
|||
stdenv = gcc7Stdenv;
|
||||
});
|
||||
|
||||
ncurses = addPatchesHost [ ./ncurses/genode.patch ] ncurses;
|
||||
ncurses =
|
||||
# https://invisible-island.net/autoconf/
|
||||
# Stay clear of upstream on this one.
|
||||
addPatchesHost [ ./ncurses/genode.patch ] ncurses;
|
||||
|
||||
nim = overrideAttrsTarget (attrs: {
|
||||
nim =
|
||||
# Nim is configured to build Genode with GCC.
|
||||
overrideAttrsTarget (attrs: {
|
||||
postInstall = ''
|
||||
sed \
|
||||
-e '/cc = gcc/d' \
|
||||
|
@ -156,7 +181,10 @@ in nullPkgs // {
|
|||
'';
|
||||
}) prev.nim;
|
||||
|
||||
nim-unwrapped = addPatchesTarget [ ./nim/genode.patch ] prev.nim-unwrapped;
|
||||
nim-unwrapped = addPatchesTarget [
|
||||
./nim/genode.patch
|
||||
# Fixes to the compiler and standard libary.
|
||||
] prev.nim-unwrapped;
|
||||
|
||||
openssl =
|
||||
overrideHost { static = true; } # shared library comes out stupid big
|
||||
|
@ -173,7 +201,10 @@ in nullPkgs // {
|
|||
"rm $out/bin/c_rehash"; # eliminate the perl runtime dependency
|
||||
}) openssl);
|
||||
|
||||
patchelf = addPatchesTarget [ ./patchelf/dynstr.patch ] prev.patchelf;
|
||||
patchelf = addPatchesTarget [
|
||||
./patchelf/dynstr.patch
|
||||
# Patch to fix a bug in rewriting the .dynstr section.
|
||||
] prev.patchelf;
|
||||
|
||||
rsync = overrideHost {
|
||||
enableACLs = false;
|
||||
|
@ -190,7 +221,10 @@ in nullPkgs // {
|
|||
tor = overrideAttrsHost (attrs: {
|
||||
configureFlags = attrs.configureFlags or [ ]
|
||||
++ [ "--disable-tool-name-check" ];
|
||||
patches = attrs.patches or [ ] ++ [ ./tor/genode.patch ];
|
||||
patches = attrs.patches or [ ] ++ [
|
||||
./tor/genode.patch
|
||||
# We don't do users and groups here.
|
||||
];
|
||||
postPatch = null; # Avoid torsocks patching
|
||||
}) tor;
|
||||
|
||||
|
|
|
@ -13,7 +13,10 @@ let
|
|||
else
|
||||
throw "unknown Genode arch for platform ${platform.system}";
|
||||
|
||||
upstreamSources = pkgs.fetchFromGitHub {
|
||||
upstreamSources =
|
||||
# This is where the Genode source tree is defined.
|
||||
# Must be updated with ./patches/sources.patch.
|
||||
pkgs.fetchFromGitHub {
|
||||
owner = "genodelabs";
|
||||
repo = "genode";
|
||||
rev = "3fac8b106d83721914797c202793ec1d8ea02d2f";
|
||||
|
@ -21,7 +24,7 @@ let
|
|||
};
|
||||
|
||||
genodeSources =
|
||||
# The Genode source repository
|
||||
# The Genode source repository after patching.
|
||||
let
|
||||
toolPrefix = if platform.isx86 then
|
||||
"genode-x86-"
|
||||
|
@ -56,10 +59,16 @@ let
|
|||
installPhase = "cp -a . $out";
|
||||
};
|
||||
|
||||
portVersions = import "${genodeSources}/ports.nix";
|
||||
portVersions =
|
||||
# Port versions are taken from the sources to force
|
||||
# updates of the port fixed-output derivations.
|
||||
import "${genodeSources}/ports.nix";
|
||||
|
||||
preparePort =
|
||||
# Prepare a "port" of source code declared in the Genode sources
|
||||
# Prepare a "port" of source code declared in the Genode sources.
|
||||
# This is fragile because breakage can appear when the packages
|
||||
# used in preparation are updated, but previously successful
|
||||
# builds will cache.
|
||||
name:
|
||||
{ hash ? "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
|
||||
, patches ? [ ], extraRepos ? [ ], ... }@args:
|
||||
|
@ -122,20 +131,26 @@ let
|
|||
dontFixup = true;
|
||||
});
|
||||
|
||||
ports = lib.mapAttrs preparePort (import ./ports.nix {
|
||||
ports =
|
||||
# The "ports" mechanism is hardly deterministic, so prepare with
|
||||
# a pinned nixpkgs revision for a pinned platform for consistency.
|
||||
lib.mapAttrs preparePort (import ./ports.nix {
|
||||
pkgs = flake.inputs.nixpkgs.legacyPackages.x86_64-linux // {
|
||||
inherit (pkgs) genodePackages;
|
||||
};
|
||||
});
|
||||
# The "ports" mechanism is hardly deterministic, so prepare with
|
||||
# a pinned nixpkgs revision for a pinned platform.
|
||||
|
||||
toolchain = buildPackages.buildPackages.callPackage ./toolchain.nix { };
|
||||
toolchain =
|
||||
# Patched GCC build from upstream.
|
||||
buildPackages.buildPackages.callPackage ./toolchain.nix { };
|
||||
|
||||
stdenv' = pkgs.stdenvAdapters.overrideCC pkgs.stdenv toolchain;
|
||||
stdenv' =
|
||||
# Special stdenv for use within the upstream sources.
|
||||
# TODO: build with Clang.
|
||||
pkgs.stdenvAdapters.overrideCC pkgs.stdenv toolchain;
|
||||
|
||||
buildUpstream =
|
||||
# Build from the Genode sources
|
||||
# Build from the Genode sources using the least recursive make.
|
||||
{ name, targets, portInputs ? [ ], nativeBuildInputs ? [ ], patches ? [ ]
|
||||
, enableParallelBuilding ? true, meta ? { }, ... }@extraAttrs:
|
||||
let havePatches = patches != [ ];
|
||||
|
@ -185,7 +200,7 @@ let
|
|||
});
|
||||
|
||||
buildDepot =
|
||||
# Build a Depot target from the Genode sources
|
||||
# Build from the Genode sources using the depot build system.
|
||||
# WARNING: buildDepot can produce artifacts with broken linkage
|
||||
# to their inputs. The Genode depot mechanism links programs and
|
||||
# libraries to facsimilie stub libraries which are not guaranteed
|
||||
|
@ -209,8 +224,7 @@ let
|
|||
enableParallelBuilding = true;
|
||||
|
||||
nativeBuildInputs = with buildPackages.buildPackages;
|
||||
[ binutils bison flex stdenv.cc tcl which ]
|
||||
++ nativeBuildInputs
|
||||
[ binutils bison flex stdenv.cc tcl which ] ++ nativeBuildInputs
|
||||
++ lib.optional (!stdenv.hostPlatform.isGenode) erisPatchHook;
|
||||
|
||||
buildInputs = buildInputs ++ depotInputs';
|
||||
|
@ -277,7 +291,9 @@ let
|
|||
});
|
||||
in self;
|
||||
|
||||
makePackages = let
|
||||
makePackages =
|
||||
# Build everything in ./make-targets.nix.
|
||||
let
|
||||
overrides = import ./make-targets.nix {
|
||||
inherit (pkgs) buildPackages genodePackages;
|
||||
inherit ports;
|
||||
|
@ -286,6 +302,7 @@ let
|
|||
(name: value: (buildUpstream ({ inherit name; } // value))) overrides;
|
||||
|
||||
depotPackages = lib.attrsets.mapAttrs
|
||||
# Build everything in ./depot-targets.nix.
|
||||
(name: value: (buildDepot ({ inherit name; } // value)))
|
||||
(import ./depot-targets.nix {
|
||||
inherit (pkgs) genodePackages;
|
||||
|
@ -313,7 +330,8 @@ let
|
|||
++ lib.optional isx86_64 "x86_64";
|
||||
|
||||
genodeBase =
|
||||
# A package containing the Genode C++ headers, a stub ld.lib.so and vfs.lib.so
|
||||
# A package containing the Genode C++ headers
|
||||
# and a stub ld.lib.so and vfs.lib.so.
|
||||
buildUpstream {
|
||||
name = "base";
|
||||
targets = [ "LIB=vfs" ];
|
||||
|
@ -342,10 +360,16 @@ let
|
|||
|
||||
in makePackages // depotPackages // {
|
||||
|
||||
genodeSources = genodeSources // {
|
||||
genodeSources =
|
||||
# Expose genodeSources and tuck some extras in with it.
|
||||
genodeSources // {
|
||||
inherit arch buildUpstream buildDepot genodeBase ports specs toolchain;
|
||||
};
|
||||
|
||||
# Builds of the Genode base-systems follow.
|
||||
# These contain the hardware and kernel specific core program,
|
||||
# the loader and base-library, and a timer driver.
|
||||
|
||||
base-hw-pc = buildUpstream {
|
||||
name = "base-hw-pc";
|
||||
outputs = [ "out" "coreObj" "bootstrapObj" ];
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
# Shameless plagiarism of Blitz's toolchain expression:
|
||||
# https://github.com/blitz/genode-nix
|
||||
|
||||
#
|
||||
# WARNING: these binaries are from sourceforge and
|
||||
# have not been publicly verified by Genode Labs.
|
||||
#
|
||||
|
||||
{ lib, stdenv, fetchurl, ncurses5, expat, makeWrapper, wrapCC }:
|
||||
|
||||
let
|
||||
|
|
|
@ -5,9 +5,13 @@ let
|
|||
nixpkgs = flake.legacyPackages.${system};
|
||||
legacyPackages = flake.legacyPackages.${system};
|
||||
|
||||
testingPython = import ./lib/testing-python.nix;
|
||||
testingPython =
|
||||
# Mostly lifted from Nixpkgs.
|
||||
import ./lib/testing-python.nix;
|
||||
|
||||
testSpace = lib.cartesianProductOfSets {
|
||||
testSpace =
|
||||
# Run all tests on all defined Genode platforms
|
||||
lib.cartesianProductOfSets {
|
||||
|
||||
test = map (p: import p) [
|
||||
./ahci.nix
|
||||
|
@ -20,7 +24,8 @@ let
|
|||
|
||||
core = builtins.filter (core:
|
||||
builtins.any (x: x == pkgs.stdenv.hostPlatform.system) core.platforms) [
|
||||
/* {
|
||||
/* # Need to fix the QEMU boot parameters?
|
||||
{
|
||||
prefix = "hw-pc-";
|
||||
testingPython = testingPython {
|
||||
inherit flake system localSystem crossSystem pkgs;
|
||||
|
@ -30,7 +35,8 @@ let
|
|||
platforms = [ "x86_64-genode" ];
|
||||
}
|
||||
*/
|
||||
/* {
|
||||
/* # Need to fix the QEMU boot parameters?
|
||||
{
|
||||
prefix = "hw-virt_qemu-";
|
||||
testingPython = testingPython {
|
||||
inherit flake system localSystem crossSystem pkgs;
|
||||
|
|
Loading…
Reference in New Issue