forked from DGNum/liminix
t #2
4 changed files with 62 additions and 12 deletions
|
@ -1,4 +1,18 @@
|
||||||
{ lib, pkgs, ... }:
|
{ 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, ... }:
|
{ lib, pkgs, ... }:
|
||||||
{
|
{
|
||||||
networking.hostName = "client-vm";
|
networking = {
|
||||||
|
hostName = "client-vm";
|
||||||
|
useDHCP = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,21 @@
|
||||||
lib ? pkgs.lib,
|
lib ? pkgs.lib,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
base-cmd = vm: ''
|
base-cmd =
|
||||||
${pkgs.qemu}/bin/qemu-system-x86_64 -m 4G \
|
{
|
||||||
-kernel ${vm.kernel}/bzImage \
|
apnet-mac,
|
||||||
-initrd ${vm.ramdisk}/initrd \
|
apnet-port,
|
||||||
-append "init=${vm.toplevel}/init loglevel=4 console=ttyS0" \
|
vm,
|
||||||
-display none -serial mon:stdio
|
}:
|
||||||
'';
|
''
|
||||||
|
${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 =
|
border-vm =
|
||||||
(import (pkgs.path + "/nixos/lib/eval-config.nix") {
|
(import (pkgs.path + "/nixos/lib/eval-config.nix") {
|
||||||
|
@ -30,11 +38,28 @@ let
|
||||||
}).config.system.build;
|
}).config.system.build;
|
||||||
|
|
||||||
border-launch = pkgs.writeShellScript "lauch-border" ''
|
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" ''
|
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
|
in
|
||||||
{ }
|
pkgs.linkFarm "vms" [
|
||||||
|
{
|
||||||
|
name = "border";
|
||||||
|
path = border-launch;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "client";
|
||||||
|
path = client-launch;
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
modulesPath,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
@ -13,6 +14,13 @@ let
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
|
||||||
|
environment.systemPackages = with pkgs; [ tcpdump ];
|
||||||
|
networking = {
|
||||||
|
useNetworkd = true;
|
||||||
|
firewall.enable = false;
|
||||||
|
};
|
||||||
|
|
||||||
system.build.ramdisk = pkgs.makeInitrdNG {
|
system.build.ramdisk = pkgs.makeInitrdNG {
|
||||||
inherit (config.boot.initrd) compressor;
|
inherit (config.boot.initrd) compressor;
|
||||||
prepend = [ "${config.system.build.initialRamdisk}/initrd" ];
|
prepend = [ "${config.system.build.initialRamdisk}/initrd" ];
|
||||||
|
|
Loading…
Reference in a new issue