45 lines
1.3 KiB
Nix
45 lines
1.3 KiB
Nix
# SPDX-License-Identifier: CC0-1.0
|
|
|
|
{ stdenv, nixpkgs, dhallApps, packages }:
|
|
|
|
let inherit (packages.genode) base-nova;
|
|
in nixpkgs.writeScriptBin "nova-image" (with nixpkgs.buildPackages;
|
|
let inherit (stdenv) cc;
|
|
|
|
in ''
|
|
#!${runtimeShell}
|
|
set -eu
|
|
|
|
out="$1"
|
|
shift
|
|
|
|
if [ -e "$out" ]; then
|
|
echo "refusing to overwrite $out as output" > /dev/stderr
|
|
exit 1
|
|
fi
|
|
|
|
CC="${cc}/bin/${cc.targetPrefix}cc"
|
|
LD="${buildPackages.binutils}/bin/${buildPackages.binutils.targetPrefix}ld"
|
|
|
|
TMPDIR="$(${coreutils}/bin/mktemp -d)"
|
|
trap "rm -rf $TMPDIR" err exit
|
|
|
|
export DHALL_PRELUDE=${packages.dhallPrelude}/package.dhall
|
|
export DHALL_GENODE=${packages.dhallGenode}/package.dhall
|
|
${dhallApps.dhall.program} text <<< "${
|
|
./nova-modules.as.dhall
|
|
} ($@)" > "$TMPDIR/modules.as"
|
|
|
|
# compile the boot modules into one object file
|
|
$CC -c -x assembler -o "$TMPDIR/boot_modules.o" "$TMPDIR/modules.as"
|
|
|
|
# link final image
|
|
$LD -nostdlib \
|
|
-T${base-nova.src}/repos/base/src/ld/genode.ld \
|
|
-T${base-nova.src}/repos/base-nova/src/core/core-bss.ld \
|
|
-z max-page-size=0x1000 \
|
|
-Ttext=0x100000 -gc-sections \
|
|
"''${CORE_NOVA:-${base-nova}/lib/core-nova.o}" "$TMPDIR/boot_modules.o" \
|
|
-o "$out"
|
|
'')
|