nix-servo/flake.nix

69 lines
2.1 KiB
Nix
Raw Normal View History

2023-11-08 14:47:50 +08:00
{
description = "Not-OS port to the Zynq-7000 platform";
2023-11-24 10:08:12 +08:00
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
2023-11-08 14:47:50 +08:00
inputs.not-os.url = github:cleverca22/not-os;
2023-11-24 10:08:12 +08:00
inputs.zynq-rs.url = git+https://git.m-labs.hk/m-labs/zynq-rs;
2023-11-08 14:47:50 +08:00
2023-11-24 10:08:12 +08:00
outputs = { self, nixpkgs, not-os, zynq-rs }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
zynqpkgs = zynq-rs.packages.x86_64-linux;
build = { target ? "zc706" }: let
fsbl = zynqpkgs."${target}-fsbl";
u-boot = pkgs.pkgsCross.armv7l-hf-multiplatform.buildUBoot {
defconfig = "xilinx_zynq_virt_defconfig";
preConfigure = ''
export DEVICE_TREE=zynq-zc706
'';
extraMeta.platforms = ["armv7l-linux"];
filesToInstall = ["u-boot.elf"];
};
fsbl-sd = pkgs.runCommand "${target}-fsbl-sd"
{
buildInputs = [ zynqpkgs.mkbootimage ];
}
''
bifdir=`mktemp -d`
cd $bifdir
ln -s ${fsbl}/fsbl.elf fsbl.elf
ln -s ${u-boot}/u-boot.elf u-boot.elf
cat > boot.bif << EOF
the_ROM_image:
{
[bootloader]fsbl.elf
u-boot.elf
}
EOF
mkdir $out $out/nix-support
mkbootimage boot.bif $out/boot.bin
echo file binary-dist $out/boot.bin >> $out/nix-support/hydra-build-products
'';
in {
"${target}-fsbl-sd" = fsbl-sd;
};
in rec {
packages.x86_64-linux = {
zc706-fsbl = zynqpkgs.zc706-fsbl;
} // (build { target = "zc706"; });
packages.armv7l-linux = let
platforms = (import not-os.inputs.nixpkgs { config = {}; }).platforms;
eval = (import "${not-os}" {
extraModules = [
./zynq_image.nix
];
platform = system: platforms.armv7l-hf-multiplatform;
system = "x86_64-linux";
crossSystem.system = "armv7l-linux";
inherit (not-os.inputs) nixpkgs;
});
in {
zynq_image = eval.config.system.build.zynq_image;
};
2023-11-08 14:47:50 +08:00
};
}