Compare commits
9 commits
give-it-a-
...
main
Author | SHA1 | Date | |
---|---|---|---|
6dd34b97a9 | |||
7eff028b02 | |||
89d2d34ad7 | |||
eec7a6e985 | |||
a56936f1d3 | |||
|
562b050341 | ||
dbe6b1b135 | |||
c5e48f5c9f | |||
0dd72b31f4 |
28 changed files with 200 additions and 71 deletions
|
@ -17,4 +17,34 @@ jobs:
|
||||||
- name: Build VM QEMU MIPS
|
- name: Build VM QEMU MIPS
|
||||||
run: |
|
run: |
|
||||||
# Enter the shell
|
# 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
|
||||||
|
|
||||||
|
test_shell_customization:
|
||||||
|
runs-on: nix
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Build VM QEMU MIPS
|
||||||
|
run: |
|
||||||
|
# Enter the shell
|
||||||
|
nix-build ci.nix -A custom-shell
|
||||||
|
|
4
ci.nix
4
ci.nix
|
@ -7,7 +7,7 @@
|
||||||
let
|
let
|
||||||
pkgs = (import nixpkgs { });
|
pkgs = (import nixpkgs { });
|
||||||
borderVmConf = ./bordervm.conf-example.nix;
|
borderVmConf = ./bordervm.conf-example.nix;
|
||||||
inherit (pkgs.lib.attrsets) genAttrs;
|
inherit (pkgs.lib.attrsets) genAttrs mapAttrs;
|
||||||
devices = [
|
devices = [
|
||||||
"qemu"
|
"qemu"
|
||||||
"zyxel-nwa50ax"
|
"zyxel-nwa50ax"
|
||||||
|
@ -19,7 +19,7 @@ let
|
||||||
device = import (liminix + "/devices/${name}");
|
device = import (liminix + "/devices/${name}");
|
||||||
liminix-config = vanilla;
|
liminix-config = vanilla;
|
||||||
}).outputs.default;
|
}).outputs.default;
|
||||||
tests = import ./tests/ci.nix;
|
tests = mapAttrs (_: v: v { inherit liminix nixpkgs; }) (import ./tests/ci.nix);
|
||||||
jobs =
|
jobs =
|
||||||
(genAttrs devices for-device) //
|
(genAttrs devices for-device) //
|
||||||
tests //
|
tests //
|
||||||
|
|
24
default.nix
24
default.nix
|
@ -26,9 +26,13 @@ let
|
||||||
eval = evalModules {
|
eval = evalModules {
|
||||||
modules = [
|
modules = [
|
||||||
{
|
{
|
||||||
nixpkgs.overlays = [
|
nixpkgs = {
|
||||||
overlay
|
source = nixpkgs;
|
||||||
];
|
overlays = [ overlay ];
|
||||||
|
config.permittedInsecurePackages = [
|
||||||
|
"python-2.7.18.8"
|
||||||
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
device.module
|
device.module
|
||||||
liminix-config
|
liminix-config
|
||||||
|
@ -52,7 +56,7 @@ let
|
||||||
borderVmConf
|
borderVmConf
|
||||||
];
|
];
|
||||||
}).config.system;
|
}).config.system;
|
||||||
in rec {
|
in {
|
||||||
inherit evalModules;
|
inherit evalModules;
|
||||||
|
|
||||||
outputs = config.system.outputs // {
|
outputs = config.system.outputs // {
|
||||||
|
@ -90,16 +94,4 @@ in rec {
|
||||||
lua
|
lua
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
try-nand = pkgs.pkgsBuildBuild.writeShellScriptBin "try-nand.sh" ''
|
|
||||||
rootfs=$(mktemp)
|
|
||||||
cp ${outputs.default}/rootfs $rootfs
|
|
||||||
${pkgs.pkgsBuildBuild.qemuLim}/bin/qemu-system-mips \
|
|
||||||
-M malta -echr 16 -m 272 \
|
|
||||||
-device nand,chip_id=0x59,id=nand -drive format=raw,file=''${rootfs},if=mtd,id=nand \
|
|
||||||
-serial mon:stdio -kernel ${outputs.default}/vmlinux \
|
|
||||||
-append "root=/dev/mtdblock0 console=ttyS0,115200 panic=10 oops=panic init=/bin/init loglevel=8 root=/dev/mtdblock0 rootfstype=squashfs fw_devlink=off mem=256M liminix mtdparts=phram0:16M(rootfs) phram.phram=phram0,0x90000000,16Mi,65536" \
|
|
||||||
-display none
|
|
||||||
rm $rootfs
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,13 @@
|
||||||
|
|
||||||
{ lib, pkgs, config, ...}:
|
{ lib, pkgs, config, ...}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
|
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr concatStringsSep mapAttrsToList;
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs.liminix.networking) address interface;
|
inherit (pkgs.liminix.networking) address interface;
|
||||||
inherit (pkgs.liminix.services) bundle;
|
inherit (pkgs.liminix.services) bundle;
|
||||||
|
|
||||||
|
# TODO: escape shell argument.
|
||||||
|
exportVar = name: value: "export ${name}=\"${value}\"";
|
||||||
type_service = pkgs.liminix.lib.types.service;
|
type_service = pkgs.liminix.lib.types.service;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
@ -22,6 +24,24 @@ in {
|
||||||
/run/current-system, we just add the paths in /etc/profile
|
/run/current-system, we just add the paths in /etc/profile
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environmentVariables = mkOption {
|
||||||
|
type = types.attrsOf types.str;
|
||||||
|
description = ''
|
||||||
|
Attribute set of environment variables to make available
|
||||||
|
in a login shell.
|
||||||
|
|
||||||
|
The value is assumed to be escaped and the name to be valid.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
prompt = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "$(whoami)@$(hostname) # ";
|
||||||
|
description = ''
|
||||||
|
Prompt string (PS1) for the shell.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
services = mkOption {
|
services = mkOption {
|
||||||
type = types.attrsOf type_service;
|
type = types.attrsOf type_service;
|
||||||
|
@ -111,6 +131,8 @@ in {
|
||||||
|
|
||||||
defaultProfile.packages = with pkgs;
|
defaultProfile.packages = with pkgs;
|
||||||
[ s6 s6-init-bin execline s6-linux-init s6-rc ];
|
[ s6 s6-init-bin execline s6-linux-init s6-rc ];
|
||||||
|
# Set the useful PS1 prompt by default.
|
||||||
|
defaultProfile.environmentVariables.PS1 = lib.mkDefault config.defaultProfile.prompt;
|
||||||
|
|
||||||
boot.commandLine = [
|
boot.commandLine = [
|
||||||
"panic=10 oops=panic init=/bin/init loglevel=8"
|
"panic=10 oops=panic init=/bin/init loglevel=8"
|
||||||
|
@ -181,9 +203,10 @@ in {
|
||||||
etc = let
|
etc = let
|
||||||
profile = symlink
|
profile = symlink
|
||||||
(pkgs.writeScript ".profile" ''
|
(pkgs.writeScript ".profile" ''
|
||||||
PATH=${lib.makeBinPath config.defaultProfile.packages}:/bin
|
PATH=${lib.makeBinPath config.defaultProfile.packages}:/bin
|
||||||
export PATH
|
export PATH
|
||||||
'');
|
${concatStringsSep "\n" (mapAttrsToList exportVar config.defaultProfile.environmentVariables)}
|
||||||
|
'');
|
||||||
in dir {
|
in dir {
|
||||||
inherit profile;
|
inherit profile;
|
||||||
ashrc = profile;
|
ashrc = profile;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{ lib, pkgs, config, ...}:
|
{ lib, pkgs, config, ...}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
inherit (pkgs.liminix.services) oneshot;
|
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
hostname = mkOption {
|
hostname = mkOption {
|
||||||
|
@ -12,12 +11,21 @@ in {
|
||||||
default = "liminix";
|
default = "liminix";
|
||||||
type = types.nonEmptyStr;
|
type = types.nonEmptyStr;
|
||||||
};
|
};
|
||||||
};
|
hostname-script = mkOption {
|
||||||
config = {
|
description = ''
|
||||||
services.hostname = oneshot {
|
Script that outputs the system hostname on stdin.
|
||||||
name = "hostname-${builtins.substring 0 12 (builtins.hashString "sha256" config.hostname)}";
|
'';
|
||||||
up = "echo ${config.hostname} > /proc/sys/kernel/hostname";
|
default = pkgs.writeScript "hostname-gen" ''
|
||||||
down = "true";
|
#!/bin/sh
|
||||||
|
echo ${config.hostname}
|
||||||
|
'';
|
||||||
|
defaultText = ''
|
||||||
|
pkgs.writeScript "hostname-gen" '''
|
||||||
|
#!/bin/sh
|
||||||
|
echo ''${config.hostname}
|
||||||
|
'''
|
||||||
|
'';
|
||||||
|
type = types.package;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ let
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
cp -r $src $out/scripts
|
cp -r $src $out/scripts
|
||||||
|
substituteInPlace $out/scripts/rc.init \
|
||||||
|
--replace-fail 'config.hostname' "${config.hostname-script}"
|
||||||
chmod -R +w $out
|
chmod -R +w $out
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,6 +36,7 @@ fi
|
||||||
### (replace /run/service with your scandir)
|
### (replace /run/service with your scandir)
|
||||||
s6-rc-init -d -c /etc/s6-rc/compiled /run/service
|
s6-rc-init -d -c /etc/s6-rc/compiled /run/service
|
||||||
|
|
||||||
|
config.hostname > /proc/sys/kernel/hostname
|
||||||
|
|
||||||
### 2. Starting the wanted set of services
|
### 2. Starting the wanted set of services
|
||||||
### This is also called every time you change runlevels with telinit.
|
### This is also called every time you change runlevels with telinit.
|
||||||
|
|
|
@ -194,7 +194,11 @@ extraPkgs // {
|
||||||
});
|
});
|
||||||
in h.override { openssl = null; sqlite = null; };
|
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: {
|
kexec-tools-static = prev.kexec-tools.overrideAttrs(o: {
|
||||||
# For kexecboot we copy kexec into a ramdisk on the system being
|
# For kexecboot we copy kexec into a ramdisk on the system being
|
||||||
|
@ -254,7 +258,6 @@ extraPkgs // {
|
||||||
qemuLim = let q = prev.qemu.overrideAttrs (o: {
|
qemuLim = let q = prev.qemu.overrideAttrs (o: {
|
||||||
patches = o.patches ++ [
|
patches = o.patches ++ [
|
||||||
./pkgs/qemu/arm-image-friendly-load-addr.patch
|
./pkgs/qemu/arm-image-friendly-load-addr.patch
|
||||||
./pkgs/qemu/mips-with-nand.patch
|
|
||||||
];
|
];
|
||||||
}); in q.override { nixosTestRunner = true; sdlSupport = false; };
|
}); in q.override { nixosTestRunner = true; sdlSupport = false; };
|
||||||
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
From 875b1f312b6a5b432e020723007a374d82a797f1 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Raito Bezarius <masterancpp@gmail.com>
|
|
||||||
Date: Mon, 7 Oct 2024 13:05:06 +0200
|
|
||||||
Subject: [PATCH] feat: support NAND devices for MIPS
|
|
||||||
|
|
||||||
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
|
|
||||||
---
|
|
||||||
hw/mips/Kconfig | 1 +
|
|
||||||
1 file changed, 1 insertion(+)
|
|
||||||
|
|
||||||
diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
|
|
||||||
index 692bede538..60738ac659 100644
|
|
||||||
--- a/hw/mips/Kconfig
|
|
||||||
+++ b/hw/mips/Kconfig
|
|
||||||
@@ -10,6 +10,7 @@ config MALTA
|
|
||||||
select MIPS_CPS
|
|
||||||
select PIIX
|
|
||||||
select PFLASH_CFI01
|
|
||||||
+ select NAND
|
|
||||||
select SERIAL
|
|
||||||
select SMBUS_EEPROM
|
|
||||||
|
|
||||||
--
|
|
||||||
2.46.0
|
|
||||||
|
|
|
@ -10,4 +10,5 @@
|
||||||
tftpboot = import ./tftpboot/test.nix;
|
tftpboot = import ./tftpboot/test.nix;
|
||||||
updown = import ./updown/test.nix;
|
updown = import ./updown/test.nix;
|
||||||
inout = import ./inout/test.nix;
|
inout = import ./inout/test.nix;
|
||||||
|
custom-shell = import ./custom-shell/test.nix;
|
||||||
}
|
}
|
||||||
|
|
7
tests/custom-shell/check-prompt.expect
Normal file
7
tests/custom-shell/check-prompt.expect
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
set timeout 60
|
||||||
|
|
||||||
|
spawn socat unix-connect:vm/console -
|
||||||
|
expect {
|
||||||
|
"root@liminix blah blah > " { exit 0 }
|
||||||
|
timeout { exit 1 }
|
||||||
|
}
|
13
tests/custom-shell/configuration.nix
Normal file
13
tests/custom-shell/configuration.nix
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{ config, pkgs, lib, ... } :
|
||||||
|
let
|
||||||
|
inherit (pkgs.liminix.networking) interface address hostapd route dnsmasq;
|
||||||
|
inherit (pkgs.liminix.services) oneshot longrun bundle target;
|
||||||
|
in rec {
|
||||||
|
imports = [
|
||||||
|
../../modules/network
|
||||||
|
];
|
||||||
|
|
||||||
|
defaultProfile.prompt = "$(whoami)@$(hostname) blah blah > ";
|
||||||
|
|
||||||
|
defaultProfile.packages = with pkgs; [ ];
|
||||||
|
}
|
21
tests/custom-shell/test.nix
Normal file
21
tests/custom-shell/test.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
liminix
|
||||||
|
, nixpkgs
|
||||||
|
}:
|
||||||
|
let img = (import liminix {
|
||||||
|
inherit nixpkgs;
|
||||||
|
device = import "${liminix}/devices/qemu/";
|
||||||
|
liminix-config = ./configuration.nix;
|
||||||
|
}).outputs.default;
|
||||||
|
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||||
|
in pkgs.runCommand "check" {
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
expect socat
|
||||||
|
] ;
|
||||||
|
} ''
|
||||||
|
. ${../test-helpers.sh}
|
||||||
|
|
||||||
|
mkdir vm
|
||||||
|
${img}/run.sh --background ./vm
|
||||||
|
expect ${./check-prompt.expect} |tee output && mv output $out
|
||||||
|
''
|
|
@ -6,7 +6,7 @@ let img = (import liminix {
|
||||||
device = import "${liminix}/devices/qemu/";
|
device = import "${liminix}/devices/qemu/";
|
||||||
liminix-config = ./configuration.nix;
|
liminix-config = ./configuration.nix;
|
||||||
}).outputs.vmroot;
|
}).outputs.vmroot;
|
||||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||||
in pkgs.runCommand "check" {
|
in pkgs.runCommand "check" {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
expect
|
expect
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
overlay = import "${liminix}/overlay.nix";
|
overlay = import "${liminix}/overlay.nix";
|
||||||
pkgs = import <nixpkgs> { overlays = [overlay]; };
|
pkgs = import nixpkgs { overlays = [overlay]; };
|
||||||
script = pkgs.writeFennelScript "foo" [] ./hello.fnl;
|
script = pkgs.writeFennelScript "foo" [] ./hello.fnl;
|
||||||
inherit (pkgs.lua.pkgs) fifo;
|
inherit (pkgs.lua.pkgs) fifo;
|
||||||
netlink = pkgs.netlink-lua;
|
netlink = pkgs.netlink-lua;
|
||||||
|
|
|
@ -6,7 +6,7 @@ let img = (import liminix {
|
||||||
device = import "${liminix}/devices/qemu/";
|
device = import "${liminix}/devices/qemu/";
|
||||||
liminix-config = ./configuration.nix;
|
liminix-config = ./configuration.nix;
|
||||||
}).outputs.vmroot;
|
}).outputs.vmroot;
|
||||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||||
in pkgs.runCommand "check" {
|
in pkgs.runCommand "check" {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
expect
|
expect
|
||||||
|
|
|
@ -5,7 +5,6 @@ in {
|
||||||
imports = [
|
imports = [
|
||||||
../../vanilla-configuration.nix
|
../../vanilla-configuration.nix
|
||||||
../../modules/squashfs.nix
|
../../modules/squashfs.nix
|
||||||
../../modules/outputs/jffs2.nix
|
|
||||||
];
|
];
|
||||||
config.rootfsType = "jffs2";
|
config.rootfsType = "jffs2";
|
||||||
config.filesystem = dir {
|
config.filesystem = dir {
|
||||||
|
|
|
@ -6,7 +6,7 @@ let img = (import liminix {
|
||||||
device = import "${liminix}/devices/qemu/";
|
device = import "${liminix}/devices/qemu/";
|
||||||
liminix-config = ./configuration.nix;
|
liminix-config = ./configuration.nix;
|
||||||
}).outputs.vmroot;
|
}).outputs.vmroot;
|
||||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||||
in pkgs.runCommand "check" {
|
in pkgs.runCommand "check" {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
expect
|
expect
|
||||||
|
|
|
@ -13,7 +13,6 @@ let
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
../../vanilla-configuration.nix
|
../../vanilla-configuration.nix
|
||||||
../../modules/outputs/jffs2.nix
|
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
services.sshd = longrun {
|
services.sshd = longrun {
|
||||||
|
|
|
@ -8,7 +8,7 @@ let lmx = (import liminix {
|
||||||
});
|
});
|
||||||
rogue = lmx.pkgs.rogue;
|
rogue = lmx.pkgs.rogue;
|
||||||
img = lmx.outputs.vmroot;
|
img = lmx.outputs.vmroot;
|
||||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||||
in pkgs.runCommand "check" {
|
in pkgs.runCommand "check" {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
expect
|
expect
|
||||||
|
|
|
@ -6,7 +6,7 @@ let img = (import liminix {
|
||||||
device = import "${liminix}/devices/qemu";
|
device = import "${liminix}/devices/qemu";
|
||||||
liminix-config = ./configuration.nix;
|
liminix-config = ./configuration.nix;
|
||||||
}).outputs.default;
|
}).outputs.default;
|
||||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||||
inherit (pkgs.pkgsBuildBuild) routeros;
|
inherit (pkgs.pkgsBuildBuild) routeros;
|
||||||
in pkgs.runCommand "check" {
|
in pkgs.runCommand "check" {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix,
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
let check = deviceName : config :
|
let check = deviceName : config :
|
||||||
let derivation = (import liminix {
|
let derivation = (import liminix {
|
||||||
|
|
|
@ -6,7 +6,7 @@ let img = (import liminix {
|
||||||
device = import "${liminix}/devices/qemu/";
|
device = import "${liminix}/devices/qemu/";
|
||||||
liminix-config = ./configuration.nix;
|
liminix-config = ./configuration.nix;
|
||||||
}).outputs.vmroot;
|
}).outputs.vmroot;
|
||||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||||
in pkgs.runCommand "check" {
|
in pkgs.runCommand "check" {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
expect
|
expect
|
||||||
|
|
|
@ -7,6 +7,7 @@ in rec {
|
||||||
../../modules/wlan.nix
|
../../modules/wlan.nix
|
||||||
../../modules/hostapd
|
../../modules/hostapd
|
||||||
../../modules/network
|
../../modules/network
|
||||||
|
./wpa_supplicant.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
services.hostap = config.system.service.hostapd.build {
|
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
|
, nixpkgs
|
||||||
}:
|
}:
|
||||||
let img = (import liminix {
|
let img = (import liminix {
|
||||||
device = import "${liminix}/devices/qemu-armv7l/";
|
inherit nixpkgs;
|
||||||
|
device = import "${liminix}/devices/qemu/";
|
||||||
liminix-config = ./configuration.nix;
|
liminix-config = ./configuration.nix;
|
||||||
}).outputs.default;
|
}).outputs.default;
|
||||||
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
pkgs = import nixpkgs { overlays = [(import ../../overlay.nix)]; };
|
||||||
in pkgs.runCommand "check" {
|
in pkgs.runCommand "check" {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
expect socat
|
expect socat
|
||||||
|
|
|
@ -14,10 +14,10 @@ expect {
|
||||||
}
|
}
|
||||||
expect "#"
|
expect "#"
|
||||||
while { $FINISHED < 10 } {
|
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 {
|
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 }
|
"not_present" { send_user "waiting ...\n" ; sleep 5 }
|
||||||
}
|
}
|
||||||
set FINISHED [ expr $FINISHED + 1 ]
|
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…
Reference in a new issue