melodypond/flake.nix

77 lines
2.2 KiB
Nix
Raw Normal View History

2023-04-04 17:51:16 +00:00
{
description = "my project description";
inputs = {
2023-07-25 07:32:19 +00:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
2023-04-04 17:51:16 +00:00
flake-utils.url = "github:numtide/flake-utils";
2023-07-25 07:32:19 +00:00
colmena.url = "github:zhaofengli/colmena";
2023-07-27 19:24:32 +00:00
graphfix.url = "git+https://git.sr.ht/~mtxyz/graphfix";
graphfix.inputs.nixpkgs.follows = "nixpkgs";
2023-04-04 17:51:16 +00:00
};
outputs = inputs@{self, nixpkgs, flake-utils, ...}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
2023-07-25 07:32:19 +00:00
overlays = [ inputs.colmena.overlay ];
2023-04-04 17:51:16 +00:00
};
crossPkgs = pkgs.pkgsCross.aarch64-multiplatform;
2023-04-04 17:51:16 +00:00
in
2023-07-25 07:32:19 +00:00
{
devShell = pkgs.mkShell {
packages = with pkgs; [ colmena ];
};
apps.default = {
type = "app";
program = self.outputs.packages.${system}.vmscript + "/bin/vmscript";
};
packages.vmscript = pkgs.writeScriptBin "vmscript" ''
2023-04-04 19:40:16 +00:00
#!${pkgs.runtimeShell} -e
img=./sd-card.img
2023-07-25 07:32:19 +00:00
${pkgs.zstd}/bin/zstd -k -d ${self.outputs.image}/sd-image/orange.img.zst -o $img
2023-04-04 19:40:16 +00:00
chmod 640 $img
2023-07-25 07:32:19 +00:00
truncate -s 16G $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-07-27 19:24:32 +00:00
}) // (let
pkgs = import nixpkgs {
system = "aarch64-linux";
overlays = [ inputs.graphfix.overlay ];
};
in rec {
2023-07-25 07:32:19 +00:00
colmena = {
meta = {
2023-07-27 19:24:32 +00:00
nixpkgs = pkgs;
2023-07-25 07:32:19 +00:00
};
orange = {
imports = [
./configuration.nix
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
];
};
};
nixosConfigurations.orange = nixpkgs.lib.nixosSystem {
modules = [
2023-07-25 07:32:19 +00:00
./configuration.nix
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
{
2023-07-27 19:24:32 +00:00
nixpkgs.overlays = [inputs.graphfix.overlay];
sdImage.imageName = "orange.img";
}
];
};
2023-07-25 07:32:19 +00:00
image = nixosConfigurations.orange.config.system.build.sdImage;
2023-07-27 19:24:32 +00:00
});
2023-04-04 17:51:16 +00:00
}