Adds native vm for testing.

This commit is contained in:
Bailey Stevens 2023-08-03 16:00:12 -04:00
parent 2d507ae030
commit 00ad5f6c8c
5 changed files with 43 additions and 52 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
result
sd-card.img
clementine.qcow2

View file

@ -1,17 +1,13 @@
{pkgs, ... }:
{
boot.loader.raspberryPi.version = 3;
boot.initrd.kernelModules = [ "vc4" "bcm2835_dma" "i2c_bcm2835" ];
networking.hostName = "orange";
nixpkgs.hostPlatform.system = "aarch64-linux";
system.stateVersion = "23.05";
nix.settings.experimental-features = [ "nix-command" "flakes" ];
hardware.opengl.enable = true;
environment.systemPackages = with pkgs; [
graphfix xorg.xauth xorg.xinit
xorg.xauth xorg.xinit
];
users = {

View file

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

4
platforms/clementine.nix Normal file
View file

@ -0,0 +1,4 @@
{pkgs, ...}:
{
networking.hostName = "clementine";
}

10
platforms/orange.nix Normal file
View file

@ -0,0 +1,10 @@
{pkgs, ...}:
{
nixpkgs.hostPlatform.system = "aarch64-linux";
sdImage.imageName = "orange.img";
boot.loader.raspberryPi.version = 3;
boot.initrd.kernelModules = [ "vc4" "bcm2835_dma" "i2c_bcm2835" ];
networking.hostName = "orange";
}