# SPDX-License-Identifier: CC0-1.0 { system, localSystem, crossSystem, genodepkgs, nixpkgs, apps }: let thisSystem = builtins.getAttr system; inherit (nixpkgs) buildPackages; testPkgs = thisSystem genodepkgs.packages; in rec { runDhallCommand = name: env: script: nixpkgs.runCommand name ({ nativeBuildInputs = [ buildPackages.dhall ]; } // env) '' export XDG_CACHE_HOME=$NIX_BUILD_TOP export DHALL_GENODE="${testPkgs.dhallGenode}/binary.dhall"; ${buildPackages.xorg.lndir}/bin/lndir -silent \ ${testPkgs.dhallGenode}/.cache \ $XDG_CACHE_HOME ${script} ''; linuxScript = name: env: bootDhall: runDhallCommand name env '' dhall to-directory-tree --output $out \ <<< "${./linux-script.dhall} (${bootDhall}) \"$out\"" ''; compileBoot = name: env: bootDhall: runDhallCommand name env '' dhall to-directory-tree --output $out \ <<< "${./compile-boot.dhall} (${bootDhall}) \"$out\"" ''; novaImage = name: env: boot: let inherit (nixpkgs.stdenv) cc; in nixpkgs.stdenv.mkDerivation { name = name + ".image.elf"; # buildInputs = with buildPackages; [ stdenv.cc ]; build = compileBoot name env boot; # CC="${cc}/bin/${cc.targetPrefix}cc" buildCommand = '' # compile the boot modules into one object file $CC -c -x assembler -o "boot_modules.o" "$build/modules_asm" # link final image LD="${buildPackages.binutils}/bin/${buildPackages.binutils.targetPrefix}ld" $LD --strip-all -nostdlib \ -T${testPkgs.genodeSources}/repos/base/src/ld/genode.ld \ -T${testPkgs.genodeSources}/repos/base-nova/src/core/core-bss.ld \ -z max-page-size=0x1000 \ -Ttext=0x100000 -gc-sections \ "${testPkgs.base-nova.coreObj}" boot_modules.o \ -o $out ''; }; mergeManifests = inputs: nixpkgs.writeTextFile { name = "manifest.dhall"; text = with builtins; let f = head: input: if hasAttr "manifest" input then "${head},${input.pname}=${input.manifest}" else abort "${input.pname} does not have a manifest"; in (foldl' f "{" inputs) + "}"; }; }