melodypond/flake.nix

58 lines
1.7 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.vmscript = pkgs.writeScriptBin "vmscript" ''
2023-04-04 19:40:16 +00:00
#!${pkgs.runtimeShell} -e
img=./sd-card.img
cp -b ${self.outputs.image}/sd-image/orange.img $img
2023-04-04 19:40:16 +00:00
chmod 640 $img
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
'';
}) // {
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;
};
2023-04-04 17:51:16 +00:00
}