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;
|
|
|
|
};
|
2023-04-04 17:51:16 +00:00
|
|
|
crossPkgs = pkgs.pkgsCross.aarch64-multiplatform;
|
2023-04-04 17:51:16 +00:00
|
|
|
in
|
|
|
|
{
|
2023-04-04 17:51:16 +00:00
|
|
|
apps.default = {
|
|
|
|
type = "app";
|
2023-04-20 00:28:26 +00:00
|
|
|
program = self.outputs.packages.${system}.vmscript + "/bin/vmscript";
|
2023-04-04 17:51:16 +00:00
|
|
|
};
|
2023-04-20 00:28:26 +00:00
|
|
|
packages.vmscript = pkgs.writeScriptBin "vmscript" ''
|
2023-04-04 19:40:16 +00:00
|
|
|
#!${pkgs.runtimeShell} -e
|
|
|
|
img=./sd-card.img
|
2023-04-20 00:28:26 +00:00
|
|
|
cp -b ${self.outputs.image}/sd-image/orange.img $img
|
2023-04-04 19:40:16 +00:00
|
|
|
chmod 640 $img
|
2023-04-20 00:28:26 +00:00
|
|
|
truncate -s %2G $img
|
2023-04-04 19:40:16 +00:00
|
|
|
${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
|
|
|
'';
|
2023-04-20 00:28:26 +00:00
|
|
|
}) // {
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|
2023-05-07 02:04:36 +00:00
|
|
|
./configuration.nix
|
2023-04-20 00:28:26 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
image = self.outputs.nixosConfigurations.orange.config.system.build.sdImage;
|
2023-04-04 17:51:16 +00:00
|
|
|
};
|
2023-04-04 17:51:16 +00:00
|
|
|
}
|