commit 1dc9770dbc590c2afc8c224785f44cedd708b0ae
parent 4addcbbd510bb003ad2cd2c3e034252cb73b7dee
Author: Daniel Barlow <dan@telent.net>
Date: Wed, 8 Feb 2023 22:49:10 +0000
turn run-qemu.sh and connect-qemu scripts into buildEnv commands
Diffstat:
4 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
@@ -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
parameter, it will fork into the background and open Unix sockets in
-that directory for console and monitor. Use
-`./scripts/connect-qemu.sh` to connect to either of these sockets, and
-^O to disconnect.
+that directory for console and monitor. Use `connect-vm` (also in the
+`buildEnv` environment) to connect to either of these sockets, and ^O
+to disconnect.
### 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
mkdir ros-sockets
- nix-shell -A buildEnv --arg device '(import ./devices/qemu)' \
- --run "routeros ros-sockets"
- ./scripts/connect-qemu.sh ./ros-sockets/console
+ nix-shell -A buildEnv --arg device '(import ./devices/qemu)'
+ nix-shell$ routeros ros-sockets
+ nix-shell$ connect-vm ./ros-sockets/console
to start it and connect to it.
diff --git a/THOUGHTS.txt b/THOUGHTS.txt
@@ -468,7 +468,7 @@ don't yet know if any of those builds actually boots or does anything
useful.
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,
ideally in a way that mirrors typical real uses. AAISP have an L2TP
diff --git a/pkgs/mips-vm/default.nix b/pkgs/mips-vm/default.nix
@@ -1,11 +1,19 @@
{
qemu
+, socat
, writeShellScriptBin
-, stdenv
+, symlinkJoin
, lib
-}:
-writeShellScriptBin "mips-vm"
- ''
+}: let
+ mips-vm = writeShellScriptBin "mips-vm" ''
export PATH="${lib.makeBinPath [qemu]}:$PATH"
${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 ];
+}
diff --git a/scripts/connect-qemu.sh b/scripts/connect-qemu.sh
@@ -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"