2023-11-08 14:47:50 +08:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
# Copy of zynq_image.nix from https://github.com/cleverca22/not-os with added patch
|
|
|
|
|
|
|
|
let
|
|
|
|
# dont use overlays for the qemu, it causes a lot of wasted time on recompiles
|
|
|
|
x86pkgs = import pkgs.path { system = "x86_64-linux"; };
|
2023-11-24 10:09:56 +08:00
|
|
|
build = config.system.build;
|
2023-11-14 11:44:55 +08:00
|
|
|
customKernel = pkgs.linux.override {
|
2023-11-08 14:47:50 +08:00
|
|
|
extraConfig = ''
|
|
|
|
OVERLAY_FS y
|
2023-11-24 10:09:56 +08:00
|
|
|
CORESIGHT_LINKS_AND_SINKS m
|
|
|
|
CORESIGHT_SINK_TPIU m
|
|
|
|
CORESIGHT_SOURCE_ETM3X m
|
2023-11-08 14:47:50 +08:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
customKernelPackages = pkgs.linuxPackagesFor customKernel;
|
|
|
|
in {
|
|
|
|
boot.kernelPackages = customKernelPackages;
|
|
|
|
nixpkgs.system = "armv7l-linux";
|
|
|
|
system.build.zynq_image = let
|
2023-11-24 10:09:56 +08:00
|
|
|
cmdline = "root=/dev/mmcblk0 console=ttyPS0,115200n8 systemConfig=${builtins.unsafeDiscardStringContext build.toplevel}";
|
2023-11-08 14:47:50 +08:00
|
|
|
qemuScript = ''
|
|
|
|
#!/bin/bash -v
|
|
|
|
export PATH=${x86pkgs.qemu}/bin:$PATH
|
|
|
|
set -x
|
|
|
|
base=$(dirname $0)
|
|
|
|
|
2023-11-08 15:56:56 +08:00
|
|
|
mkdir ./tmp/
|
|
|
|
cp $base/root.squashfs ./tmp/
|
|
|
|
chmod +w ./tmp/root.squashfs
|
|
|
|
truncate -s 64M ./tmp/root.squashfs
|
2023-11-08 14:47:50 +08:00
|
|
|
|
|
|
|
qemu-system-arm \
|
|
|
|
-M xilinx-zynq-a9 \
|
|
|
|
-serial /dev/null \
|
|
|
|
-serial stdio \
|
|
|
|
-display none \
|
2023-11-24 10:09:56 +08:00
|
|
|
-dtb $base/zynq-zc706.dtb \
|
2023-11-08 14:47:50 +08:00
|
|
|
-kernel $base/zImage \
|
|
|
|
-initrd $base/initrd \
|
2023-11-08 15:56:56 +08:00
|
|
|
-drive file=./tmp/root.squashfs,if=sd,format=raw \
|
2023-11-08 14:47:50 +08:00
|
|
|
-append "${cmdline}"
|
|
|
|
'';
|
|
|
|
in pkgs.runCommand "zynq_image" {
|
|
|
|
inherit qemuScript;
|
|
|
|
passAsFile = [ "qemuScript" ];
|
|
|
|
preferLocalBuild = true;
|
|
|
|
} ''
|
|
|
|
mkdir $out
|
|
|
|
cd $out
|
2023-11-24 10:09:56 +08:00
|
|
|
cp ${build.squashfs} root.squashfs
|
|
|
|
cp ${build.kernel}/*zImage .
|
|
|
|
cp ${build.initialRamdisk}/initrd initrd
|
|
|
|
cp ${build.kernel}/dtbs/zynq-zc706.dtb .
|
|
|
|
ln -sv ${build.toplevel} toplevel
|
2023-11-08 14:47:50 +08:00
|
|
|
cp $qemuScriptPath qemu-script
|
|
|
|
chmod +x qemu-script
|
|
|
|
patchShebangs qemu-script
|
|
|
|
ls -ltrh
|
|
|
|
'';
|
|
|
|
system.build.rpi_image_tar = pkgs.runCommand "dist.tar" {} ''
|
|
|
|
mkdir -p $out/nix-support
|
2023-11-24 10:09:56 +08:00
|
|
|
tar -cvf $out/dist.tar ${build.rpi_image}
|
2023-11-08 14:47:50 +08:00
|
|
|
echo "file binary-dist $out/dist.tar" >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
|
|
|
environment.systemPackages = [ pkgs.strace ];
|
|
|
|
environment.etc."service/getty/run".source = pkgs.writeShellScript "getty" ''
|
2023-11-24 10:09:56 +08:00
|
|
|
bash </dev/ttyPS0 >/dev/ttyPS0
|
2023-11-08 14:47:50 +08:00
|
|
|
'';
|
|
|
|
environment.etc."pam.d/other".text = "";
|
|
|
|
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
(self: super: {
|
|
|
|
# armv7l cross-compile fixes
|
2023-11-14 11:44:55 +08:00
|
|
|
libuv = super.libuv.overrideAttrs (old: { doCheck = false;});
|
|
|
|
elfutils = super.elfutils.overrideAttrs (old: { doCheck = false; doInstallCheck = false;});
|
2023-11-08 14:47:50 +08:00
|
|
|
systemd = super.systemd.override { withEfi = false; };
|
|
|
|
procps = super.procps.override { withSystemd = false; };
|
|
|
|
nix = super.nix.override { enableDocumentation = false; };
|
|
|
|
|
|
|
|
# closure size fixes
|
|
|
|
openssh = super.openssh.override { withFIDO = false; withKerberos = false; };
|
2023-11-08 15:13:04 +08:00
|
|
|
util-linux = super.util-linux.override {
|
|
|
|
pamSupport=false;
|
|
|
|
capabilitiesSupport=false;
|
|
|
|
ncursesSupport=false;
|
|
|
|
systemdSupport=false;
|
|
|
|
nlsSupport=false;
|
|
|
|
translateManpages=false; };
|
2023-11-08 14:47:50 +08:00
|
|
|
utillinuxCurses = self.util-linux;
|
|
|
|
utillinuxMinimal = self.util-linux;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|