orange/flake.nix

47 lines
1.2 KiB
Nix
Raw Normal View History

2023-04-04 17:51:16 +00:00
{
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;
2023-04-04 17:51:16 +00:00
in
{
apps.default = {
type = "app";
program = "${self.outputs.packages.${system}.vmscript}/bin/vmscript";
2023-04-04 17:51:16 +00:00
};
packages = {
default = import ./sd-card.nix { inherit pkgs crossPkgs; };
uncompressed = import ./sd-card.nix { inherit pkgs crossPkgs; compress = false; };
vmscript = pkgs.writeScriptBin "vmscript" ''
2023-04-04 19:40:16 +00:00
#!${pkgs.runtimeShell} -e
img=./sd-card.img
cp -b ${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 \
-nographic \
-serial null \
-serial mon:stdio
'';
};
});
2023-04-04 17:51:16 +00:00
}