# 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 { linuxScript = name: env: bootDhall: buildPackages.runCommand name ({ inherit name; buildInputs = [ buildPackages.dhall ]; DHALL_GENODE = "${testPkgs.dhallGenode}/binary.dhall"; } // env) '' export XDG_CACHE_HOME=$NIX_BUILD_TOP ${buildPackages.xorg.lndir}/bin/lndir -silent \ ${testPkgs.dhallGenode}/.cache \ $XDG_CACHE_HOME dhall to-directory-tree --output $out \ <<< "${./linux-script.dhall} (${bootDhall}) \"$out\"" ''; compileBoot = name: env: bootDhall: buildPackages.runCommand name ({ inherit name; buildInputs = [ buildPackages.dhall ]; DHALL_GENODE = "${testPkgs.dhallGenode}/binary.dhall"; } // env) '' export XDG_CACHE_HOME=$NIX_BUILD_TOP ${buildPackages.xorg.lndir}/bin/lndir -silent \ ${testPkgs.dhallGenode}/.cache \ $XDG_CACHE_HOME dhall to-directory-tree --output $out \ <<< "${./compile-boot.dhall} (${bootDhall}) \"$out\"" substituteInPlace "$out/modules_asm" \ --replace '.incbin "./config"' ".incbin \"$out/config\"" ${buildPackages.libxml2}/bin/xmllint \ -schema ${testPkgs.genodeSources}/repos/os/src/init/config.xsd \ -noout $out/config ''; 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) + "}"; }; }