58 lines
1.7 KiB
Nix
58 lines
1.7 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.vmscript = pkgs.writeScriptBin "vmscript" ''
|
|
#!${pkgs.runtimeShell} -e
|
|
img=./sd-card.img
|
|
cp -b ${self.outputs.image}/sd-image/orange.img $img
|
|
chmod 640 $img
|
|
truncate -s %2G $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
|
|
'';
|
|
}) // {
|
|
nixosConfigurations.orange = nixpkgs.lib.nixosSystem {
|
|
modules = [
|
|
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
|
|
{
|
|
boot.kernelParams = [ "console=ttyS1,115200n8" ];
|
|
networking.hostName = "orange";
|
|
system.stateVersion = "23.05";
|
|
nixpkgs.hostPlatform.system = "aarch64-linux";
|
|
sdImage = {
|
|
imageName = "orange.img";
|
|
compressImage = false;
|
|
};
|
|
}
|
|
];
|
|
};
|
|
image = self.outputs.nixosConfigurations.orange.config.system.build.sdImage;
|
|
};
|
|
}
|