turn run-qemu.sh and connect-qemu scripts into buildEnv commands

This commit is contained in:
Daniel Barlow 2023-02-08 22:49:10 +00:00
parent 4addcbbd51
commit 1dc9770dbc
4 changed files with 20 additions and 14 deletions

View file

@ -102,9 +102,9 @@ serial console and the [QEMU monitor](https://www.qemu.org/docs/master/system/mo
If you run with `--background /path/to/some/directory` as the first If you run with `--background /path/to/some/directory` as the first
parameter, it will fork into the background and open Unix sockets in parameter, it will fork into the background and open Unix sockets in
that directory for console and monitor. Use that directory for console and monitor. Use `connect-vm` (also in the
`./scripts/connect-qemu.sh` to connect to either of these sockets, and `buildEnv` environment) to connect to either of these sockets, and ^O
^O to disconnect. to disconnect.
### Emulated upstream connection ### Emulated upstream connection
@ -116,9 +116,9 @@ Liminix PPPoE client support can be tested.
This is made available in the `buildEnv`, so you can do something like This is made available in the `buildEnv`, so you can do something like
mkdir ros-sockets mkdir ros-sockets
nix-shell -A buildEnv --arg device '(import ./devices/qemu)' \ nix-shell -A buildEnv --arg device '(import ./devices/qemu)'
--run "routeros ros-sockets" nix-shell$ routeros ros-sockets
./scripts/connect-qemu.sh ./ros-sockets/console nix-shell$ connect-vm ./ros-sockets/console
to start it and connect to it. to start it and connect to it.

View file

@ -468,7 +468,7 @@ don't yet know if any of those builds actually boots or does anything
useful. useful.
Would be nice to clean up the run-qemu and connect-qemu scripts Would be nice to clean up the run-qemu and connect-qemu scripts
and put them in the buildEnv and put them in the buildEnv [DONE]
Some thought needed about how to hook up the gl-ar750 to the internets, Some thought needed about how to hook up the gl-ar750 to the internets,
ideally in a way that mirrors typical real uses. AAISP have an L2TP ideally in a way that mirrors typical real uses. AAISP have an L2TP

View file

@ -1,11 +1,19 @@
{ {
qemu qemu
, socat
, writeShellScriptBin , writeShellScriptBin
, stdenv , symlinkJoin
, lib , lib
}: }: let
writeShellScriptBin "mips-vm" mips-vm = writeShellScriptBin "mips-vm" ''
''
export PATH="${lib.makeBinPath [qemu]}:$PATH" export PATH="${lib.makeBinPath [qemu]}:$PATH"
${builtins.readFile ./mips-vm.sh} ${builtins.readFile ./mips-vm.sh}
'' '';
connect = writeShellScriptBin "connect-vm" ''
export PATH="${lib.makeBinPath [socat]}:$PATH"
socat -,raw,echo=0,icanon=0,isig=0,icrnl=0,escape=0x0f unix-connect:$1
'';
in symlinkJoin {
name = "mips-vm";
paths = [ mips-vm connect ];
}

View file

@ -1,2 +0,0 @@
#!/usr/bin/env sh
nix-shell -p socat --run "socat -,raw,echo=0,icanon=0,isig=0,icrnl=0,escape=0x0f unix-connect:$1"