Compare commits
39 commits
Author | SHA1 | Date | |
---|---|---|---|
6dd34b97a9 | |||
7eff028b02 | |||
89d2d34ad7 | |||
eec7a6e985 | |||
a56936f1d3 | |||
|
562b050341 | ||
dbe6b1b135 | |||
c5e48f5c9f | |||
0dd72b31f4 | |||
|
013e4c396c | ||
|
036f91d2f0 | ||
|
54db2ad006 | ||
|
8ac3e32b8b | ||
|
6970d811e8 | ||
|
b468275f53 | ||
|
3ed1564235 | ||
|
9fcfae3eae | ||
|
73ea02b982 | ||
|
c942b2be09 | ||
|
95850a44c2 | ||
|
bc1f54e701 | ||
|
0ee2ce4183 | ||
|
94a5b19c77 | ||
|
13069415fd | ||
|
5590fea16e | ||
|
c39bfc2bb5 | ||
|
0c363be423 | ||
|
26d2812aa4 | ||
|
b57df3f288 | ||
|
4cf10c2e75 | ||
|
0d36000d9f | ||
ce17fea337 | |||
|
1a770910a6 | ||
|
5444059b63 | ||
|
ffc6492365 | ||
|
71813a1f8f | ||
|
032e57b34c | ||
|
0fb671023c | ||
|
ebcdbf76bc |
56 changed files with 629 additions and 135 deletions
|
@ -17,4 +17,34 @@ 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
|
||||
|
||||
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
|
||||
|
|
26
ci.nix
26
ci.nix
|
@ -1,21 +1,15 @@
|
|||
{
|
||||
nixpkgs
|
||||
, unstable
|
||||
, liminix
|
||||
sources ? import ./lon.nix
|
||||
, nixpkgs ? sources.nixpkgs
|
||||
, unstable ? nixpkgs
|
||||
, liminix ? ./.
|
||||
, ... }:
|
||||
let
|
||||
inherit (builtins) map;
|
||||
pkgs = (import nixpkgs {});
|
||||
pkgs = (import nixpkgs { });
|
||||
borderVmConf = ./bordervm.conf-example.nix;
|
||||
inherit (pkgs.lib.attrsets) genAttrs;
|
||||
inherit (pkgs.lib.attrsets) genAttrs mapAttrs;
|
||||
devices = [
|
||||
"gl-ar750"
|
||||
"gl-mt300a"
|
||||
"gl-mt300n-v2"
|
||||
"qemu"
|
||||
"qemu-aarch64"
|
||||
"qemu-armv7l"
|
||||
"tp-archer-ax23"
|
||||
"zyxel-nwa50ax"
|
||||
];
|
||||
vanilla = ./vanilla-configuration.nix;
|
||||
|
@ -25,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 //
|
||||
|
@ -44,12 +38,6 @@ let
|
|||
imports = [ ./modules/all-modules.nix ];
|
||||
};
|
||||
}).outputs.optionsJson;
|
||||
installers = map (f: "system.outputs.${f}") [
|
||||
"vmroot"
|
||||
"mtdimage"
|
||||
"ubimage"
|
||||
];
|
||||
inherit (pkgs.lib) concatStringsSep;
|
||||
in pkgs.stdenv.mkDerivation {
|
||||
name = "liminix-doc";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
|
|
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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This "device" generates images that can be used with the QEMU
|
||||
# emulator. The default output is a directory containing separate
|
||||
# kernel (uncompressed vmlinux) and initrd (squashfs) images
|
||||
{
|
||||
rec {
|
||||
system = {
|
||||
crossSystem = {
|
||||
config = "mips-unknown-linux-musl";
|
||||
|
@ -41,6 +41,9 @@
|
|||
../../modules/arch/mipseb.nix
|
||||
../families/qemu.nix
|
||||
];
|
||||
|
||||
nixpkgs.hostPlatform = system.crossSystem;
|
||||
|
||||
kernel = {
|
||||
config = {
|
||||
MIPS_MALTA= "y";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
rec {
|
||||
system = {
|
||||
crossSystem = {
|
||||
config = "mipsel-unknown-linux-musl";
|
||||
|
@ -135,6 +135,8 @@
|
|||
../../modules/zyxel-dual-image
|
||||
];
|
||||
|
||||
nixpkgs.hostPlatform = system.crossSystem;
|
||||
|
||||
filesystem = dir {
|
||||
lib = dir {
|
||||
firmware = dir {
|
||||
|
@ -222,8 +224,8 @@
|
|||
|
||||
imageFormat = "fit";
|
||||
tftp = {
|
||||
# 5MB is nice.
|
||||
freeSpaceBytes = 5 * 1024 * 1024;
|
||||
# 20MB is pretty good on this device as we have plenty of RAM.
|
||||
freeSpaceBytes = 20 * 1024 * 1024;
|
||||
appendDTB = true;
|
||||
loadAddress = lim.parseInt "0x2000000";
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ nixpkgs ? <nixpkgs>, pkgs ? (import <nixpkgs> {}), lib ? pkgs.lib }:
|
||||
{ nixpkgs ? <nixpkgs>, pkgs ? (import nixpkgs {}), lib ? pkgs.lib }:
|
||||
args:
|
||||
let
|
||||
modulesPath = builtins.toString ../modules;
|
||||
|
|
15
lon.lock
Normal file
15
lon.lock
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"version": "1",
|
||||
"sources": {
|
||||
"nixpkgs": {
|
||||
"type": "GitHub",
|
||||
"fetchType": "tarball",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"branch": "nixos-unstable-small",
|
||||
"revision": "b6227cadb5123c7e4cb159bf6f9f5705ae081a47",
|
||||
"url": "https://github.com/nixos/nixpkgs/archive/b6227cadb5123c7e4cb159bf6f9f5705ae081a47.tar.gz",
|
||||
"hash": "sha256-KFR30GNFhjzXl0kVEn+KK4xrFr0gggb1NBroP8ukbxY="
|
||||
}
|
||||
}
|
||||
}
|
41
lon.nix
Normal file
41
lon.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
# Generated by lon. Do not modify!
|
||||
let
|
||||
|
||||
lock = builtins.fromJSON (builtins.readFile ./lon.lock);
|
||||
|
||||
# Override with a path defined in an environment variable. If no variable is
|
||||
# set, the original path is used.
|
||||
overrideFromEnv =
|
||||
name: path:
|
||||
let
|
||||
replacement = builtins.getEnv "LON_OVERRIDE_${name}";
|
||||
in
|
||||
if replacement == "" then
|
||||
path
|
||||
else
|
||||
# this turns the string into an actual Nix path (for both absolute and
|
||||
# relative paths)
|
||||
if builtins.substring 0 1 replacement == "/" then
|
||||
/. + replacement
|
||||
else
|
||||
/. + builtins.getEnv "PWD" + "/${replacement}";
|
||||
|
||||
fetchSource =
|
||||
args@{ fetchType, ... }:
|
||||
if fetchType == "git" then
|
||||
builtins.fetchGit {
|
||||
url = args.url;
|
||||
ref = args.branch;
|
||||
rev = args.revision;
|
||||
narHash = args.hash;
|
||||
}
|
||||
else if fetchType == "tarball" then
|
||||
builtins.fetchTarball {
|
||||
url = args.url;
|
||||
sha256 = args.hash;
|
||||
}
|
||||
else
|
||||
builtins.throw "Unsupported source type ${fetchType}";
|
||||
|
||||
in
|
||||
builtins.mapAttrs (name: args: overrideFromEnv name (fetchSource args)) lock.sources
|
|
@ -4,11 +4,13 @@
|
|||
|
||||
{ lib, pkgs, config, ...}:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
|
||||
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr concatStringsSep mapAttrsToList;
|
||||
inherit (pkgs.pseudofile) dir symlink;
|
||||
inherit (pkgs.liminix.networking) address interface;
|
||||
inherit (pkgs.liminix.services) bundle;
|
||||
|
||||
# TODO: escape shell argument.
|
||||
exportVar = name: value: "export ${name}=\"${value}\"";
|
||||
type_service = pkgs.liminix.lib.types.service;
|
||||
|
||||
in {
|
||||
|
@ -22,6 +24,24 @@ in {
|
|||
/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 {
|
||||
type = types.attrsOf type_service;
|
||||
|
@ -69,6 +89,14 @@ in {
|
|||
default = "uimage";
|
||||
};
|
||||
tftp = {
|
||||
commandLine = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = config.boot.commandLine;
|
||||
description = ''
|
||||
TFTP-specific command line.
|
||||
Defaults to the classical one if unset.
|
||||
'';
|
||||
};
|
||||
loadAddress = mkOption {
|
||||
type = types.ints.unsigned;
|
||||
description = ''
|
||||
|
@ -98,8 +126,13 @@ in {
|
|||
};
|
||||
};
|
||||
config = {
|
||||
# By default, we enable cross-compilation support.
|
||||
nixpkgs.buildPlatform = lib.mkDefault builtins.currentSystem;
|
||||
|
||||
defaultProfile.packages = with pkgs;
|
||||
[ 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 = [
|
||||
"panic=10 oops=panic init=/bin/init loglevel=8"
|
||||
|
@ -170,9 +203,10 @@ in {
|
|||
etc = let
|
||||
profile = symlink
|
||||
(pkgs.writeScript ".profile" ''
|
||||
PATH=${lib.makeBinPath config.defaultProfile.packages}:/bin
|
||||
PATH=${lib.makeBinPath config.defaultProfile.packages}:/bin
|
||||
export PATH
|
||||
'');
|
||||
${concatStringsSep "\n" (mapAttrsToList exportVar config.defaultProfile.environmentVariables)}
|
||||
'');
|
||||
in dir {
|
||||
inherit profile;
|
||||
ashrc = profile;
|
||||
|
|
|
@ -43,8 +43,20 @@ in
|
|||
};
|
||||
|
||||
members = mkOption {
|
||||
type = types.listOf liminix.lib.types.interface;
|
||||
description = "interfaces to add to the bridge";
|
||||
type = types.attrsOf (types.submodule ({ ... }: { options = {
|
||||
member = mkOption {
|
||||
type = liminix.lib.types.interface;
|
||||
description = "interface to add";
|
||||
};
|
||||
|
||||
dependencies = mkOption {
|
||||
type = types.listOf liminix.lib.types.service;
|
||||
default = [];
|
||||
description = "extra dependencies before attaching this interface to the bridge";
|
||||
};
|
||||
}; }));
|
||||
|
||||
description = "set of bridge members";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
{ members, primary } :
|
||||
|
||||
let
|
||||
inherit (liminix.networking) interface;
|
||||
inherit (liminix.services) bundle oneshot;
|
||||
inherit (lib) mkOption types;
|
||||
addif = member : oneshot {
|
||||
name = "${primary.name}.member.${member.name}";
|
||||
inherit (liminix.services) structuredBundle oneshot;
|
||||
inherit (lib) mapAttrs;
|
||||
addif = name: { dependencies ? [ ], member }: oneshot {
|
||||
name = "${primary.name}.member.${name}";
|
||||
up = ''
|
||||
echo "attaching $(output ${member} ifname) to $(output ${primary} ifname) bridge"
|
||||
ip link set dev $(output ${member} ifname) master $(output ${primary} ifname)
|
||||
|
@ -21,9 +20,9 @@ let
|
|||
ip link set dev $(output ${member} ifname) nomaster
|
||||
'';
|
||||
|
||||
dependencies = [ primary member ];
|
||||
dependencies = [ primary member ] ++ dependencies;
|
||||
};
|
||||
in bundle {
|
||||
in structuredBundle {
|
||||
name = "${primary.name}.members";
|
||||
contents = map addif members;
|
||||
contents = mapAttrs addif members;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@ in {
|
|||
system.service.hostapd = mkOption {
|
||||
type = liminix.lib.types.serviceDefn;
|
||||
};
|
||||
|
||||
system.service.hostapd-ready = mkOption {
|
||||
type = liminix.lib.types.serviceDefn;
|
||||
};
|
||||
};
|
||||
config = {
|
||||
system.service.hostapd = liminix.callService ./service.nix {
|
||||
|
@ -34,5 +38,12 @@ in {
|
|||
type = types.attrs;
|
||||
};
|
||||
};
|
||||
|
||||
system.service.hostapd-ready = liminix.callService ./ready.nix {
|
||||
interface = mkOption {
|
||||
type = liminix.lib.types.interface;
|
||||
description = "Interface for which to wait that the oper state Master or Master (VLAN) has been reached.";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
16
modules/hostapd/ready.nix
Normal file
16
modules/hostapd/ready.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
liminix
|
||||
, ifwait
|
||||
, lib
|
||||
}:
|
||||
{ interface } :
|
||||
let
|
||||
inherit (liminix.services) oneshot;
|
||||
in oneshot {
|
||||
name = "${interface.name}.wlan-oper";
|
||||
up = ''
|
||||
${ifwait}/bin/ifbridgeable -v $(output ${interface} ifname)
|
||||
'';
|
||||
|
||||
dependencies = [ interface ];
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
{ lib, pkgs, config, ...}:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
inherit (pkgs.liminix.services) oneshot;
|
||||
in {
|
||||
options = {
|
||||
hostname = mkOption {
|
||||
|
@ -12,12 +11,21 @@ in {
|
|||
default = "liminix";
|
||||
type = types.nonEmptyStr;
|
||||
};
|
||||
};
|
||||
config = {
|
||||
services.hostname = oneshot {
|
||||
name = "hostname";
|
||||
up = "echo ${config.hostname} > /proc/sys/kernel/hostname";
|
||||
down = "true";
|
||||
hostname-script = mkOption {
|
||||
description = ''
|
||||
Script that outputs the system hostname on stdin.
|
||||
'';
|
||||
default = pkgs.writeScript "hostname-gen" ''
|
||||
#!/bin/sh
|
||||
echo ${config.hostname}
|
||||
'';
|
||||
defaultText = ''
|
||||
pkgs.writeScript "hostname-gen" '''
|
||||
#!/bin/sh
|
||||
echo ''${config.hostname}
|
||||
'''
|
||||
'';
|
||||
type = types.package;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -83,11 +83,11 @@ let
|
|||
localSystem = cfg.hostPlatform;
|
||||
};
|
||||
in
|
||||
import <nixpkgs> ({
|
||||
import cfg.source ({
|
||||
inherit (cfg) config overlays;
|
||||
} // systemArgs)
|
||||
else
|
||||
import <nixpkgs> {
|
||||
import cfg.source {
|
||||
inherit (cfg) config overlays localSystem crossSystem;
|
||||
};
|
||||
|
||||
|
@ -97,6 +97,14 @@ in
|
|||
|
||||
{
|
||||
options.nixpkgs = {
|
||||
source = mkOption {
|
||||
type = types.package // {
|
||||
description = "Source of a nixpkgs repository";
|
||||
};
|
||||
|
||||
default = <nixpkgs>;
|
||||
defaultText = "<nixpkgs>";
|
||||
};
|
||||
|
||||
pkgs = mkOption {
|
||||
defaultText = literalExpression ''
|
||||
|
|
|
@ -36,22 +36,43 @@ in
|
|||
kernel.config = {
|
||||
BLK_DEV_INITRD = "y";
|
||||
INITRAMFS_SOURCE = builtins.toJSON "${config.system.outputs.initramfs}";
|
||||
# INITRAMFS_COMPRESSION_LZO = "y";
|
||||
INITRAMFS_COMPRESSION_ZSTD = "y";
|
||||
};
|
||||
|
||||
system.outputs = {
|
||||
initramfs =
|
||||
let inherit (pkgs.pkgsBuildBuild) gen_init_cpio;
|
||||
let
|
||||
inherit (pkgs.pkgsBuildBuild) gen_init_cpio cpio writeScript;
|
||||
inherit (pkgs) busybox;
|
||||
failsafe-init = writeScript "init" ''
|
||||
#!/bin/sh
|
||||
exec >/dev/console
|
||||
echo Running in initramfs
|
||||
PATH=${busybox}/bin:$PATH
|
||||
export PATH
|
||||
mount -t proc none /proc
|
||||
mount -t sysfs none /sys
|
||||
${busybox}/bin/sh
|
||||
'';
|
||||
refs = pkgs.writeReferencesToFile busybox;
|
||||
in runCommand "initramfs.cpio" {} ''
|
||||
cat << SPECIALS | ${gen_init_cpio}/bin/gen_init_cpio /dev/stdin > $out
|
||||
cat << SPECIALS | ${gen_init_cpio}/bin/gen_init_cpio /dev/stdin > out
|
||||
dir /proc 0755 0 0
|
||||
dir /dev 0755 0 0
|
||||
nod /dev/console 0600 0 0 c 5 1
|
||||
dir /target 0755 0 0
|
||||
dir /target/persist 0755 0 0
|
||||
dir /target/nix 0755 0 0
|
||||
dir /nix 0755 0 0
|
||||
dir /nix/store 0755 0 0
|
||||
dir /bin 0755 0 0
|
||||
file /bin/sh ${busybox}/bin/sh 0755 0 0
|
||||
file /init ${pkgs.preinit}/bin/preinit 0755 0 0
|
||||
file /failsafe-init ${failsafe-init} 0755 0 0
|
||||
SPECIALS
|
||||
|
||||
find $(cat ${refs}) | ${cpio}/bin/cpio -H newc -o -A -v -O out
|
||||
mv out $out
|
||||
'';
|
||||
systemConfiguration =
|
||||
pkgs.systemconfig config.filesystem.contents;
|
||||
|
|
|
@ -12,10 +12,15 @@ let
|
|||
arch = pkgs.stdenv.hostPlatform.linuxArch;
|
||||
|
||||
# UBI cannot run on the top of phram.
|
||||
needsSquashfs = config.rootfsType == "ubifs";
|
||||
rootfstype = if needsSquashfs then "squashfs" else config.rootfsType;
|
||||
rootfs = if needsSquashfs then
|
||||
liminix.builders.squashfs config.filesystem.contents
|
||||
needsJffs2 = config.rootfsType == "ubifs";
|
||||
# squashfs doesn't work out for us because only `bootablerootdir`
|
||||
# contain what we need to boot, not `config.filesystem.contents` alas.
|
||||
rootfstype = if needsJffs2 then "jffs2" else config.rootfsType;
|
||||
rootfs = if needsJffs2 then
|
||||
liminix.builders.jffs2 {
|
||||
bootableRootDirectory = config.system.outputs.bootablerootdir;
|
||||
inherit (config.hardware.flash) eraseBlockSize;
|
||||
}
|
||||
else config.system.outputs.rootfs;
|
||||
in {
|
||||
imports = [ ../ramdisk.nix ];
|
||||
|
@ -36,14 +41,6 @@ in {
|
|||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
commandLine = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = config.boot.commandLine;
|
||||
description = ''
|
||||
TFTP-specific command line.
|
||||
Defaults to the classical one if unset.
|
||||
'';
|
||||
};
|
||||
};
|
||||
options.system.outputs = {
|
||||
tftpboot = mkOption {
|
||||
|
@ -82,9 +79,13 @@ in {
|
|||
config = {
|
||||
boot.ramdisk.enable = true;
|
||||
|
||||
kernel.config = mkIf needsSquashfs {
|
||||
SQUASHFS = "y";
|
||||
SQUASHFS_XZ = "y";
|
||||
kernel.config = mkIf needsJffs2 {
|
||||
JFFS2_FS = "y";
|
||||
JFFS2_LZO = "y";
|
||||
JFFS2_RTIME = "y";
|
||||
JFFS2_COMPRESSION_OPTIONS = "y";
|
||||
JFFS2_ZLIB = "y";
|
||||
JFFS2_CMODE_SIZE = "y";
|
||||
};
|
||||
|
||||
system.outputs = rec {
|
||||
|
|
|
@ -30,6 +30,8 @@ let
|
|||
installPhase = ''
|
||||
mkdir $out
|
||||
cp -r $src $out/scripts
|
||||
substituteInPlace $out/scripts/rc.init \
|
||||
--replace-fail 'config.hostname' "${config.hostname-script}"
|
||||
chmod -R +w $out
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -36,6 +36,7 @@ fi
|
|||
### (replace /run/service with your scandir)
|
||||
s6-rc-init -d -c /etc/s6-rc/compiled /run/service
|
||||
|
||||
config.hostname > /proc/sys/kernel/hostname
|
||||
|
||||
### 2. Starting the wanted set of services
|
||||
### This is also called every time you change runlevels with telinit.
|
||||
|
|
|
@ -9,5 +9,8 @@ let
|
|||
in longrun {
|
||||
# Long term: make it unique so that user can spawn multiple buses if they want.
|
||||
name = "ubus";
|
||||
run = "${package}/bin/ubusd";
|
||||
run = ''
|
||||
mkdir -p /run/ubus
|
||||
${package}/bin/ubusd -s /run/ubus/ubus.sock
|
||||
'';
|
||||
}
|
||||
|
|
62
overlay.nix
62
overlay.nix
|
@ -1,23 +1,24 @@
|
|||
final: prev:
|
||||
let
|
||||
isCross = final.stdenv.buildPlatform != final.stdenv.hostPlatform;
|
||||
crossOnly = pkg : amendFn : if isCross then (amendFn pkg) else pkg;
|
||||
extraPkgs = import ./pkgs/default.nix {
|
||||
inherit (final) lib callPackage;
|
||||
};
|
||||
inherit (final) fetchpatch;
|
||||
lua_no_readline = prev.lua5_3;
|
||||
# lua_no_readline = prev.lua5_3.overrideAttrs(o: {
|
||||
# name = "lua-tty";
|
||||
# preBuild = ''
|
||||
# makeFlagsArray+=(PLAT="posix" SYSLIBS="-Wl,-E -ldl" CFLAGS="-O2 -fPIC -DLUA_USE_POSIX -DLUA_USE_DLOPEN")
|
||||
# '';
|
||||
# # lua in nixpkgs has a postInstall stanza that assumes only
|
||||
# # one output, we need to override that if we're going to
|
||||
# # convert to multi-output
|
||||
# # outputs = ["bin" "man" "out"];
|
||||
# makeFlags =
|
||||
# builtins.filter (x: (builtins.match "(PLAT|MYLIBS).*" x) == null)
|
||||
# o.makeFlags;
|
||||
# });
|
||||
luaHost = prev.lua5_3.overrideAttrs(o: {
|
||||
name = "lua-tty";
|
||||
preBuild = ''
|
||||
makeFlagsArray+=(PLAT="posix" SYSLIBS="-Wl,-E -ldl" CFLAGS="-O2 -fPIC -DLUA_USE_POSIX -DLUA_USE_DLOPEN")
|
||||
'';
|
||||
# lua in nixpkgs has a postInstall stanza that assumes only
|
||||
# one output, we need to override that if we're going to
|
||||
# convert to multi-output
|
||||
# outputs = ["bin" "man" "out"];
|
||||
makeFlags =
|
||||
builtins.filter (x: (builtins.match "(PLAT|MYLIBS).*" x) == null)
|
||||
o.makeFlags;
|
||||
});
|
||||
|
||||
s6 = prev.s6.overrideAttrs(o:
|
||||
let
|
||||
|
@ -42,7 +43,6 @@ let
|
|||
(if o ? patches then o.patches else []) ++
|
||||
(if patch_needed then [ patch ] else []);
|
||||
});
|
||||
lua = let s = lua_no_readline.override { self = s; }; in s;
|
||||
in
|
||||
extraPkgs // {
|
||||
# liminix library functions
|
||||
|
@ -130,9 +130,18 @@ extraPkgs // {
|
|||
"CONFIG_LIBNL32=y"
|
||||
"CONFIG_PKCS12=y"
|
||||
"CONFIG_RSN_PREAUTH=y"
|
||||
"CONFIG_UBUS=y"
|
||||
"CONFIG_TLS=internal"
|
||||
];
|
||||
h = prev.hostapd.overrideAttrs(o: {
|
||||
buildInputs = o.buildInputs ++ [ final.libubox final.ubus ];
|
||||
src = final.fetchFromGitea {
|
||||
domain = "git.dgnum.eu";
|
||||
owner = "DGNum";
|
||||
repo = "hostapd";
|
||||
rev = "hostap-liminix-integration";
|
||||
hash = "sha256-5Xi90keCHxvuKR5Q7STuZDzuM9h9ac6aWoXVQYvqkQI=";
|
||||
};
|
||||
extraConfig = "";
|
||||
configurePhase = ''
|
||||
cat > hostapd/defconfig <<EOF
|
||||
|
@ -163,10 +172,18 @@ extraPkgs // {
|
|||
"CONFIG_LIBNL32=y"
|
||||
"CONFIG_PKCS12=y"
|
||||
"CONFIG_RSN_PREAUTH=y"
|
||||
# Required to read the key material for RADIUS.
|
||||
"CONFIG_TLS=openssl"
|
||||
"CONFIG_UBUS=y"
|
||||
"CONFIG_TLS=internal"
|
||||
];
|
||||
h = prev.hostapd.overrideAttrs(o: {
|
||||
buildInputs = o.buildInputs ++ [ final.libubox final.ubus ];
|
||||
src = final.fetchFromGitea {
|
||||
domain = "git.dgnum.eu";
|
||||
owner = "DGNum";
|
||||
repo = "hostapd";
|
||||
rev = "hostap-liminix-integration";
|
||||
hash = "sha256-5Xi90keCHxvuKR5Q7STuZDzuM9h9ac6aWoXVQYvqkQI=";
|
||||
};
|
||||
extraConfig = "";
|
||||
configurePhase = ''
|
||||
cat > hostapd/defconfig <<EOF
|
||||
|
@ -175,9 +192,13 @@ extraPkgs // {
|
|||
${o.configurePhase}
|
||||
'';
|
||||
});
|
||||
in h.override { 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: {
|
||||
# For kexecboot we copy kexec into a ramdisk on the system being
|
||||
|
@ -197,8 +218,7 @@ extraPkgs // {
|
|||
];
|
||||
});
|
||||
|
||||
luaFull = prev.lua;
|
||||
inherit lua;
|
||||
lua = crossOnly prev.lua5_3 (_: luaHost);
|
||||
|
||||
mtdutils = prev.mtdutils.overrideAttrs(o: {
|
||||
patches = (if o ? patches then o.patches else []) ++ [
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
default: fs.lua init.lua nl.lua svc.lua net/constants.lua
|
||||
default: wlan.lua fs.lua init.lua nl.lua svc.lua net/constants.lua
|
||||
|
||||
test:
|
||||
ln -s . anoia
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
, linotify
|
||||
, lua
|
||||
, lualinux
|
||||
, iwinfo
|
||||
, cpio
|
||||
}:
|
||||
let pname = "anoia";
|
||||
|
@ -12,7 +13,7 @@ in stdenv.mkDerivation {
|
|||
version = "0.1";
|
||||
src = ./.;
|
||||
nativeBuildInputs = [ fennel cpio ];
|
||||
buildInputs = with lua.pkgs; [ linotify lualinux ];
|
||||
buildInputs = with lua.pkgs; [ linotify lualinux iwinfo ];
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
doCheck = true;
|
||||
|
|
8
pkgs/anoia/wlan.fnl
Normal file
8
pkgs/anoia/wlan.fnl
Normal file
|
@ -0,0 +1,8 @@
|
|||
(local { : nl80211 } (require :iwinfo))
|
||||
|
||||
(fn is-bridgeable [ifname]
|
||||
(let [mode (nl80211.mode ifname)]
|
||||
(or (= mode "Master") (= mode "Master (VLAN)"))
|
||||
))
|
||||
|
||||
{ : is-bridgeable }
|
|
@ -112,6 +112,7 @@ in {
|
|||
tufted = callPackage ./tufted {};
|
||||
libubox = callPackage ./libubox {};
|
||||
ubus = callPackage ./ubus {};
|
||||
iwinfo = callPackage ./iwinfo {};
|
||||
uevent-watch = callPackage ./uevent-watch {};
|
||||
usb-modeswitch = callPackage ./usb-modeswitch {};
|
||||
writeAshScript = callPackage ./write-ash-script {};
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
, linotify
|
||||
, anoia
|
||||
, netlink-lua
|
||||
, iwinfo
|
||||
, fennel
|
||||
}:
|
||||
let packages = [
|
||||
|
@ -18,7 +19,7 @@ let packages = [
|
|||
fennel
|
||||
lualinux
|
||||
netlink-lua
|
||||
lua.pkgs.readline
|
||||
iwinfo
|
||||
];
|
||||
join = ps: builtins.concatStringsSep ";" ps;
|
||||
luapath = join (builtins.map (f:
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
{
|
||||
lua
|
||||
, netlink-lua
|
||||
, lualinux
|
||||
, iwinfo
|
||||
, writeFennelScript
|
||||
, runCommand
|
||||
, anoia
|
||||
}:
|
||||
runCommand "ifwait" {} ''
|
||||
mkdir -p $out/bin
|
||||
cp -p ${writeFennelScript "ifwait" [anoia netlink-lua] ./ifwait.fnl} $out/bin/ifwait
|
||||
cp -p ${writeFennelScript "ifwait" [ anoia netlink-lua ] ./ifwait.fnl} $out/bin/ifwait
|
||||
cp -p ${writeFennelScript "ifbridgeable" [ anoia lualinux iwinfo ] ./ifbridgeable.fnl} $out/bin/ifbridgeable
|
||||
''
|
||||
|
|
30
pkgs/ifwait/ifbridgeable.fnl
Normal file
30
pkgs/ifwait/ifbridgeable.fnl
Normal file
|
@ -0,0 +1,30 @@
|
|||
(local wlan (require :anoia.wlan))
|
||||
(local { : assoc } (require :anoia))
|
||||
(local { : msleep } (require :lualinux))
|
||||
|
||||
(fn parse-args [args]
|
||||
(match args
|
||||
["-v" & rest] (assoc (parse-args rest) :verbose true)
|
||||
[linkname] {:link linkname}
|
||||
_ nil))
|
||||
|
||||
(fn run [args poll-fn]
|
||||
(let [parameters
|
||||
(assert (parse-args args)
|
||||
(.. "Usage: ifbridgeable [-v] ifname"))]
|
||||
(when parameters.verbose
|
||||
(print (.. "ifbridgeable: waiting for "
|
||||
parameters.link " to be bridgeable")))
|
||||
|
||||
(while (not (poll-fn parameters.link))
|
||||
(when parameters.verbose
|
||||
(print (.. "ifbridgeable: waiting for " parameters.link " to be bridgeable")))
|
||||
(msleep 500)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(when (not (= (. arg 0) "test"))
|
||||
(run arg wlan.is-bridgeable))
|
||||
|
||||
{ : run }
|
59
pkgs/iwinfo/default.nix
Normal file
59
pkgs/iwinfo/default.nix
Normal file
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitea,
|
||||
ubus,
|
||||
libubox,
|
||||
lua5_3,
|
||||
libnl-tiny,
|
||||
backend ? "nl80211"
|
||||
}:
|
||||
let
|
||||
lua = lua5_3;
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "iwinfo";
|
||||
version = "unstable-07-09-2024";
|
||||
|
||||
src = fetchFromGitea {
|
||||
domain = "git.dgnum.eu";
|
||||
owner = "DGNum";
|
||||
repo = "iwinfo";
|
||||
rev = "14685a26805155aa5c137993b9a4861a0bc585d5";
|
||||
hash = "sha256-lg4sBoYcFFLhcUv+wKR6u1OCartjtnAoF9M5FdfO6JE=";
|
||||
};
|
||||
|
||||
BACKENDS = backend;
|
||||
|
||||
buildInputs = [
|
||||
ubus
|
||||
libubox
|
||||
lua
|
||||
libnl-tiny
|
||||
];
|
||||
|
||||
CFLAGS = "-I${libnl-tiny}/include/libnl-tiny -D_GNU_SOURCE";
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm755 iwinfo $out/bin/iwinfo
|
||||
install -Dm755 iwinfo.so $out/lib/lua/${lua.luaversion}/iwinfo.so
|
||||
install -Dm755 libiwinfo.so $out/lib/libiwinfo.so
|
||||
install -Dm755 libiwinfo.so.0 $out/lib/libiwinfo.so.0
|
||||
|
||||
mkdir -p $out/include
|
||||
cp -r include/* $out/include
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Library to access wireless devices";
|
||||
homepage = "https://github.com/openwrt/iwinfo";
|
||||
license = lib.licenses.gpl2Only;
|
||||
maintainers = with lib.maintainers; [ raitobezarius ];
|
||||
mainProgram = "iwinfo";
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
}
|
|
@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
|
|||
nativeBuildInputs = [buildPackages.stdenv.cc] ++
|
||||
(with buildPackages.pkgs; [
|
||||
rsync bc bison flex pkg-config
|
||||
openssl ncurses.all perl
|
||||
openssl ncurses.all perl zstd
|
||||
]);
|
||||
CC = "${stdenv.cc.bintools.targetPrefix}gcc";
|
||||
HOSTCC = with buildPackages.pkgs;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchgit,
|
||||
fetchFromGitea,
|
||||
cmake,
|
||||
lua5_1,
|
||||
lua,
|
||||
json_c
|
||||
}:
|
||||
|
||||
|
@ -11,30 +11,32 @@ stdenv.mkDerivation rec {
|
|||
pname = "libubox";
|
||||
version = "unstable-2024-04-09";
|
||||
|
||||
src = fetchgit {
|
||||
url = "https://git.openwrt.org/project/libubox.git";
|
||||
rev = "eb9bcb64185ac155c02cc1a604692c4b00368324";
|
||||
hash = "sha256-5KO2E+4pcDp/pe2+vjoQDmyMwCc0yKm847U4J6HjxyA=";
|
||||
src = fetchFromGitea {
|
||||
domain = "git.dgnum.eu";
|
||||
owner = "DGNum";
|
||||
repo = "libubox";
|
||||
rev = "1c4b2dc4c12848e1b70b11e1cb2139ca8f19c860";
|
||||
hash = "sha256-aPhGJ7viXQmnoQRY8DuRvtwtxSy+S4qPj1fBsK066Yc=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
lua5_1
|
||||
lua
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
lua5_1
|
||||
lua
|
||||
json_c
|
||||
];
|
||||
|
||||
# Otherwise, CMake cannot find jsoncpp?
|
||||
env.NIX_CFLAGS_COMPILE = toString [ "-I${json_c.dev}/include/json-c" "-D JSONC" ];
|
||||
env.NIX_CFLAGS_COMPILE = toString [ "-I${json_c.dev}/include/json-c" "-D JSONC" "-D LUA_COMPAT_MODULE" ];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DBUILD_EXAMPLES=off"
|
||||
# TODO: it explode at install phase.
|
||||
"-DBUILD_LUA=on"
|
||||
"-DLUAPATH=${placeholder "out"}/lib/lua"
|
||||
"-DLUAPATH=${placeholder "out"}/lib/lua/${lua.luaversion}/"
|
||||
];
|
||||
|
||||
meta = {
|
||||
|
|
|
@ -39,6 +39,7 @@ let
|
|||
, contents ? []
|
||||
, buildInputs ? []
|
||||
, isTrigger ? false
|
||||
, passthru ? {}
|
||||
} @ args:
|
||||
stdenvNoCC.mkDerivation {
|
||||
# we use stdenvNoCC to avoid generating derivations with names
|
||||
|
@ -50,6 +51,8 @@ let
|
|||
dependencies = builtins.map (d: d.name) dependencies;
|
||||
contents = builtins.map (d: d.name) contents;
|
||||
builder = ./builder.sh;
|
||||
|
||||
inherit passthru;
|
||||
};
|
||||
|
||||
longrun = {
|
||||
|
@ -100,7 +103,18 @@ let
|
|||
serviceType = "bundle";
|
||||
inherit contents dependencies;
|
||||
});
|
||||
structuredBundle = {
|
||||
name
|
||||
, contents ? {}
|
||||
, dependencies ? []
|
||||
, ...
|
||||
} @ args: service (args // {
|
||||
serviceType = "bundle";
|
||||
contents = builtins.attrValues contents;
|
||||
inherit dependencies;
|
||||
passthru.components = contents;
|
||||
});
|
||||
target = bundle;
|
||||
in {
|
||||
inherit target bundle oneshot longrun output;
|
||||
inherit target bundle oneshot longrun output structuredBundle;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
ssh_command=${SSH_COMMAND-ssh}
|
||||
|
||||
|
@ -13,19 +14,24 @@ case "$1" in
|
|||
reboot="soft"
|
||||
shift
|
||||
;;
|
||||
"--root")
|
||||
root_prefix="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
|
||||
target_host=$1
|
||||
shift
|
||||
|
||||
if [ -z "$target_host" ] ; then
|
||||
echo Usage: liminix-rebuild \[--no-reboot\] target-host params
|
||||
echo Usage: liminix-rebuild \[--no-reboot\] \[--fast\] target-host params
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if toplevel=$(nix-build "$@" -A outputs.systemConfiguration --no-out-link); then
|
||||
echo systemConfiguration $toplevel
|
||||
min-copy-closure $target_host $toplevel
|
||||
min-copy-closure --root "$root_prefix" $target_host $toplevel
|
||||
$ssh_command $target_host $toplevel/bin/install
|
||||
case "$reboot" in
|
||||
reboot)
|
||||
|
|
|
@ -4,9 +4,13 @@
|
|||
#include <fcntl.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
#include <asm/setup.h> /* for COMMAND_LINE_SIZE */
|
||||
|
||||
|
@ -44,6 +48,25 @@ static int fork_exec(char * command, char *args[])
|
|||
return execve(command, args, NULL);
|
||||
}
|
||||
|
||||
static void debug_listdir(const char * path)
|
||||
{
|
||||
DIR *mydir;
|
||||
struct dirent *myfile;
|
||||
struct stat mystat;
|
||||
|
||||
char buf[512];
|
||||
mydir = opendir(path);
|
||||
while((myfile = readdir(mydir)) != NULL)
|
||||
{
|
||||
sprintf(buf, "%s/%s", path, myfile->d_name);
|
||||
stat(buf, &mystat);
|
||||
printf("%llu", mystat.st_size);
|
||||
printf(" %s\n", myfile->d_name);
|
||||
}
|
||||
closedir(mydir);
|
||||
|
||||
}
|
||||
|
||||
char banner[] = "Running pre-init...\n";
|
||||
char buf[COMMAND_LINE_SIZE];
|
||||
|
||||
|
@ -98,6 +121,7 @@ int main(int argc, char *argv[], char *envp[])
|
|||
AVER(mount(opts.device, "/target/persist", opts.fstype, 0, opts.mount_opts));
|
||||
} else {
|
||||
if(mount(opts.device, "/target/persist", opts.fstype, 0, opts.mount_opts) < 0) {
|
||||
ERR("failed to mount primary device, mount the alternative device\n");
|
||||
AVER(mount(opts.altdevice, "/target/persist", opts.fstype, 0, opts.mount_opts));
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +131,12 @@ int main(int argc, char *argv[], char *envp[])
|
|||
"bind", MS_BIND, NULL));
|
||||
|
||||
char *exec_args[] = { "activate", "/target", NULL };
|
||||
AVER(fork_exec("/target/persist/activate", exec_args));
|
||||
if (fork_exec("/target/persist/activate", exec_args) < 0) {
|
||||
ERR("failed to activate the system\n");
|
||||
pr_u32(errno); ERR ( " - "); ERR(strerror(errno)); ERR("\n");
|
||||
goto failsafe;
|
||||
}
|
||||
|
||||
AVER(chdir("/target"));
|
||||
|
||||
AVER(mount("/target", "/", "bind", MS_BIND | MS_REC, NULL));
|
||||
|
@ -118,5 +147,23 @@ int main(int argc, char *argv[], char *envp[])
|
|||
|
||||
AVER(execve("/persist/init", argv, envp));
|
||||
}
|
||||
|
||||
failsafe:
|
||||
debug_listdir("/");
|
||||
debug_listdir("/target");
|
||||
|
||||
ERR("failed to mount the rootfs\n");
|
||||
ERR("final stand using the failsafe initialization method\n");
|
||||
ERR("the boot process is manual from now on\n");
|
||||
|
||||
argv[0] = "init";
|
||||
argv[1] = NULL;
|
||||
// Attempt to unmount the /target mount-bind.
|
||||
AVER(umount("/target"));
|
||||
AVER(execve("/failsafe-init", argv, envp));
|
||||
|
||||
debug_listdir("/");
|
||||
debug_listdir("/target");
|
||||
|
||||
die();
|
||||
}
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
qemuLim
|
||||
, socat
|
||||
, writeShellScript
|
||||
, writeFennel
|
||||
, runCommand
|
||||
, fennel
|
||||
, lib
|
||||
, lua
|
||||
, pkgsBuildBuild
|
||||
}: let
|
||||
run-liminix-vm = pkgsBuildBuild.writeFennel "run-liminix-vm" {
|
||||
packages = [ qemuLim pkgsBuildBuild.lua.pkgs.luaposix pkgsBuildBuild.lua.pkgs.fennel ];
|
||||
writeFennel = pkgsBuildBuild.writeFennel.override { inherit lua; };
|
||||
run-liminix-vm = writeFennel "run-liminix-vm" {
|
||||
packages = [ qemuLim lua.pkgs.luaposix fennel ];
|
||||
} ./run-liminix-vm.fnl;
|
||||
connect = writeShellScript "connect-vm" ''
|
||||
export PATH="${lib.makeBinPath [socat]}:$PATH"
|
||||
|
|
|
@ -1,28 +1,35 @@
|
|||
{ stdenv, fetchFromGitHub, cmake, libubox, json_c, lua5_1 }:
|
||||
{ stdenv, fetchFromGitea, lib, cmake, libubox, json_c, lua, defaultSocketLocation ? "/run/ubus/ubus.sock" }:
|
||||
stdenv.mkDerivation {
|
||||
pname = "ubus";
|
||||
version = "unstable-04-09-2024";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "openwrt";
|
||||
src = fetchFromGitea {
|
||||
domain = "git.dgnum.eu";
|
||||
owner = "DGNum";
|
||||
repo = "ubus";
|
||||
rev = "65bb027054def3b94a977229fd6ad62ddd32345b";
|
||||
hash = "sha256-n82Ub0IiuvWbnlDCoN+0hjo/1PbplEbc56kuOYMrHxQ=";
|
||||
rev = "ebb1dc92e4985538a8e18b7e926264118138f281";
|
||||
hash = "sha256-fo4zleC9R6uzlcOJ/jQ0t0nSBHUAq/uqPVd9xJdkAM0=";
|
||||
};
|
||||
|
||||
# We don't use /var/run/ in Liminix by default.
|
||||
postPatch = ''
|
||||
substituteInPlace CMakeLists.txt \
|
||||
--replace-fail "/var/run/ubus/ubus.sock" "${defaultSocketLocation}"
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
lua5_1
|
||||
lua
|
||||
libubox
|
||||
json_c
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DBUILD_LUA=on"
|
||||
"-DLUAPATH=${placeholder "out"}/lib/lua"
|
||||
"-DLUAPATH=${placeholder "out"}/lib/lua/${lua.luaversion}"
|
||||
"-DBUILD_EXAMPLES=off"
|
||||
];
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ name :
|
|||
echo "#!${lua}/bin/lua ${luaFlags}"
|
||||
echo "package.path = ${lib.strings.escapeShellArg (builtins.concatStringsSep "" luapath)} .. package.path"
|
||||
echo "package.cpath = ${lib.strings.escapeShellArg (builtins.concatStringsSep "" luacpath)} .. package.cpath"
|
||||
echo "local ok, stdlib = pcall(require,'posix.stdlib'); if ok then stdlib.setenv('PATH',${lib.escapeShellArg (lib.makeBinPath packages)} .. \":\" .. os.getenv('PATH')) end"
|
||||
echo "local ok, stdlib = pcall(require,'posix.stdlib'); if ok then stdlib.setenv('PATH', \"${lib.makeBinPath packages}\" .. \":\" .. os.getenv('PATH')) end"
|
||||
fennel ${if correlate then "--correlate" else ""} --compile ${source}
|
||||
) > ${name}.lua
|
||||
'';
|
||||
|
|
|
@ -10,4 +10,5 @@
|
|||
tftpboot = import ./tftpboot/test.nix;
|
||||
updown = import ./updown/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/";
|
||||
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…
Reference in a new issue