- Add nix-env warning to AGENTS.md - Include QEMU in flake.nix devShell for testing - Update Makefile to use nix develop for QEMU commands - Fix test-usb target to work with nix develop environment
124 lines
3.0 KiB
Nix
124 lines
3.0 KiB
Nix
{
|
|
description = "Workshop VM with Participant Containers + USB ISO";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
|
nixos-generators = {
|
|
url = "github:nix-community/nixos-generators";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs =
|
|
{
|
|
self,
|
|
nixpkgs,
|
|
nixos-generators,
|
|
}:
|
|
let
|
|
system = "x86_64-linux";
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
# Server names for cloud connections
|
|
cloudServerNames = [
|
|
"hopper"
|
|
"curie"
|
|
"lovelace"
|
|
"noether"
|
|
"hamilton"
|
|
"franklin"
|
|
"johnson"
|
|
"clarke"
|
|
"goldberg"
|
|
"liskov"
|
|
"wing"
|
|
"rosen"
|
|
"shaw"
|
|
"karp"
|
|
"rich"
|
|
];
|
|
|
|
# Common configuration
|
|
commonConfig =
|
|
{
|
|
isLiveIso ? false,
|
|
}:
|
|
import ./common.nix {
|
|
inherit pkgs cloudServerNames isLiveIso;
|
|
};
|
|
in
|
|
{
|
|
packages.${system} = {
|
|
local-vm = self.nixosConfigurations.workshop-vm.config.system.build.vm;
|
|
|
|
live-iso = nixos-generators.nixosGenerate {
|
|
inherit system;
|
|
format = "iso";
|
|
modules = [
|
|
(commonConfig { isLiveIso = true; })
|
|
];
|
|
};
|
|
};
|
|
|
|
devShells.${system}.default = pkgs.mkShell {
|
|
packages = with pkgs; [
|
|
markdownlint-cli
|
|
jq
|
|
nixpkgs-fmt
|
|
qemu
|
|
];
|
|
};
|
|
|
|
nixosConfigurations.workshop-vm = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
modules = [
|
|
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
|
|
|
|
(commonConfig { isLiveIso = false; })
|
|
|
|
(
|
|
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
{
|
|
boot.loader.grub.enable = false;
|
|
boot.loader.generic-extlinux-compatible.enable = true;
|
|
|
|
# Enable networking for VM
|
|
networking.hostName = "workshop-vm";
|
|
networking.networkmanager.enable = true;
|
|
networking.firewall.enable = false;
|
|
|
|
# Hybrid console configuration - serial primary, GUI available
|
|
boot.kernelParams = [
|
|
"console=ttyS0,115200"
|
|
"console=tty1"
|
|
];
|
|
|
|
# VM specific settings
|
|
virtualisation.memorySize = 4096;
|
|
virtualisation.diskSize = 40000;
|
|
|
|
# Hybrid mode: GUI available but serial console primary
|
|
virtualisation.qemu.options = [
|
|
"-display"
|
|
"gtk"
|
|
"-monitor"
|
|
"stdio"
|
|
# Add port forwarding for SSH
|
|
"-netdev"
|
|
"user,id=net0,hostfwd=tcp::2222-:22"
|
|
"-device"
|
|
"virtio-net,netdev=net0"
|
|
];
|
|
# GUI session commands handled in common.nix
|
|
}
|
|
)
|
|
];
|
|
};
|
|
};
|
|
}
|