forked from DGNum/liminix
feat(ci): netdevice on vms
This commit is contained in:
parent
ca41e04e7d
commit
d8d512ab31
4 changed files with 62 additions and 12 deletions
|
@ -1,4 +1,18 @@
|
|||
{ lib, pkgs, ... }:
|
||||
{
|
||||
networking.hostName = "border-vm";
|
||||
networking = {
|
||||
hostName = "border-vm";
|
||||
useDHCP = false;
|
||||
};
|
||||
|
||||
systemd.network = {
|
||||
enable = true;
|
||||
networks."10-ens3" = {
|
||||
name = "ens3";
|
||||
networkConfig = {
|
||||
DHCPServer = "yes";
|
||||
};
|
||||
address = [ "192.168.242.1/24" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
{ lib, pkgs, ... }:
|
||||
{
|
||||
networking.hostName = "client-vm";
|
||||
networking = {
|
||||
hostName = "client-vm";
|
||||
useDHCP = true;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,13 +3,21 @@
|
|||
lib ? pkgs.lib,
|
||||
}:
|
||||
let
|
||||
base-cmd = vm: ''
|
||||
${pkgs.qemu}/bin/qemu-system-x86_64 -m 4G \
|
||||
-kernel ${vm.kernel}/bzImage \
|
||||
-initrd ${vm.ramdisk}/initrd \
|
||||
-append "init=${vm.toplevel}/init loglevel=4 console=ttyS0" \
|
||||
-display none -serial mon:stdio
|
||||
'';
|
||||
base-cmd =
|
||||
{
|
||||
apnet-mac,
|
||||
apnet-port,
|
||||
vm,
|
||||
}:
|
||||
''
|
||||
${pkgs.qemu}/bin/qemu-system-x86_64 -m 4G \
|
||||
-kernel ${vm.kernel}/bzImage \
|
||||
-initrd ${vm.ramdisk}/initrd \
|
||||
-append "init=${vm.toplevel}/init loglevel=4 console=ttyS0" \
|
||||
-display none -serial mon:stdio \
|
||||
-netdev socket,mcast=230.0.0.1:${toString apnet-port},localaddr=127.0.0.1,id=apnet \
|
||||
-device virtio-net,disable-legacy=on,disable-modern=off,netdev=apnet,mac=${apnet-mac}
|
||||
'';
|
||||
|
||||
border-vm =
|
||||
(import (pkgs.path + "/nixos/lib/eval-config.nix") {
|
||||
|
@ -30,11 +38,28 @@ let
|
|||
}).config.system.build;
|
||||
|
||||
border-launch = pkgs.writeShellScript "lauch-border" ''
|
||||
${base-cmd border-vm}
|
||||
${base-cmd {
|
||||
vm = border-vm;
|
||||
apnet-port = 1234;
|
||||
apnet-mac = "ba:ad:3d:ea:21:02";
|
||||
}}
|
||||
'';
|
||||
|
||||
client-launch = pkgs.writeShellScript "lauch-client" ''
|
||||
${base-cmd client-vm}
|
||||
${base-cmd {
|
||||
vm = client-vm;
|
||||
apnet-port = 1235;
|
||||
apnet-mac = "ba:ad:3d:ea:21:01";
|
||||
}}
|
||||
'';
|
||||
in
|
||||
{ }
|
||||
pkgs.linkFarm "vms" [
|
||||
{
|
||||
name = "border";
|
||||
path = border-launch;
|
||||
}
|
||||
{
|
||||
name = "client";
|
||||
path = client-launch;
|
||||
}
|
||||
]
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
@ -13,6 +14,13 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
|
||||
environment.systemPackages = with pkgs; [ tcpdump ];
|
||||
networking = {
|
||||
useNetworkd = true;
|
||||
firewall.enable = false;
|
||||
};
|
||||
|
||||
system.build.ramdisk = pkgs.makeInitrdNG {
|
||||
inherit (config.boot.initrd) compressor;
|
||||
prepend = [ "${config.system.build.initialRamdisk}/initrd" ];
|
||||
|
|
Loading…
Reference in a new issue