Compare commits
5 commits
main
...
multi-vm-c
Author | SHA1 | Date | |
---|---|---|---|
2542adcc48 | |||
9eeb7c017a | |||
1c8357abbd | |||
e44b081d49 | |||
9fdae776de |
25 changed files with 305 additions and 26 deletions
18
.forgejo/ci-files/border.nix
Normal file
18
.forgejo/ci-files/border.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ lib, pkgs, ... }:
|
||||
{
|
||||
networking = {
|
||||
hostName = "border-vm";
|
||||
useDHCP = false;
|
||||
};
|
||||
|
||||
systemd.network = {
|
||||
enable = true;
|
||||
networks."10-ens3" = {
|
||||
name = "ens3";
|
||||
networkConfig = {
|
||||
DHCPServer = "yes";
|
||||
};
|
||||
address = [ "192.168.242.1/24" ];
|
||||
};
|
||||
};
|
||||
}
|
7
.forgejo/ci-files/client.nix
Normal file
7
.forgejo/ci-files/client.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ lib, pkgs, ... }:
|
||||
{
|
||||
networking = {
|
||||
hostName = "client-vm";
|
||||
useDHCP = true;
|
||||
};
|
||||
}
|
65
.forgejo/ci-files/default.nix
Normal file
65
.forgejo/ci-files/default.nix
Normal file
|
@ -0,0 +1,65 @@
|
|||
{
|
||||
pkgs ? (import <nixpkgs> { }),
|
||||
lib ? pkgs.lib,
|
||||
}:
|
||||
let
|
||||
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") {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
./border.nix
|
||||
./vm-base.nix
|
||||
];
|
||||
}).config.system.build;
|
||||
|
||||
client-vm =
|
||||
(import (pkgs.path + "/nixos/lib/eval-config.nix") {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
./client.nix
|
||||
./vm-base.nix
|
||||
];
|
||||
}).config.system.build;
|
||||
|
||||
border-launch = pkgs.writeShellScript "lauch-border" ''
|
||||
${base-cmd {
|
||||
vm = border-vm;
|
||||
apnet-port = 1234;
|
||||
apnet-mac = "ba:ad:3d:ea:21:02";
|
||||
}}
|
||||
'';
|
||||
|
||||
client-launch = pkgs.writeShellScript "lauch-client" ''
|
||||
${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;
|
||||
}
|
||||
]
|
100
.forgejo/ci-files/vm-base.nix
Normal file
100
.forgejo/ci-files/vm-base.nix
Normal file
|
@ -0,0 +1,100 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
let
|
||||
sqshStore = pkgs.callPackage (pkgs.path + /nixos/lib/make-squashfs.nix) {
|
||||
storeContents = [
|
||||
config.system.build.toplevel
|
||||
];
|
||||
comp = null; # no time for this
|
||||
};
|
||||
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" ];
|
||||
|
||||
contents = [
|
||||
{
|
||||
source = sqshStore;
|
||||
target = "/nix-store.squashfs";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
fsType = "tmpfs";
|
||||
options = [ "mode=0755" ];
|
||||
};
|
||||
|
||||
"/nix/.ro-store" = {
|
||||
fsType = "squashfs";
|
||||
device = "../nix-store.squashfs";
|
||||
options = [ "loop" ];
|
||||
neededForBoot = true;
|
||||
};
|
||||
|
||||
"/nix/.rw-store" = {
|
||||
fsType = "tmpfs";
|
||||
options = [ "mode=0755" ];
|
||||
neededForBoot = true;
|
||||
};
|
||||
|
||||
"/nix/store" = {
|
||||
overlay = {
|
||||
lowerdir = [ "/nix/.ro-store" ];
|
||||
upperdir = "/nix/.rw-store/store";
|
||||
workdir = "/nix/.rw-store/work";
|
||||
};
|
||||
neededForBoot = true;
|
||||
};
|
||||
};
|
||||
|
||||
boot = {
|
||||
loader.grub.enable = false;
|
||||
initrd = {
|
||||
availableKernelModules = [
|
||||
"squashfs"
|
||||
"overlay"
|
||||
];
|
||||
|
||||
kernelModules = [
|
||||
"loop"
|
||||
"overlay"
|
||||
];
|
||||
};
|
||||
postBootCommands = ''
|
||||
# After booting, register the contents of the Nix store
|
||||
# in the Nix database in the tmpfs.
|
||||
${config.nix.package}/bin/nix-store --load-db < /nix/store/nix-path-registration
|
||||
'';
|
||||
};
|
||||
|
||||
services = {
|
||||
getty.autologinUser = lib.mkForce "root";
|
||||
openssh.enable = true;
|
||||
qemuGuest.enable = true;
|
||||
};
|
||||
nix = {
|
||||
nixPath = [
|
||||
"nixpkgs=${builtins.storePath pkgs.path}"
|
||||
"nixos=${builtins.storePath pkgs.path}"
|
||||
];
|
||||
channel.enable = false;
|
||||
settings.nix-path = config.nix.nixPath;
|
||||
package = pkgs.lix;
|
||||
};
|
||||
console.keyMap = "fr";
|
||||
}
|
|
@ -17,4 +17,24 @@ jobs:
|
|||
- name: Build VM QEMU MIPS
|
||||
run: |
|
||||
# Enter the shell
|
||||
nix-build -I liminix-config=./examples/hello-from-qemu.nix --arg device "import ./devices/qemu" -A outputs.default
|
||||
nix-build ci.nix -A qemu
|
||||
|
||||
build_zyxel-nwa50ax_mips:
|
||||
runs-on: nix
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build VM QEMU MIPS
|
||||
run: |
|
||||
# Enter the shell
|
||||
nix-build ci.nix -A qemu
|
||||
|
||||
test_hostapd:
|
||||
runs-on: nix
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build VM QEMU MIPS
|
||||
run: |
|
||||
# Enter the shell
|
||||
nix-build ci.nix -A wlan
|
||||
|
|
4
ci.nix
4
ci.nix
|
@ -7,7 +7,7 @@
|
|||
let
|
||||
pkgs = (import nixpkgs { });
|
||||
borderVmConf = ./bordervm.conf-example.nix;
|
||||
inherit (pkgs.lib.attrsets) genAttrs;
|
||||
inherit (pkgs.lib.attrsets) genAttrs mapAttrs;
|
||||
devices = [
|
||||
"qemu"
|
||||
"zyxel-nwa50ax"
|
||||
|
@ -19,7 +19,7 @@ let
|
|||
device = import (liminix + "/devices/${name}");
|
||||
liminix-config = vanilla;
|
||||
}).outputs.default;
|
||||
tests = import ./tests/ci.nix;
|
||||
tests = mapAttrs (_: v: v { inherit liminix nixpkgs; }) (import ./tests/ci.nix);
|
||||
jobs =
|
||||
(genAttrs devices for-device) //
|
||||
tests //
|
||||
|
|
10
default.nix
10
default.nix
|
@ -26,9 +26,13 @@ let
|
|||
eval = evalModules {
|
||||
modules = [
|
||||
{
|
||||
nixpkgs.overlays = [
|
||||
overlay
|
||||
];
|
||||
nixpkgs = {
|
||||
source = nixpkgs;
|
||||
overlays = [ overlay ];
|
||||
config.permittedInsecurePackages = [
|
||||
"python-2.7.18.8"
|
||||
];
|
||||
};
|
||||
}
|
||||
device.module
|
||||
liminix-config
|
||||
|
|
|
@ -18,6 +18,14 @@ in rec {
|
|||
family = "inet"; address ="10.3.0.1"; prefixLength = 16;
|
||||
};
|
||||
|
||||
services.dhcpc = svc.network.dhcp.client.build {
|
||||
interface = config.hardware.networkInterfaces.wan;
|
||||
|
||||
# don't start DHCP until the hostname is configured,
|
||||
# so it can identify itself to the DHCP server
|
||||
dependencies = [ config.services.hostname ];
|
||||
};
|
||||
|
||||
services.sshd = svc.ssh.build { };
|
||||
|
||||
users.root = {
|
||||
|
|
|
@ -194,7 +194,11 @@ extraPkgs // {
|
|||
});
|
||||
in h.override { openssl = null; sqlite = null; };
|
||||
|
||||
|
||||
wpa_supplicant = prev.wpa_supplicant.override {
|
||||
dbusSupport = false;
|
||||
withPcsclite = false;
|
||||
wpa_supplicant_gui = null;
|
||||
};
|
||||
|
||||
kexec-tools-static = prev.kexec-tools.overrideAttrs(o: {
|
||||
# For kexecboot we copy kexec into a ramdisk on the system being
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
smoke = import ./smoke/test.nix;
|
||||
pseudofiles = import ./pseudofiles/test.nix;
|
||||
wlan = import ./wlan/test.nix;
|
||||
pppoe = import ./pppoe/test.nix;
|
||||
pppoe = import ./pppoe/test.nix; #
|
||||
jffs2 = import ./jffs2/test.nix;
|
||||
ext4 = import ./ext4/test.nix;
|
||||
ext4 = import ./ext4/test.nix; #
|
||||
min-copy-closure = import ./min-copy-closure/test.nix;
|
||||
fennel = import ./fennel/test.nix;
|
||||
tftpboot = import ./tftpboot/test.nix;
|
||||
updown = import ./updown/test.nix;
|
||||
tftpboot = import ./tftpboot/test.nix; #
|
||||
updown = import ./updown/test.nix; #
|
||||
inout = import ./inout/test.nix;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ let img = (import liminix {
|
|||
device = import "${liminix}/devices/qemu/";
|
||||
liminix-config = ./configuration.nix;
|
||||
}).outputs.vmroot;
|
||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
||||
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||
in pkgs.runCommand "check" {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
expect
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
}:
|
||||
let
|
||||
overlay = import "${liminix}/overlay.nix";
|
||||
pkgs = import <nixpkgs> { overlays = [overlay]; };
|
||||
pkgs = import nixpkgs { overlays = [overlay]; };
|
||||
script = pkgs.writeFennelScript "foo" [] ./hello.fnl;
|
||||
inherit (pkgs.lua.pkgs) fifo;
|
||||
netlink = pkgs.netlink-lua;
|
||||
|
|
|
@ -6,7 +6,7 @@ let img = (import liminix {
|
|||
device = import "${liminix}/devices/qemu/";
|
||||
liminix-config = ./configuration.nix;
|
||||
}).outputs.vmroot;
|
||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
||||
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||
in pkgs.runCommand "check" {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
expect
|
||||
|
|
|
@ -5,7 +5,6 @@ in {
|
|||
imports = [
|
||||
../../vanilla-configuration.nix
|
||||
../../modules/squashfs.nix
|
||||
../../modules/outputs/jffs2.nix
|
||||
];
|
||||
config.rootfsType = "jffs2";
|
||||
config.filesystem = dir {
|
||||
|
|
|
@ -6,7 +6,7 @@ let img = (import liminix {
|
|||
device = import "${liminix}/devices/qemu/";
|
||||
liminix-config = ./configuration.nix;
|
||||
}).outputs.vmroot;
|
||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
||||
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||
in pkgs.runCommand "check" {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
expect
|
||||
|
|
|
@ -13,7 +13,6 @@ let
|
|||
in {
|
||||
imports = [
|
||||
../../vanilla-configuration.nix
|
||||
../../modules/outputs/jffs2.nix
|
||||
];
|
||||
config = {
|
||||
services.sshd = longrun {
|
||||
|
|
|
@ -8,7 +8,7 @@ let lmx = (import liminix {
|
|||
});
|
||||
rogue = lmx.pkgs.rogue;
|
||||
img = lmx.outputs.vmroot;
|
||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
||||
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||
in pkgs.runCommand "check" {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
expect
|
||||
|
|
|
@ -6,7 +6,7 @@ let img = (import liminix {
|
|||
device = import "${liminix}/devices/qemu";
|
||||
liminix-config = ./configuration.nix;
|
||||
}).outputs.default;
|
||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
||||
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||
inherit (pkgs.pkgsBuildBuild) routeros;
|
||||
in pkgs.runCommand "check" {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
liminix
|
||||
liminix,
|
||||
...
|
||||
}:
|
||||
let check = deviceName : config :
|
||||
let derivation = (import liminix {
|
||||
|
|
|
@ -6,7 +6,7 @@ let img = (import liminix {
|
|||
device = import "${liminix}/devices/qemu/";
|
||||
liminix-config = ./configuration.nix;
|
||||
}).outputs.vmroot;
|
||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
||||
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||
in pkgs.runCommand "check" {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
expect
|
||||
|
|
|
@ -7,6 +7,7 @@ in rec {
|
|||
../../modules/wlan.nix
|
||||
../../modules/hostapd
|
||||
../../modules/network
|
||||
./wpa_supplicant.nix
|
||||
];
|
||||
|
||||
services.hostap = config.system.service.hostapd.build {
|
||||
|
@ -27,5 +28,21 @@ in rec {
|
|||
};
|
||||
};
|
||||
|
||||
defaultProfile.packages = with pkgs; [ tcpdump ] ;
|
||||
services.wpa_supplicant = config.system.service.wpa_supplicant.build {
|
||||
interface = "wlan1";
|
||||
driver = "nl80211";
|
||||
config-file = pkgs.writeText "wpa_supplicant.conf" ''
|
||||
country=us
|
||||
update_config=1
|
||||
ctrl_interface=/run/wpa_supplicant
|
||||
|
||||
network={
|
||||
scan_ssid=1
|
||||
ssid="liminix"
|
||||
psk="colourless green ideas"
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
defaultProfile.packages = with pkgs; [ tcpdump wpa_supplicant ];
|
||||
}
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
, nixpkgs
|
||||
}:
|
||||
let img = (import liminix {
|
||||
device = import "${liminix}/devices/qemu-armv7l/";
|
||||
inherit nixpkgs;
|
||||
device = import "${liminix}/devices/qemu/";
|
||||
liminix-config = ./configuration.nix;
|
||||
}).outputs.default;
|
||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
||||
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||
in pkgs.runCommand "check" {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
expect socat
|
||||
|
|
|
@ -14,10 +14,10 @@ expect {
|
|||
}
|
||||
expect "#"
|
||||
while { $FINISHED < 10 } {
|
||||
send "date && grep AP-ENABLED /run/uncaught-logs/* || echo \$NOT\r\n"
|
||||
send "date && grep CTRL-EVENT-CONNECTED /run/uncaught-logs/* || echo \$NOT\r\n"
|
||||
|
||||
expect {
|
||||
"wlan0: AP-ENABLED" { set FINISHED 999; set EXIT 0; }
|
||||
"wlan1: CTRL-EVENT-CONNECTED" { set FINISHED 999; set EXIT 0; }
|
||||
"not_present" { send_user "waiting ...\n" ; sleep 5 }
|
||||
}
|
||||
set FINISHED [ expr $FINISHED + 1 ]
|
||||
|
|
21
tests/wlan/wpa_service.nix
Normal file
21
tests/wlan/wpa_service.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
liminix,
|
||||
wpa_supplicant,
|
||||
lib,
|
||||
}:
|
||||
{
|
||||
interface,
|
||||
driver,
|
||||
config-file,
|
||||
}:
|
||||
let
|
||||
inherit (liminix.services) longrun;
|
||||
inherit (lib.strings) escapeShellArg;
|
||||
in
|
||||
longrun {
|
||||
name = "wpa_supplicant";
|
||||
run =
|
||||
''
|
||||
${wpa_supplicant}/bin/wpa_supplicant -D${driver} -i${interface} -c ${config-file}
|
||||
'';
|
||||
}
|
15
tests/wlan/wpa_supplicant.nix
Normal file
15
tests/wlan/wpa_supplicant.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
with lib; {
|
||||
options.system.service.wpa_supplicant = mkOption { type = pkgs.liminix.lib.types.serviceDefn; };
|
||||
config.system.service.wpa_supplicant = config.system.callService ./wpa_service.nix {
|
||||
interface = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
driver = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
config-file = mkOption {
|
||||
type = types.package;
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue