2
0
Fork 0
genodepkgs/lib/default.nix

83 lines
2.5 KiB
Nix
Raw Normal View History

2020-01-17 01:24:34 +01:00
# SPDX-License-Identifier: CC0-1.0
2020-03-27 08:05:41 +01:00
{ system, localSystem, crossSystem, genodepkgs, nixpkgs, apps }:
2019-11-10 09:42:12 +01:00
let
2020-01-14 12:16:02 +01:00
thisSystem = builtins.getAttr system;
2020-04-05 10:01:11 +02:00
inherit (nixpkgs) buildPackages;
2019-12-02 16:39:52 +01:00
testPkgs = thisSystem genodepkgs.packages;
2019-11-10 09:42:12 +01:00
2020-04-05 10:01:11 +02:00
in rec {
linuxScript = name: env: bootDhall:
buildPackages.runCommand name ({
inherit name;
buildInputs = [ buildPackages.dhall ];
DHALL_GENODE = "${testPkgs.dhallGenode}/binary.dhall";
} // env) ''
2019-11-10 09:42:12 +01:00
export XDG_CACHE_HOME=$NIX_BUILD_TOP
2020-04-05 10:01:11 +02:00
${buildPackages.xorg.lndir}/bin/lndir -silent \
${testPkgs.dhallGenode}/.cache \
$XDG_CACHE_HOME
dhall to-directory-tree --output $out \
<<< "${./linux-script.dhall} (${bootDhall}) \"$out\""
2019-11-10 09:42:12 +01:00
'';
2020-04-05 10:01:11 +02:00
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\""
'';
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) + "}";
};
2019-11-10 09:42:12 +01:00
}