46 lines
1.2 KiB
Nix
46 lines
1.2 KiB
Nix
{
|
|
description = "my project description";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = inputs@{self, nixpkgs, flake-utils, ...}:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
};
|
|
crossPkgs = pkgs.pkgsCross.aarch64-multiplatform;
|
|
in
|
|
{
|
|
apps.default = {
|
|
type = "app";
|
|
program = "${self.outputs.packages.${system}.vmscript}/bin/vmscript";
|
|
};
|
|
packages = {
|
|
default = import ./sd-card.nix { inherit pkgs crossPkgs; };
|
|
uncompressed = import ./sd-card.nix { inherit pkgs crossPkgs; compress = false; };
|
|
|
|
vmscript = pkgs.writeScriptBin "vmscript" ''
|
|
#!${pkgs.runtimeShell}
|
|
img=./sd-card.img
|
|
cp ${self.outputs.packages.${system}.uncompressed}/sd-card.img $img
|
|
chmod 640 $img
|
|
${pkgs.qemu}/bin/qemu-system-aarch64 \
|
|
-machine raspi3b \
|
|
-kernel "${crossPkgs.ubootRaspberryPi3_64bit}/u-boot.bin" \
|
|
-cpu max \
|
|
-m 1G \
|
|
-smp 4 \
|
|
-drive file="$img",format=raw \
|
|
-serial null \
|
|
-serial mon:stdio
|
|
'';
|
|
|
|
};
|
|
|
|
});
|
|
}
|