forked from dan/liminix
Compare commits
371 Commits
Author | SHA1 | Date |
---|---|---|
Daniel Barlow | 635590d37a | |
Daniel Barlow | 17630f2678 | |
Daniel Barlow | 707a471bc2 | |
Daniel Barlow | d3fce5edd4 | |
Daniel Barlow | 5771108fed | |
Daniel Barlow | 9e5f2d663d | |
Daniel Barlow | 21eeb1671e | |
Daniel Barlow | 44762d38fc | |
Daniel Barlow | 1f6cfc3679 | |
Daniel Barlow | 8ec00f1710 | |
Daniel Barlow | 6a6dd32dea | |
Daniel Barlow | 9b1fc11a59 | |
Daniel Barlow | aaa6e353db | |
Daniel Barlow | 69bf6cb5fb | |
Daniel Barlow | 9f58e7b926 | |
Daniel Barlow | 5a5c27ab9f | |
Daniel Barlow | 277c91acdf | |
Daniel Barlow | e0725489ca | |
Daniel Barlow | cc47515cf8 | |
Daniel Barlow | 464913cc8f | |
Daniel Barlow | e604d628e3 | |
Daniel Barlow | e2a597589b | |
Raito Bezarius | a139a262c1 | |
Daniel Barlow | 6a5fed83dd | |
Daniel Barlow | bcf5ab24e8 | |
Daniel Barlow | 32bf80c6fa | |
Daniel Barlow | 12275f6896 | |
Daniel Barlow | a60c2539a6 | |
Daniel Barlow | 146a2d9ac0 | |
Daniel Barlow | 091d863710 | |
Daniel Barlow | c7bcfbfa34 | |
Daniel Barlow | 500a3c1025 | |
Daniel Barlow | 0c0d0eed8a | |
Daniel Barlow | 699cf97206 | |
Daniel Barlow | cd0093279c | |
Daniel Barlow | 034d6aacc4 | |
Daniel Barlow | e590c0ad3f | |
Daniel Barlow | 14abdd9998 | |
Daniel Barlow | 6287b92000 | |
Daniel Barlow | d2215d3e56 | |
Daniel Barlow | 3cf2308bee | |
Daniel Barlow | 3913989be3 | |
Daniel Barlow | 43e5e6876e | |
Daniel Barlow | 7d6c80570c | |
Daniel Barlow | e745991b9d | |
Daniel Barlow | defbfce1fb | |
Daniel Barlow | 0df2c83382 | |
Daniel Barlow | 01c28de88d | |
Daniel Barlow | 2bf197cad8 | |
Daniel Barlow | a8a19977ca | |
Daniel Barlow | 8a9284af1e | |
Daniel Barlow | 7351e143c5 | |
Daniel Barlow | 283c3154a7 | |
Daniel Barlow | 34f37d60d9 | |
Daniel Barlow | fe7b092075 | |
Daniel Barlow | b56f121e04 | |
Daniel Barlow | d5d621f310 | |
Daniel Barlow | da95a9fa62 | |
Daniel Barlow | 85071c88e7 | |
Daniel Barlow | 74093b7ee3 | |
Daniel Barlow | 41733e58d6 | |
Daniel Barlow | 9041d5d63a | |
Daniel Barlow | 001ebdc601 | |
Daniel Barlow | 1f97409474 | |
Daniel Barlow | a41839f3d1 | |
Daniel Barlow | ff76d854fc | |
Daniel Barlow | 81a6480a4f | |
Daniel Barlow | c7164a6f4a | |
Daniel Barlow | 83ca86fe42 | |
Daniel Barlow | 1b4106e2a3 | |
Daniel Barlow | 89912c766b | |
Daniel Barlow | 9828b007ae | |
Daniel Barlow | f34abc85ae | |
Daniel Barlow | b475a680fb | |
Daniel Barlow | 43612af71a | |
Daniel Barlow | 5695c47496 | |
Daniel Barlow | e3ec514710 | |
Daniel Barlow | 99f68e5421 | |
Daniel Barlow | 9c30b6f882 | |
Daniel Barlow | dd75322c10 | |
Daniel Barlow | 869a508c0a | |
Daniel Barlow | e835473945 | |
Daniel Barlow | 055268d5d2 | |
Daniel Barlow | ff38bcacbb | |
Daniel Barlow | a6128955e7 | |
Daniel Barlow | 531cb113be | |
Daniel Barlow | daede666cb | |
Daniel Barlow | 2992771c7e | |
Daniel Barlow | 4cc82e1502 | |
Daniel Barlow | 21f2320d86 | |
Daniel Barlow | d40ada4251 | |
Daniel Barlow | 4053ea9481 | |
Daniel Barlow | 54d3415885 | |
Daniel Barlow | 264d83c98d | |
Daniel Barlow | 97defc2076 | |
Daniel Barlow | ddaa5476d3 | |
Daniel Barlow | bcd9d56624 | |
Daniel Barlow | e2c883356c | |
Daniel Barlow | d79a941504 | |
Daniel Barlow | 2f82e0dab8 | |
Daniel Barlow | fc03965915 | |
Daniel Barlow | d2d3af2587 | |
Daniel Barlow | 310ac30f24 | |
Daniel Barlow | 45a7f96bd4 | |
Daniel Barlow | 79445fd962 | |
Daniel Barlow | a9ddd78482 | |
Daniel Barlow | 4fb8253e57 | |
Daniel Barlow | ff3a1905a5 | |
Daniel Barlow | 3c353e4aff | |
Daniel Barlow | ba21384fde | |
Daniel Barlow | 2480fdef5b | |
Daniel Barlow | 409c1cfb16 | |
Daniel Barlow | 9767078878 | |
Daniel Barlow | d760c2d27b | |
Daniel Barlow | 1e139c22fd | |
Daniel Barlow | a1ff07b063 | |
Daniel Barlow | 9550772cec | |
Daniel Barlow | 64cd1626c6 | |
Daniel Barlow | eb79928b37 | |
Daniel Barlow | 0a629df48d | |
Daniel Barlow | 64afd18e2a | |
Daniel Barlow | 47e96ddc15 | |
Daniel Barlow | 5db9d7269e | |
Daniel Barlow | 985df8792d | |
Daniel Barlow | 528afae8b1 | |
Daniel Barlow | 384835c89d | |
Daniel Barlow | 5051625d31 | |
Daniel Barlow | c4d00e062a | |
Daniel Barlow | 8fa3443923 | |
Daniel Barlow | 8091e207b6 | |
Daniel Barlow | 39020607ad | |
Daniel Barlow | fe735408a1 | |
Daniel Barlow | a9d1582b53 | |
Daniel Barlow | eca8e37e7a | |
Daniel Barlow | d300373b96 | |
Daniel Barlow | 70ca7fac17 | |
Daniel Barlow | 79a3a45061 | |
Daniel Barlow | 612d6d7a51 | |
Daniel Barlow | e1ae986cf6 | |
Daniel Barlow | bce0c7ffb6 | |
Daniel Barlow | 28ca1e68ab | |
Daniel Barlow | acf33a100f | |
Daniel Barlow | 7f9cae9d5c | |
Daniel Barlow | 3012c91b47 | |
Daniel Barlow | 1edf20c08f | |
Daniel Barlow | 7195cb10ce | |
Daniel Barlow | 135a445672 | |
Daniel Barlow | 3899daee56 | |
Daniel Barlow | b17f623d03 | |
Daniel Barlow | df395a4d5d | |
Daniel Barlow | 75e9f8210c | |
Daniel Barlow | 1c3242cab1 | |
Daniel Barlow | 44ea683391 | |
Daniel Barlow | 725d8b608f | |
Daniel Barlow | bc9ced5d38 | |
Daniel Barlow | 73ae7788b9 | |
Daniel Barlow | d34919766a | |
Daniel Barlow | 2fe0cd2f48 | |
Daniel Barlow | 241f1013ed | |
Daniel Barlow | 2ce361d4e3 | |
Daniel Barlow | 3f8cc24dcc | |
Daniel Barlow | 57e3b449f8 | |
Daniel Barlow | 3964505131 | |
Daniel Barlow | 941479b144 | |
Daniel Barlow | ac551536da | |
Daniel Barlow | 6f908156af | |
Daniel Barlow | 534a49e827 | |
Daniel Barlow | 07a6eb73cd | |
Daniel Barlow | 159bfa3057 | |
Daniel Barlow | 8f0ab5be40 | |
Daniel Barlow | 7f9971512d | |
Daniel Barlow | f0f6cc80d7 | |
Daniel Barlow | afcc6a6436 | |
Daniel Barlow | 2e8e05f31a | |
Daniel Barlow | 143137cbc6 | |
Daniel Barlow | 8d228f2bef | |
Daniel Barlow | 5751058d59 | |
Daniel Barlow | 5ac7e1e9b2 | |
Daniel Barlow | c75452549b | |
Daniel Barlow | 2663f58807 | |
Daniel Barlow | 9dbc285605 | |
Daniel Barlow | 8b6aa2134e | |
Daniel Barlow | 3df1ec76ff | |
Daniel Barlow | 0d3218127f | |
Daniel Barlow | e94bf62ec1 | |
Daniel Barlow | 16a2499d74 | |
Daniel Barlow | d4d8093f97 | |
Daniel Barlow | 7c9c801afc | |
Daniel Barlow | c4185617c0 | |
Daniel Barlow | 06d28e9b08 | |
Daniel Barlow | 9540fc2641 | |
Daniel Barlow | adc84108ad | |
Daniel Barlow | eae99051fa | |
Daniel Barlow | 49d1703428 | |
Daniel Barlow | 1d337588f9 | |
Daniel Barlow | 29a869b4fa | |
Daniel Barlow | 5ae1b0a193 | |
Daniel Barlow | 473a4947a5 | |
Daniel Barlow | 50bad5c604 | |
Daniel Barlow | c22e3fb2ef | |
Daniel Barlow | f898e4dca2 | |
Daniel Barlow | 5121a8563d | |
Daniel Barlow | 78be354b6e | |
Daniel Barlow | be13ab23ca | |
Daniel Barlow | 4b30cd7a75 | |
Daniel Barlow | b15542b668 | |
Daniel Barlow | 6daeaf29a0 | |
Daniel Barlow | e6ca5ea064 | |
Daniel Barlow | e6e4665a18 | |
Daniel Barlow | 2c10790a6d | |
Daniel Barlow | 571adf84c0 | |
Daniel Barlow | c8c79fd75a | |
Daniel Barlow | 884d8d194e | |
Daniel Barlow | f091bbd706 | |
Daniel Barlow | 37d7e20582 | |
Daniel Barlow | 04b068f7a3 | |
Daniel Barlow | 53f57c1a8c | |
Daniel Barlow | 19aba0d873 | |
Daniel Barlow | 7d00b39249 | |
Daniel Barlow | 7aa8633cde | |
Daniel Barlow | 58bec8a40f | |
Daniel Barlow | a3fca5bf05 | |
Daniel Barlow | e0bd7aec1e | |
Daniel Barlow | e815f61bb5 | |
Daniel Barlow | af9200a136 | |
Daniel Barlow | 898958fa10 | |
Daniel Barlow | fa0f262706 | |
Daniel Barlow | 71aeb27b2f | |
Daniel Barlow | 530b4080c9 | |
Daniel Barlow | 58cd007ccc | |
Daniel Barlow | 3a56798eb5 | |
Daniel Barlow | 758c7ef657 | |
Daniel Barlow | 73225a70b2 | |
Daniel Barlow | ab304dd3f1 | |
Daniel Barlow | 0d49f0f7a7 | |
Daniel Barlow | e64390460a | |
Daniel Barlow | c0ef6ce282 | |
Daniel Barlow | bd6ec5201f | |
Daniel Barlow | b4068da9fe | |
Daniel Barlow | aa4b09da85 | |
Daniel Barlow | 471c63b399 | |
Daniel Barlow | 782feaeafa | |
Daniel Barlow | ac54c89427 | |
Daniel Barlow | 5a3646cb29 | |
Daniel Barlow | e249f48cff | |
Daniel Barlow | 6661e42684 | |
Daniel Barlow | b9ba9ef835 | |
Daniel Barlow | 8b69dcc209 | |
Daniel Barlow | 9b3a3b9ff7 | |
Daniel Barlow | 7d08497bcb | |
Daniel Barlow | 0e84adaa0e | |
Daniel Barlow | 660ed5df8f | |
Daniel Barlow | 792a11c8c0 | |
Daniel Barlow | 7e4a05bbf8 | |
Daniel Barlow | a4ba5c85e1 | |
Daniel Barlow | 723ef73d5a | |
Daniel Barlow | 3d4e782929 | |
Daniel Barlow | 1b6a05aec5 | |
Daniel Barlow | 80628a3d90 | |
Daniel Barlow | bf0cafffed | |
Daniel Barlow | e49aba127c | |
Daniel Barlow | 324465bc18 | |
Daniel Barlow | b33249a050 | |
Daniel Barlow | b9c084415e | |
Daniel Barlow | cf9cadd212 | |
Daniel Barlow | a116fe084a | |
Daniel Barlow | 74cf3e0711 | |
Daniel Barlow | 9795f03da4 | |
Daniel Barlow | cdb23b147c | |
Daniel Barlow | dbd1264352 | |
Daniel Barlow | 834858d5bc | |
Daniel Barlow | 18335b95e3 | |
Daniel Barlow | 6bee2f67ac | |
Daniel Barlow | b4ba3eea21 | |
Daniel Barlow | 16af3984c9 | |
Daniel Barlow | ce7e395295 | |
Daniel Barlow | 7e13e017eb | |
Daniel Barlow | bbf2f53c0e | |
Daniel Barlow | 032d0f8aca | |
Daniel Barlow | b8ac9e5279 | |
Daniel Barlow | ff2604ca5d | |
Daniel Barlow | 72789984ce | |
Daniel Barlow | 90d9d0e811 | |
Daniel Barlow | 97a8ae1c84 | |
Daniel Barlow | 52eb283a26 | |
Daniel Barlow | cbb1de804e | |
Daniel Barlow | f9c03998b8 | |
Daniel Barlow | 50de1b090f | |
Daniel Barlow | 648382f64a | |
Daniel Barlow | e9370358ae | |
Daniel Barlow | 762ce7b6b8 | |
Daniel Barlow | b1c0560f4f | |
Daniel Barlow | e34135c41a | |
Daniel Barlow | 712c9b266f | |
Daniel Barlow | 4df963996c | |
Daniel Barlow | 349bfecbb8 | |
Daniel Barlow | 450d3820b2 | |
Daniel Barlow | 771585546d | |
Daniel Barlow | 73abf952d5 | |
Daniel Barlow | 8af4e9fd5b | |
Daniel Barlow | 7e19d80130 | |
Daniel Barlow | 0f0688c802 | |
Daniel Barlow | b43f17f655 | |
Daniel Barlow | adf62d4483 | |
Daniel Barlow | 68eb1360f6 | |
Daniel Barlow | 19ad6cd278 | |
Daniel Barlow | 00076c7b81 | |
Daniel Barlow | 721e7499f3 | |
Daniel Barlow | fc723b9a35 | |
Daniel Barlow | a5f16dfa81 | |
Daniel Barlow | 41a4b1f7ef | |
Daniel Barlow | 42a5699326 | |
Daniel Barlow | ea2b25168e | |
Daniel Barlow | 5564cf0554 | |
Daniel Barlow | f3a13630d3 | |
Daniel Barlow | f233acf9ff | |
Daniel Barlow | b6a054c588 | |
Daniel Barlow | b231664a06 | |
Daniel Barlow | f4bf3029fa | |
Daniel Barlow | 05f2c9a2f7 | |
Daniel Barlow | 5df5c822ea | |
Daniel Barlow | 4795dd05b7 | |
Daniel Barlow | a192f08881 | |
Daniel Barlow | a873dc6608 | |
Daniel Barlow | 2fb4756a7f | |
Daniel Barlow | 04f5174425 | |
Daniel Barlow | dca2e4def1 | |
Daniel Barlow | b60126775a | |
Daniel Barlow | 76f11bcc93 | |
Daniel Barlow | efcfdcc21d | |
Daniel Barlow | 77f1a78331 | |
Daniel Barlow | 28a5dec7dd | |
Daniel Barlow | fad0a47b75 | |
Daniel Barlow | af52aafc84 | |
Daniel Barlow | 34442b6069 | |
Daniel Barlow | b8a46fc05e | |
Daniel Barlow | 8ac2c6cec1 | |
Daniel Barlow | 8879b2d1ba | |
Daniel Barlow | 83e346d5a0 | |
Daniel Barlow | 156b1fe64a | |
Daniel Barlow | 1a314e55b7 | |
Daniel Barlow | 9263b21faa | |
Daniel Barlow | 0a820a702a | |
Daniel Barlow | 4ea518e296 | |
Daniel Barlow | 98318b450d | |
Daniel Barlow | e4ac7f19dc | |
Daniel Barlow | 9c22744850 | |
Daniel Barlow | c697be8c28 | |
dan | 202a37221a | |
Florian Klink | 436eb03a7b | |
Daniel Barlow | e5963ae3f7 | |
Daniel Barlow | f164f19d95 | |
Daniel Barlow | dd4ab41f6a | |
Daniel Barlow | 5d5dff6729 | |
Daniel Barlow | 570d29c368 | |
Daniel Barlow | 725af00dc9 | |
Daniel Barlow | e1b932ec27 | |
Daniel Barlow | 7173b6fb1c | |
Daniel Barlow | ed9548f21d | |
Daniel Barlow | 0787807a7f | |
Daniel Barlow | 38ed91f641 | |
Daniel Barlow | ffe9603c39 | |
Daniel Barlow | cbd3dfefc5 | |
Daniel Barlow | 018c1868b5 | |
Daniel Barlow | 5184ff63f7 | |
Daniel Barlow | 35909c9a23 | |
Daniel Barlow | 4383462199 | |
Daniel Barlow | 9730cdd63b | |
dan | 095853214b | |
sinavir | 27c7735f02 | |
sinavir | 29c9de248d |
31
NEWS
31
NEWS
|
@ -84,3 +84,34 @@ sponsoring this development (and funding the hardware)
|
||||||
|
|
||||||
New port! Thanks to Raito Bezarius, Liminix now runs on the Zyxel NWA50AX,
|
New port! Thanks to Raito Bezarius, Liminix now runs on the Zyxel NWA50AX,
|
||||||
an MT7621 (MIPS EL) dual radio WiFi AP.
|
an MT7621 (MIPS EL) dual radio WiFi AP.
|
||||||
|
|
||||||
|
2024-04-29
|
||||||
|
|
||||||
|
The setup for using `levitate` has changed: now it accepts an entire
|
||||||
|
config fragment, not just a list of services. Hopefully this makes it
|
||||||
|
a bit more useful :-)
|
||||||
|
|
||||||
|
defaultProfile.packages = with pkgs; [
|
||||||
|
...
|
||||||
|
(levitate.override {
|
||||||
|
config = {
|
||||||
|
services = {
|
||||||
|
inherit (config.services) dhcpc sshd watchdog;
|
||||||
|
};
|
||||||
|
defaultProfile.packages = [ mtdutils ];
|
||||||
|
users.root.openssh.authorizedKeys.keys = secrets.root.keys;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
2024-07-16
|
||||||
|
|
||||||
|
* structured parameters are available for the pppoe service
|
||||||
|
|
||||||
|
* The "wan" configuration in modules/profiles/gateway.nix has changed:
|
||||||
|
instead of passing options that are used to create a pppoe interface,
|
||||||
|
callers should create a (pppoe or other) interface and pass that as
|
||||||
|
the value of profile.gateway.wan. For the pppoe case this is now only
|
||||||
|
very slightly more verbose, and it allows using the gateway profile
|
||||||
|
with other kinds of upstream.
|
||||||
|
|
||||||
|
|
2050
THOUGHTS.txt
2050
THOUGHTS.txt
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,20 @@
|
||||||
|
# This is for use with minicom, but needs you to configure it to
|
||||||
|
# use expect as its "Script program" instead of runscript. Try
|
||||||
|
# Ctrl+A O -> Filenames and paths -> D
|
||||||
|
|
||||||
|
log_user 0
|
||||||
|
log_file -a -open stderr
|
||||||
|
set f [open "result/boot.scr"]
|
||||||
|
send "version\r"
|
||||||
|
set timeout 60
|
||||||
|
while {[gets $f line] >= 0} {
|
||||||
|
puts stderr "next line $line\r"
|
||||||
|
puts stderr "waiting for prompt\r"
|
||||||
|
expect {
|
||||||
|
"ath>" {}
|
||||||
|
"BusyBox" { puts stderr "DONE"; exit 0 }
|
||||||
|
}
|
||||||
|
send "$line\r\n"
|
||||||
|
}
|
||||||
|
puts stderr "done\r\n"
|
||||||
|
close $f
|
|
@ -4,6 +4,10 @@ let
|
||||||
inherit (lib) mkOption mkEnableOption mdDoc types optional optionals;
|
inherit (lib) mkOption mkEnableOption mdDoc types optional optionals;
|
||||||
in {
|
in {
|
||||||
options.bordervm = {
|
options.bordervm = {
|
||||||
|
keys = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
l2tp = {
|
l2tp = {
|
||||||
host = mkOption {
|
host = mkOption {
|
||||||
description = mdDoc ''
|
description = mdDoc ''
|
||||||
|
@ -51,18 +55,17 @@ in {
|
||||||
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
|
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
boot.kernelParams = [
|
boot.kernelParams = [ "loglevel=9" ];
|
||||||
"loglevel=9"
|
|
||||||
];
|
|
||||||
systemd.services.pppoe =
|
systemd.services.pppoe =
|
||||||
let conf = pkgs.writeText "kpppoed.toml"
|
let
|
||||||
''
|
conf = pkgs.writeText "kpppoed.toml" ''
|
||||||
interface_name = "eth1"
|
interface_name = "eth1"
|
||||||
services = [ "myservice" ]
|
services = [ "myservice" ]
|
||||||
lns_ipaddr = "${cfg.l2tp.host}:${builtins.toString cfg.l2tp.port}"
|
lns_ipaddr = "${cfg.l2tp.host}:${builtins.toString cfg.l2tp.port}"
|
||||||
ac_name = "kpppoed-1.0"
|
ac_name = "kpppoed-1.0"
|
||||||
'';
|
'';
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
@ -76,24 +79,46 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
|
services.dnsmasq = {
|
||||||
|
enable = true;
|
||||||
|
resolveLocalQueries = false;
|
||||||
|
settings = {
|
||||||
|
# domain-needed = true;
|
||||||
|
dhcp-range = [ "10.0.0.10,10.0.0.240" ];
|
||||||
|
interface = "eth1";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx = {
|
||||||
|
enable = true;
|
||||||
|
user = "liminix";
|
||||||
|
virtualHosts.${config.networking.hostName} = {
|
||||||
|
root = "/home/liminix";
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
systemd.services.nginx.serviceConfig.ProtectHome = "read-only";
|
||||||
|
|
||||||
systemd.services.sshd.wantedBy = pkgs.lib.mkForce [ "multi-user.target" ];
|
systemd.services.sshd.wantedBy = pkgs.lib.mkForce [ "multi-user.target" ];
|
||||||
|
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
qemu = {
|
qemu = {
|
||||||
networkingOptions = [];
|
networkingOptions = [ ];
|
||||||
options = [] ++
|
options =
|
||||||
optional cfg.ethernet.pci.enable
|
[ ]
|
||||||
"-device vfio-pci,host=${cfg.ethernet.pci.id}" ++
|
++ optional cfg.ethernet.pci.enable "-device vfio-pci,host=${cfg.ethernet.pci.id}"
|
||||||
optionals cfg.ethernet.usb.enable [
|
++ optionals cfg.ethernet.usb.enable [
|
||||||
"-device usb-ehci,id=ehci"
|
"-device usb-ehci,id=ehci"
|
||||||
"-device usb-host,bus=ehci.0,vendorid=${cfg.ethernet.usb.vendor},productid=${cfg.ethernet.usb.product}"
|
"-device usb-host,bus=ehci.0,vendorid=${cfg.ethernet.usb.vendor},productid=${cfg.ethernet.usb.product}"
|
||||||
] ++ [
|
]
|
||||||
|
++ [
|
||||||
"-nographic"
|
"-nographic"
|
||||||
"-serial mon:stdio"
|
"-serial mon:stdio"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
sharedDirectories = {
|
sharedDirectories = {
|
||||||
liminix = {
|
liminix = {
|
||||||
|
securityModel = "none";
|
||||||
source = builtins.toString ./.;
|
source = builtins.toString ./.;
|
||||||
target = "/home/liminix/liminix";
|
target = "/home/liminix/liminix";
|
||||||
};
|
};
|
||||||
|
@ -108,6 +133,7 @@ in {
|
||||||
tufted
|
tufted
|
||||||
iptables
|
iptables
|
||||||
usbutils
|
usbutils
|
||||||
|
busybox
|
||||||
];
|
];
|
||||||
security.sudo.wheelNeedsPassword = false;
|
security.sudo.wheelNeedsPassword = false;
|
||||||
networking = {
|
networking = {
|
||||||
|
@ -117,11 +143,17 @@ in {
|
||||||
useDHCP = false;
|
useDHCP = false;
|
||||||
ipv4.addresses = [ { address = "10.0.0.1"; prefixLength = 24;}];
|
ipv4.addresses = [ { address = "10.0.0.1"; prefixLength = 24;}];
|
||||||
};
|
};
|
||||||
|
nat = {
|
||||||
|
enable = true;
|
||||||
|
internalInterfaces = [ "eth1" ];
|
||||||
|
externalInterface = "eth0";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
users.users.liminix = {
|
users.users.liminix = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
uid = 1000;
|
uid = 1000;
|
||||||
extraGroups = [ "wheel"];
|
extraGroups = [ "wheel" ];
|
||||||
|
openssh.authorizedKeys.keys = cfg.keys;
|
||||||
};
|
};
|
||||||
services.getty.autologinUser = "liminix";
|
services.getty.autologinUser = "liminix";
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
{...}:
|
{ ... }:
|
||||||
{
|
{
|
||||||
bordervm = {
|
bordervm = {
|
||||||
# ethernet.pci = { id = "01:00.0"; enable = true; };
|
# ethernet.pci = { id = "01:00.0"; enable = true; };
|
||||||
ethernet.usb = { vendor = "0x0bda"; product = "0x8153"; enable = true; };
|
ethernet.usb = {
|
||||||
|
vendor = "0x0bda";
|
||||||
|
product = "0x8153";
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
l2tp = {
|
l2tp = {
|
||||||
host = "l2tp.aa.net.uk";
|
host = "l2tp.aa.net.uk";
|
||||||
};
|
};
|
||||||
|
|
66
ci.nix
66
ci.nix
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
nixpkgs
|
nixpkgs,
|
||||||
, unstable
|
unstable,
|
||||||
, liminix
|
liminix,
|
||||||
, ... }:
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
inherit (builtins) map;
|
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;
|
||||||
devices = [
|
devices = [
|
||||||
"gl-ar750"
|
"gl-ar750"
|
||||||
|
@ -27,45 +27,47 @@ let
|
||||||
}).outputs.default;
|
}).outputs.default;
|
||||||
tests = import ./tests/ci.nix;
|
tests = import ./tests/ci.nix;
|
||||||
jobs =
|
jobs =
|
||||||
(genAttrs devices for-device) //
|
(genAttrs devices for-device)
|
||||||
tests //
|
// tests
|
||||||
{
|
// {
|
||||||
buildEnv = (import liminix {
|
buildEnv =
|
||||||
inherit nixpkgs borderVmConf;
|
(import liminix {
|
||||||
device = import (liminix + "/devices/qemu");
|
inherit nixpkgs borderVmConf;
|
||||||
liminix-config = vanilla;
|
device = import (liminix + "/devices/qemu");
|
||||||
}).buildEnv;
|
liminix-config = vanilla;
|
||||||
|
}).buildEnv;
|
||||||
doc =
|
doc =
|
||||||
let json =
|
let
|
||||||
(import liminix {
|
json =
|
||||||
inherit nixpkgs borderVmConf;
|
(import liminix {
|
||||||
device = import (liminix + "/devices/qemu");
|
inherit nixpkgs borderVmConf;
|
||||||
liminix-config = {...} : {
|
device = import (liminix + "/devices/qemu");
|
||||||
|
liminix-config =
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
imports = [ ./modules/all-modules.nix ];
|
imports = [ ./modules/all-modules.nix ];
|
||||||
};
|
};
|
||||||
}).outputs.optionsJson;
|
}).outputs.optionsJson;
|
||||||
installers = map (f: "system.outputs.${f}") [
|
in
|
||||||
"vmroot"
|
pkgs.stdenv.mkDerivation {
|
||||||
"mtdimage"
|
|
||||||
"ubimage"
|
|
||||||
];
|
|
||||||
inherit (pkgs.lib) concatStringsSep;
|
|
||||||
in pkgs.stdenv.mkDerivation {
|
|
||||||
name = "liminix-doc";
|
name = "liminix-doc";
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
gnumake sphinx fennel luaPackages.lyaml
|
gnumake
|
||||||
|
sphinx
|
||||||
|
fennel
|
||||||
|
luaPackages.lyaml
|
||||||
];
|
];
|
||||||
src = ./.;
|
src = ./.;
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
cat ${json} | fennel --correlate doc/parse-options.fnl > doc/modules-generated.rst
|
cat ${json} | fennel --correlate doc/parse-options.fnl > doc/modules-generated.inc.rst
|
||||||
cat ${json} | fennel --correlate doc/parse-options-outputs.fnl > doc/outputs-generated.rst
|
cat ${json} | fennel --correlate doc/parse-options-outputs.fnl > doc/outputs-generated.inc.rst
|
||||||
cp ${(import ./doc/hardware.nix)} doc/hardware.rst
|
cp ${(import ./doc/hardware.nix)} doc/hardware.rst
|
||||||
make -C doc html
|
make -C doc html
|
||||||
'';
|
'';
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/nix-support $out/share/doc/
|
mkdir -p $out/nix-support $out/share/doc/
|
||||||
cd doc
|
cd doc
|
||||||
cp *-generated.rst $out
|
cp *-generated.inc.rst hardware.rst $out
|
||||||
ln -s ${json} $out/options.json
|
ln -s ${json} $out/options.json
|
||||||
cp -a _build/html $out/share/doc/liminix
|
cp -a _build/html $out/share/doc/liminix
|
||||||
echo "file source-dist \"$out/share/doc/liminix\"" \
|
echo "file source-dist \"$out/share/doc/liminix\"" \
|
||||||
|
|
48
default.nix
48
default.nix
|
@ -1,31 +1,39 @@
|
||||||
{
|
{
|
||||||
device
|
deviceName ? null,
|
||||||
, liminix-config ? <liminix-config>
|
device ? (import ./devices/${deviceName}),
|
||||||
, nixpkgs ? <nixpkgs>
|
liminix-config ? <liminix-config>,
|
||||||
, borderVmConf ? ./bordervm.conf.nix
|
nixpkgs ? <nixpkgs>,
|
||||||
, imageType ? "primary"
|
borderVmConf ? ./bordervm.conf.nix,
|
||||||
|
imageType ? "primary",
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
overlay = import ./overlay.nix;
|
overlay = import ./overlay.nix;
|
||||||
pkgs = import nixpkgs (device.system // {
|
pkgs = import nixpkgs (
|
||||||
overlays = [overlay];
|
device.system
|
||||||
config = {
|
// {
|
||||||
allowUnsupportedSystem = true; # mipsel
|
overlays = [ overlay ];
|
||||||
permittedInsecurePackages = [
|
config = {
|
||||||
"python-2.7.18.6" # kernel backports needs python <3
|
allowUnsupportedSystem = true; # mipsel
|
||||||
"python-2.7.18.7"
|
permittedInsecurePackages = [
|
||||||
];
|
"python-2.7.18.6" # kernel backports needs python <3
|
||||||
};
|
"python-2.7.18.7"
|
||||||
});
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
eval = pkgs.lib.evalModules {
|
eval = pkgs.lib.evalModules {
|
||||||
|
specialArgs = {
|
||||||
|
modulesPath = builtins.toString ./modules;
|
||||||
|
};
|
||||||
modules = [
|
modules = [
|
||||||
{ _module.args = { inherit pkgs; inherit (pkgs) lim; }; }
|
{ _module.args = { inherit pkgs; inherit (pkgs) lim; }; }
|
||||||
./modules/hardware.nix
|
./modules/hardware.nix
|
||||||
./modules/base.nix
|
./modules/base.nix
|
||||||
./modules/busybox.nix
|
./modules/busybox.nix
|
||||||
./modules/hostname.nix
|
./modules/hostname.nix
|
||||||
|
./modules/kernel
|
||||||
device.module
|
device.module
|
||||||
liminix-config
|
liminix-config
|
||||||
./modules/s6
|
./modules/s6
|
||||||
|
@ -41,7 +49,14 @@ let
|
||||||
borderVm = ((import <nixpkgs/nixos/lib/eval-config.nix>) {
|
borderVm = ((import <nixpkgs/nixos/lib/eval-config.nix>) {
|
||||||
system = builtins.currentSystem;
|
system = builtins.currentSystem;
|
||||||
modules = [
|
modules = [
|
||||||
({ ... } : { nixpkgs.overlays = [ overlay ]; })
|
{
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: prev: {
|
||||||
|
go-l2tp = final.callPackage ./pkgs/go-l2tp {};
|
||||||
|
tufted = final.callPackage ./pkgs/tufted {};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
(import ./bordervm-configuration.nix)
|
(import ./bordervm-configuration.nix)
|
||||||
borderVmConf
|
borderVmConf
|
||||||
];
|
];
|
||||||
|
@ -72,6 +87,7 @@ in {
|
||||||
min-copy-closure
|
min-copy-closure
|
||||||
fennelrepl
|
fennelrepl
|
||||||
lzma
|
lzma
|
||||||
|
lua
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
MTK_INFRACFG = "y";
|
MTK_INFRACFG = "y";
|
||||||
|
|
||||||
MTK_PMIC_WRAP = "y";
|
MTK_PMIC_WRAP = "y";
|
||||||
MTK_EFUSE="y";
|
NVMEM_MTK_EFUSE="y";
|
||||||
# MTK_HSDMA="y";
|
# MTK_HSDMA="y";
|
||||||
MTK_SCPSYS="y";
|
MTK_SCPSYS="y";
|
||||||
MTK_SCPSYS_PM_DOMAINS="y";
|
MTK_SCPSYS_PM_DOMAINS="y";
|
||||||
|
@ -92,7 +92,6 @@
|
||||||
|
|
||||||
MEDIATEK_GE_PHY = "y";
|
MEDIATEK_GE_PHY = "y";
|
||||||
# MEDIATEK_MT6577_AUXADC = "y";
|
# MEDIATEK_MT6577_AUXADC = "y";
|
||||||
# MEDIATEK_WATCHDOG = "y";
|
|
||||||
NET_MEDIATEK_SOC = "y";
|
NET_MEDIATEK_SOC = "y";
|
||||||
NET_MEDIATEK_SOC_WED = "y";
|
NET_MEDIATEK_SOC_WED = "y";
|
||||||
NET_MEDIATEK_STAR_EMAC = "y"; # this enables REGMAP_MMIO
|
NET_MEDIATEK_STAR_EMAC = "y"; # this enables REGMAP_MMIO
|
||||||
|
@ -214,7 +213,6 @@
|
||||||
networkInterfaces =
|
networkInterfaces =
|
||||||
let
|
let
|
||||||
inherit (config.system.service.network) link;
|
inherit (config.system.service.network) link;
|
||||||
inherit (config.system.service) bridge;
|
|
||||||
in rec {
|
in rec {
|
||||||
wan = link.build { ifname = "wan"; };
|
wan = link.build { ifname = "wan"; };
|
||||||
lan1 = link.build { ifname = "lan1"; };
|
lan1 = link.build { ifname = "lan1"; };
|
||||||
|
|
|
@ -1,234 +0,0 @@
|
||||||
{
|
|
||||||
system = {
|
|
||||||
crossSystem = {
|
|
||||||
config = "mipsel-unknown-linux-musl";
|
|
||||||
gcc = {
|
|
||||||
abi = "32";
|
|
||||||
arch = "mips32"; # mips32r2?
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Cudy X6
|
|
||||||
********************
|
|
||||||
|
|
||||||
Zyxel NWA50AX is quite close to the GL-MT300N-v2 "Mango" device, but it is based on the MT7621
|
|
||||||
chipset instead of the MT7628.
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
'';
|
|
||||||
|
|
||||||
module = { pkgs, config, lib, lim, ...}:
|
|
||||||
let
|
|
||||||
inherit (pkgs.liminix.networking) interface;
|
|
||||||
inherit (pkgs.liminix.services) oneshot;
|
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
|
||||||
inherit (pkgs) openwrt;
|
|
||||||
|
|
||||||
mac80211 = pkgs.mac80211.override {
|
|
||||||
drivers = [ "mt7915e" ];
|
|
||||||
klibBuild = config.system.outputs.kernel.modulesupport;
|
|
||||||
};
|
|
||||||
# v204520220929
|
|
||||||
wlan_firmware = pkgs.fetchurl {
|
|
||||||
url = "https://github.com/openwrt/mt76/raw/1b88dd07f153b202e57fe29734806744ed006b0e/firmware/mt7915_wa.bin";
|
|
||||||
hash = "sha256-wooyefzb0i8640+lwq3vNhcBXRFCtGuo+jiL7afZaKA=";
|
|
||||||
};
|
|
||||||
wlan_firmware' = pkgs.fetchurl {
|
|
||||||
url = "https://github.com/openwrt/mt76/raw/1b88dd07f153b202e57fe29734806744ed006b0e/firmware/mt7915_wm.bin";
|
|
||||||
hash = "sha256-k62nQewRuKjBLd5R3RxU4F74YKnQx5zr6gqMMImqVQw=";
|
|
||||||
};
|
|
||||||
wlan_firmware'' = pkgs.fetchurl {
|
|
||||||
url = "https://github.com/openwrt/mt76/raw/1b88dd07f153b202e57fe29734806744ed006b0e/firmware/mt7915_rom_patch.bin";
|
|
||||||
hash = "sha256-ifriAjWzFACrxVWCANZpUaEZgB/0pdbhnTVQytx6ddg=";
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
imports = [
|
|
||||||
# We include it to ensure the bridge functionality
|
|
||||||
# is available on the target kernel.
|
|
||||||
../../modules/bridge
|
|
||||||
../../modules/arch/mipsel.nix
|
|
||||||
../../modules/outputs/tftpboot.nix
|
|
||||||
../../modules/outputs/mtdimage.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
filesystem = dir {
|
|
||||||
lib = dir {
|
|
||||||
firmware = dir {
|
|
||||||
mediatek = dir {
|
|
||||||
"mt7915_wa.bin" = symlink wlan_firmware;
|
|
||||||
"mt7915_wm.bin" = symlink wlan_firmware';
|
|
||||||
"mt7915_rom_patch.bin" = symlink wlan_firmware'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
hardware = {
|
|
||||||
rootDevice = "/dev/mtdblock5";
|
|
||||||
|
|
||||||
defaultOutput = "mtdimage";
|
|
||||||
|
|
||||||
loadAddress = lim.parseInt "0x80001000";
|
|
||||||
entryPoint = lim.parseInt "0x80001000";
|
|
||||||
# Aligned on 2kb.
|
|
||||||
alignment = 2048;
|
|
||||||
|
|
||||||
flash = {
|
|
||||||
address = lim.parseInt "0xbc050000";
|
|
||||||
eraseBlockSize = 65536;
|
|
||||||
size = lim.parseInt "0x1F80000";
|
|
||||||
};
|
|
||||||
|
|
||||||
dts = {
|
|
||||||
src = "${openwrt.src}/target/linux/ramips/dts/mt7621_cudy_x6-v1.dts";
|
|
||||||
includes = [
|
|
||||||
"${openwrt.src}/target/linux/ramips/dts"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
networkInterfaces =
|
|
||||||
let
|
|
||||||
inherit (config.system.service.network) link;
|
|
||||||
in {
|
|
||||||
wan = link.build { ifname = "wan"; };
|
|
||||||
lan1 = link.build { ifname = "lan1"; };
|
|
||||||
lan2 = link.build { ifname = "lan2"; };
|
|
||||||
lan3 = link.build { ifname = "lan3"; };
|
|
||||||
lan4 = link.build { ifname = "lan4"; };
|
|
||||||
wlan0 = link.build {
|
|
||||||
ifname = "wlan0";
|
|
||||||
dependencies = [ mac80211 ];
|
|
||||||
};
|
|
||||||
wlan1 = link.build {
|
|
||||||
ifname = "wlan1";
|
|
||||||
dependencies = [ mac80211 ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
boot = {
|
|
||||||
imageFormat = "fit";
|
|
||||||
tftp = {
|
|
||||||
# 5MB is nice.
|
|
||||||
freeSpaceBytes = 5 * 1024 * 1024;
|
|
||||||
loadAddress = lim.parseInt "0x2000000";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
kernel = {
|
|
||||||
src = pkgs.fetchurl {
|
|
||||||
name = "linux.tar.gz";
|
|
||||||
url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz";
|
|
||||||
hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ=";
|
|
||||||
};
|
|
||||||
extraPatchPhase = ''
|
|
||||||
${openwrt.applyPatches.ramips}
|
|
||||||
|
|
||||||
'';
|
|
||||||
config = {
|
|
||||||
|
|
||||||
RALINK = "y";
|
|
||||||
PCI = "y";
|
|
||||||
PHY_MT7621_PCI = "y";
|
|
||||||
PCIE_MT7621 = "y";
|
|
||||||
SOC_MT7621 = "y";
|
|
||||||
CLK_MT7621 = "y";
|
|
||||||
CLOCKSOURCE_WATCHDOG = "y";
|
|
||||||
|
|
||||||
SERIAL_8250_CONSOLE = "y";
|
|
||||||
SERIAL_8250 = "y";
|
|
||||||
SERIAL_CORE_CONSOLE = "y";
|
|
||||||
SERIAL_OF_PLATFORM = "y";
|
|
||||||
SERIAL_8250_NR_UARTS = "3";
|
|
||||||
SERIAL_8250_RUNTIME_UARTS = "3";
|
|
||||||
SERIAL_MCTRL_GPIO = "y";
|
|
||||||
|
|
||||||
CONSOLE_LOGLEVEL_DEFAULT = "8";
|
|
||||||
CONSOLE_LOGLEVEL_QUIET = "4";
|
|
||||||
|
|
||||||
# MTD_UBI_BEB_LIMIT = "20";
|
|
||||||
# MTD_UBI_WL_THRESHOLD = "4096";
|
|
||||||
|
|
||||||
MTD = "y";
|
|
||||||
MTD_BLOCK = "y"; # fix undefined ref to register_mtd_blktrans_dev
|
|
||||||
MTD_RAW_NAND = "y";
|
|
||||||
MTD_NAND_MT7621 = "y";
|
|
||||||
MTD_NAND_MTK_BMT = "y"; # Bad-block Management Table
|
|
||||||
MTD_NAND_ECC_SW_HAMMING= "y";
|
|
||||||
MTD_SPI_NAND= "y";
|
|
||||||
MTD_OF_PARTS = "y";
|
|
||||||
MTD_NAND_CORE= "y";
|
|
||||||
MTD_SPLIT_FIRMWARE= "y";
|
|
||||||
MTD_SPLIT_FIT_FW= "y";
|
|
||||||
|
|
||||||
PINCTRL = "y";
|
|
||||||
PINCTRL_MT7621 = "y";
|
|
||||||
|
|
||||||
I2C = "y";
|
|
||||||
I2C_MT7621 = "y";
|
|
||||||
|
|
||||||
SPI = "y";
|
|
||||||
MTD_SPI_NOR = "y";
|
|
||||||
SPI_MT7621 = "y";
|
|
||||||
SPI_MASTER = "y";
|
|
||||||
SPI_MEM = "y";
|
|
||||||
|
|
||||||
REGULATOR = "y";
|
|
||||||
REGULATOR_FIXED_VOLTAGE = "y";
|
|
||||||
RESET_CONTROLLER = "y";
|
|
||||||
POWER_RESET = "y";
|
|
||||||
POWER_RESET_GPIO = "y";
|
|
||||||
POWER_SUPPLY = "y";
|
|
||||||
LED_TRIGGER_PHY = "y";
|
|
||||||
|
|
||||||
PCI_DISABLE_COMMON_QUIRKS = "y";
|
|
||||||
PCI_DOMAINS = "y";
|
|
||||||
PCI_DOMAINS_GENERIC = "y";
|
|
||||||
PCI_DRIVERS_GENERIC = "y";
|
|
||||||
PCS_MTK_LYNXI = "y";
|
|
||||||
|
|
||||||
SOC_BUS = "y";
|
|
||||||
|
|
||||||
NET = "y";
|
|
||||||
ETHERNET = "y";
|
|
||||||
WLAN = "y";
|
|
||||||
|
|
||||||
PHYLIB = "y";
|
|
||||||
AT803X_PHY = "y";
|
|
||||||
FIXED_PHY = "y";
|
|
||||||
GENERIC_PHY = "y";
|
|
||||||
NET_DSA = "y";
|
|
||||||
NET_DSA_MT7530 = "y";
|
|
||||||
NET_DSA_MT7530_MDIO = "y";
|
|
||||||
NET_DSA_TAG_MTK = "y";
|
|
||||||
NET_MEDIATEK_SOC = "y";
|
|
||||||
NET_SWITCHDEV = "y";
|
|
||||||
NET_VENDOR_MEDIATEK = "y";
|
|
||||||
|
|
||||||
SWPHY = "y";
|
|
||||||
|
|
||||||
GPIOLIB = "y";
|
|
||||||
GPIO_MT7621 = "y";
|
|
||||||
OF_GPIO = "y";
|
|
||||||
|
|
||||||
EARLY_PRINTK = "y";
|
|
||||||
|
|
||||||
NEW_LEDS = "y";
|
|
||||||
LEDS_TRIGGERS = "y";
|
|
||||||
LEDS_CLASS = "y"; # required by rt2x00lib
|
|
||||||
LEDS_CLASS_MULTICOLOR = "y";
|
|
||||||
LEDS_BRIGHTNESS_HW_CHANGED = "y";
|
|
||||||
|
|
||||||
PRINTK_TIME = "y";
|
|
||||||
} // lib.optionalAttrs (config.system.service ? vlan) {
|
|
||||||
SWCONFIG = "y";
|
|
||||||
} // lib.optionalAttrs (config.system.service ? watchdog) {
|
|
||||||
RALINK_WDT = "y"; # watchdog
|
|
||||||
MT7621_WDT = "y"; # or it might be this one
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -23,12 +23,17 @@
|
||||||
VIRTIO_BLK = "y";
|
VIRTIO_BLK = "y";
|
||||||
VIRTIO_NET = "y";
|
VIRTIO_NET = "y";
|
||||||
};
|
};
|
||||||
|
conditionalConfig = {
|
||||||
|
WLAN= {
|
||||||
|
MAC80211_HWSIM = "m";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
hardware =
|
hardware =
|
||||||
let
|
let
|
||||||
mac80211 = pkgs.mac80211.override {
|
mac80211 = pkgs.kmodloader.override {
|
||||||
drivers = ["mac80211_hwsim"];
|
inherit (config.system.outputs) kernel;
|
||||||
klibBuild = config.system.outputs.kernel.modulesupport;
|
targets = ["mac80211_hwsim"];
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
defaultOutput = "vmroot";
|
defaultOutput = "vmroot";
|
||||||
|
|
|
@ -92,7 +92,6 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs.liminix.networking) interface;
|
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
../../modules/network
|
../../modules/network
|
||||||
|
@ -125,8 +124,14 @@
|
||||||
networkInterfaces =
|
networkInterfaces =
|
||||||
let inherit (config.system.service.network) link;
|
let inherit (config.system.service.network) link;
|
||||||
in {
|
in {
|
||||||
lan = link.build { ifname = "eth0"; };
|
lan = link.build {
|
||||||
wan = link.build { ifname = "eth1"; };
|
ifname = "lan";
|
||||||
|
devpath = "/devices/platform/ahb/1a000000.eth";
|
||||||
|
};
|
||||||
|
wan = link.build {
|
||||||
|
ifname = "wan";
|
||||||
|
devpath = "/devices/platform/ahb/19000000.eth";
|
||||||
|
};
|
||||||
wlan = link.build {
|
wlan = link.build {
|
||||||
ifname = "wlan0";
|
ifname = "wlan0";
|
||||||
dependencies = [ mac80211 ];
|
dependencies = [ mac80211 ];
|
||||||
|
@ -149,6 +154,7 @@
|
||||||
};
|
};
|
||||||
boot.tftp = {
|
boot.tftp = {
|
||||||
loadAddress = lim.parseInt "0x00A00000";
|
loadAddress = lim.parseInt "0x00A00000";
|
||||||
|
appendDTB = true;
|
||||||
};
|
};
|
||||||
kernel = {
|
kernel = {
|
||||||
src = pkgs.pkgsBuildBuild.fetchurl {
|
src = pkgs.pkgsBuildBuild.fetchurl {
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
|
|
||||||
module = { pkgs, config, lib, lim, ...}:
|
module = { pkgs, config, lib, lim, ...}:
|
||||||
let
|
let
|
||||||
inherit (pkgs.liminix.networking) interface;
|
|
||||||
inherit (pkgs) openwrt;
|
inherit (pkgs) openwrt;
|
||||||
mac80211 = pkgs.kmodloader.override {
|
mac80211 = pkgs.kmodloader.override {
|
||||||
targets = ["rt2800soc"];
|
targets = ["rt2800soc"];
|
||||||
|
@ -90,19 +89,6 @@
|
||||||
let
|
let
|
||||||
inherit (config.system.service.network) link;
|
inherit (config.system.service.network) link;
|
||||||
inherit (config.system.service) vlan;
|
inherit (config.system.service) vlan;
|
||||||
inherit (pkgs.liminix.services) oneshot;
|
|
||||||
swconfig = oneshot {
|
|
||||||
name = "swconfig";
|
|
||||||
up = ''
|
|
||||||
PATH=${pkgs.swconfig}/bin:$PATH
|
|
||||||
swconfig dev switch0 set reset
|
|
||||||
swconfig dev switch0 set enable_vlan 1
|
|
||||||
swconfig dev switch0 vlan 1 set ports '1 2 3 4 6t'
|
|
||||||
swconfig dev switch0 vlan 2 set ports '0 6t'
|
|
||||||
swconfig dev switch0 set apply
|
|
||||||
'';
|
|
||||||
down = "${pkgs.swconfig}/bin/swconfig dev switch0 set reset";
|
|
||||||
};
|
|
||||||
in rec {
|
in rec {
|
||||||
eth = link.build { ifname = "eth0"; };
|
eth = link.build { ifname = "eth0"; };
|
||||||
# lan and wan ports are both behind a switch on eth0
|
# lan and wan ports are both behind a switch on eth0
|
||||||
|
@ -110,13 +96,11 @@
|
||||||
ifname = "eth0.1";
|
ifname = "eth0.1";
|
||||||
primary = eth;
|
primary = eth;
|
||||||
vid = "1";
|
vid = "1";
|
||||||
dependencies = [swconfig eth];
|
|
||||||
};
|
};
|
||||||
wan = vlan.build {
|
wan = vlan.build {
|
||||||
ifname = "eth0.2";
|
ifname = "eth0.2";
|
||||||
primary = eth;
|
primary = eth;
|
||||||
vid = "2";
|
vid = "2";
|
||||||
dependencies = [swconfig eth];
|
|
||||||
};
|
};
|
||||||
wlan = link.build {
|
wlan = link.build {
|
||||||
ifname = "wlan0";
|
ifname = "wlan0";
|
||||||
|
@ -126,7 +110,8 @@
|
||||||
};
|
};
|
||||||
boot.tftp = {
|
boot.tftp = {
|
||||||
loadAddress = lim.parseInt "0x00A00000";
|
loadAddress = lim.parseInt "0x00A00000";
|
||||||
};
|
appendDTB = true;
|
||||||
|
};
|
||||||
|
|
||||||
kernel = {
|
kernel = {
|
||||||
src = pkgs.fetchurl {
|
src = pkgs.fetchurl {
|
||||||
|
@ -136,6 +121,7 @@
|
||||||
};
|
};
|
||||||
extraPatchPhase = ''
|
extraPatchPhase = ''
|
||||||
${openwrt.applyPatches.ramips}
|
${openwrt.applyPatches.ramips}
|
||||||
|
${openwrt.applyPatches.rt2x00}
|
||||||
'';
|
'';
|
||||||
config = {
|
config = {
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
GL.iNet GL-MT300N-v2
|
GL.iNet GL-MT300N-v2
|
||||||
********************
|
********************
|
||||||
|
|
||||||
The GL-MT300N-v2 "Mango" is is very similar to the :ref:`MT300A <GL.iNet GL-MT300A>, but is
|
The GL-MT300N-v2 "Mango" is is very similar to the :ref:`gl-mt300a`, but is
|
||||||
based on the MT7628 chipset instead of MT7620. It's also marginally cheaper
|
based on the MT7628 chipset instead of MT7620. It's also marginally cheaper
|
||||||
and comes in a yellow case not a blue one. Be sure your device is
|
and comes in a yellow case not a blue one. Be sure your device is
|
||||||
v2 not v1, which is a different animal and has only half as much RAM.
|
v2 not v1, which is a different animal and has only half as much RAM.
|
||||||
|
@ -38,7 +38,6 @@
|
||||||
|
|
||||||
module = { pkgs, config, lib, lim, ...}:
|
module = { pkgs, config, lib, lim, ...}:
|
||||||
let
|
let
|
||||||
inherit (pkgs.liminix.networking) interface;
|
|
||||||
inherit (pkgs.liminix.services) oneshot;
|
inherit (pkgs.liminix.services) oneshot;
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs) openwrt;
|
inherit (pkgs) openwrt;
|
||||||
|
@ -97,7 +96,7 @@
|
||||||
swconfig dev switch0 vlan 2 set ports '0 6t'
|
swconfig dev switch0 vlan 2 set ports '0 6t'
|
||||||
swconfig dev switch0 set apply
|
swconfig dev switch0 set apply
|
||||||
'';
|
'';
|
||||||
down = "swconfig dev switch0 set reset";
|
down = "${pkgs.swconfig}/bin/swconfig dev switch0 set reset";
|
||||||
};
|
};
|
||||||
in rec {
|
in rec {
|
||||||
eth = link.build { ifname = "eth0"; dependencies = [swconfig]; };
|
eth = link.build { ifname = "eth0"; dependencies = [swconfig]; };
|
||||||
|
@ -122,6 +121,7 @@
|
||||||
# 20MB seems to give enough room to uncompress the kernel
|
# 20MB seems to give enough room to uncompress the kernel
|
||||||
# without anything getting trodden on. 10MB was too small
|
# without anything getting trodden on. 10MB was too small
|
||||||
loadAddress = lim.parseInt "0x1400000";
|
loadAddress = lim.parseInt "0x1400000";
|
||||||
|
appendDTB = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
kernel = {
|
kernel = {
|
||||||
|
|
|
@ -19,14 +19,14 @@
|
||||||
ARM targets differ from MIPS in that the kernel format expected
|
ARM targets differ from MIPS in that the kernel format expected
|
||||||
by QEMU is an "Image" (raw binary file) rather than an ELF
|
by QEMU is an "Image" (raw binary file) rather than an ELF
|
||||||
file, but this is taken care of by :command:`run.sh`. Check the
|
file, but this is taken care of by :command:`run.sh`. Check the
|
||||||
documentation for the :ref:`QEMU` (MIPS) target for more information.
|
documentation for the :ref:`qemu` target for more information.
|
||||||
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# this device is described by the "qemu" device
|
# this device is described by the "qemu" device
|
||||||
installer = "vmroot";
|
installer = "vmroot";
|
||||||
|
|
||||||
module = {pkgs, config, lim, ... }: {
|
module = { config, lim, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
../../modules/arch/aarch64.nix
|
../../modules/arch/aarch64.nix
|
||||||
../families/qemu.nix
|
../families/qemu.nix
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
'';
|
'';
|
||||||
installer = "vmroot";
|
installer = "vmroot";
|
||||||
|
|
||||||
module = {pkgs, config, lim, ... }: {
|
module = { config, lim, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
../../modules/arch/arm.nix
|
../../modules/arch/arm.nix
|
||||||
../families/qemu.nix
|
../families/qemu.nix
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
in the Development manual.
|
in the Development manual.
|
||||||
|
|
||||||
'';
|
'';
|
||||||
module = {pkgs, config, lib, lim, ... }: {
|
module = { config, lib, lim, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
../../modules/arch/mipseb.nix
|
../../modules/arch/mipseb.nix
|
||||||
../families/qemu.nix
|
../families/qemu.nix
|
||||||
|
|
|
@ -419,7 +419,6 @@
|
||||||
networkInterfaces =
|
networkInterfaces =
|
||||||
let
|
let
|
||||||
inherit (config.system.service.network) link;
|
inherit (config.system.service.network) link;
|
||||||
inherit (config.system.service) bridge;
|
|
||||||
in rec {
|
in rec {
|
||||||
lan1 = link.build { ifname = "lan1"; };
|
lan1 = link.build { ifname = "lan1"; };
|
||||||
lan2 = link.build { ifname = "lan2"; };
|
lan2 = link.build { ifname = "lan2"; };
|
||||||
|
|
|
@ -155,8 +155,6 @@
|
||||||
|
|
||||||
module = {pkgs, config, lib, lim, ... }:
|
module = {pkgs, config, lib, lim, ... }:
|
||||||
let
|
let
|
||||||
openwrt = pkgs.openwrt;
|
|
||||||
inherit (lib) mkOption types;
|
|
||||||
inherit (pkgs.liminix.services) oneshot;
|
inherit (pkgs.liminix.services) oneshot;
|
||||||
inherit (pkgs) liminix;
|
inherit (pkgs) liminix;
|
||||||
mtd_by_name_links = pkgs.liminix.services.oneshot rec {
|
mtd_by_name_links = pkgs.liminix.services.oneshot rec {
|
||||||
|
@ -358,7 +356,6 @@
|
||||||
networkInterfaces =
|
networkInterfaces =
|
||||||
let
|
let
|
||||||
inherit (config.system.service.network) link;
|
inherit (config.system.service.network) link;
|
||||||
inherit (config.system.service) bridge;
|
|
||||||
in rec {
|
in rec {
|
||||||
en70000 = link.build {
|
en70000 = link.build {
|
||||||
# in armada-38x.dtsi this is eth0.
|
# in armada-38x.dtsi this is eth0.
|
||||||
|
|
|
@ -103,8 +103,6 @@
|
||||||
|
|
||||||
module = { pkgs, config, lib, lim, ...}:
|
module = { pkgs, config, lib, lim, ...}:
|
||||||
let
|
let
|
||||||
inherit (pkgs.liminix.networking) interface;
|
|
||||||
inherit (pkgs.liminix.services) oneshot;
|
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs) openwrt;
|
inherit (pkgs) openwrt;
|
||||||
|
|
||||||
|
|
348
doc/admin.rst
348
doc/admin.rst
|
@ -4,143 +4,134 @@ System Administration
|
||||||
Services on a running system
|
Services on a running system
|
||||||
****************************
|
****************************
|
||||||
|
|
||||||
* add an s6-rc cheatsheet here
|
Liminix services are built on s6-rc, which is itself layered on s6.
|
||||||
|
Services are defined at build time in your configuration (see
|
||||||
|
:ref:`configuration-services` for information) and can't be added
|
||||||
|
to/changed at runtime, but to monitor
|
||||||
|
events or diagnose problems you may need to inspect them on the
|
||||||
|
running system. Here are some of the most commonly used s6,-rc
|
||||||
|
commands:
|
||||||
|
|
||||||
|
.. list-table:: Service management quick reference
|
||||||
|
:widths: 55 45
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
Flashing and updating
|
* - What
|
||||||
*********************
|
- How
|
||||||
|
* - List all running services
|
||||||
|
- ``s6-rc -a list``
|
||||||
|
* - List all services that are **not** running
|
||||||
|
- ``s6-rc -da list``
|
||||||
|
* - List services that ``wombat`` depends on
|
||||||
|
- ``s6-rc-db dependencies wombat``
|
||||||
|
* - ... transitively
|
||||||
|
- ``s6-rc-db all-dependencies wombat``
|
||||||
|
* - List services that depend on service ``wombat``
|
||||||
|
- ``s6-rc-db -d dependencies wombat``
|
||||||
|
* - ... transitively
|
||||||
|
- ``s6-rc-db -d all-dependencies wombat``
|
||||||
|
* - Stop service ``wombat`` and everything depending on it
|
||||||
|
- ``s6-rc -d change wombat``
|
||||||
|
* - Start service ``wombat`` (but not any services depending on it)
|
||||||
|
- ``s6-rc -u change wombat``
|
||||||
|
* - Start service ``wombat`` and all* services depending on it
|
||||||
|
- ``s6-rc-up-tree wombat``
|
||||||
|
|
||||||
|
:command:`s6-rc-up-tree` brings up a service and all services that
|
||||||
|
depend on it, except for any services that depend on a "controlled"
|
||||||
|
service that is not currently running. Controlled services are not
|
||||||
|
started at boot time but in response to external events (e.g. plugging
|
||||||
|
in a particular piece of hardware) so you probably don't want to be
|
||||||
|
starting them by hand if the conditions aren't there.
|
||||||
|
|
||||||
|
A service may be **up** or **down** (there are no intermediate states
|
||||||
|
like "started" or "stopping" or "dying" or "cogitating"). Some (but
|
||||||
|
not all) services have "readiness" notifications: the dependents of a
|
||||||
|
service with a readiness notification won't be started until the
|
||||||
|
service signals (by writing to a nominated file descriptor) that it's
|
||||||
|
prepared to start work. Most services defined by Liminix also have a
|
||||||
|
``timeout-up`` parameter, which means that if a service has readiness
|
||||||
|
notifications and doesn't become ready in the allotted time (defaults
|
||||||
|
20 seconds) it will be terminated and its state set to **down**.
|
||||||
|
|
||||||
Flashing from Liminix
|
If the process providing a service dies, it will be restarted
|
||||||
=====================
|
automatically. Liminix does not automatically set it to **down**.
|
||||||
|
|
||||||
The flash procedure from an existing Liminix-system has two steps.
|
(If the process providing a service dies without ever notifying
|
||||||
First we reboot the device (using "kexec") into an "ephemeral"
|
readiness, Liminix will restart it as many times as it has to until the
|
||||||
RAM-based version of the new configuration, then when we're happy it
|
timeout period elapses, and then stop it and mark it down.)
|
||||||
works we can flash the image - and if it doesn't work we can reboot
|
|
||||||
the device again and it will boot from the old image.
|
|
||||||
|
|
||||||
|
Controlled services
|
||||||
|
===================
|
||||||
|
|
||||||
Building the RAM-based image
|
**Controlled** services are those which are started/stopped on demand
|
||||||
----------------------------
|
by a **controller** (another service) instead of being started at boot
|
||||||
|
time. For example:
|
||||||
|
|
||||||
To create the ephemeral image, build ``outputs.kexecboot`` instead of
|
* ``svc.uevent-rule.build`` creates a controlled service which is
|
||||||
``outputs.default``. This generates a directory containing the root
|
active when a particular hardware device (identified by uevent/sysfs
|
||||||
filesystem image and kernel, along with an executable called `kexec`
|
directory) is present.
|
||||||
and a `boot.sh` script that runs it with appropriate arguments.
|
|
||||||
|
|
||||||
For example
|
* ``svc.round-robin.build`` creates a service controller that
|
||||||
|
invokes two or more services in turn, running the next one when the
|
||||||
|
process providing the previous one exits. We use this for failover
|
||||||
|
from one network connection to a backup connection, for example.
|
||||||
|
|
||||||
|
* ``svc.health-check.build`` creates a service controller that
|
||||||
|
runs a controlled service and periodically tests whether it is
|
||||||
|
healthy by running an external health check command or script. If the
|
||||||
|
check command repeatedly fails, the controlled service is
|
||||||
|
restarted.
|
||||||
|
|
||||||
|
The Configuration section of the manual describes controlled
|
||||||
|
services in more detail. Some operational considerations
|
||||||
|
|
||||||
|
* ``round-robin`` detects a service status by looking at its
|
||||||
|
:file:`outputs` directory, so it won't work unless the service
|
||||||
|
creates some outputs. This is considered a bug and will be
|
||||||
|
fixed in a future release
|
||||||
|
|
||||||
|
* ``health-check`` works for longruns but not for oneshots, as it
|
||||||
|
internally relies on ``s6-svc`` to restart the process
|
||||||
|
|
||||||
|
Logs
|
||||||
|
====
|
||||||
|
|
||||||
|
Logs for all services are collated into :file:`/run/uncaught-logs/current`.
|
||||||
|
The log file is rotated when it reaches a threshold size, into another
|
||||||
|
file in the same directory whose name contains a TAI64 timestamp.
|
||||||
|
|
||||||
|
Each log line is prefixed with a TAI64 timestamp and the name of the
|
||||||
|
service, if it is a longrun. If it is a oneshot, a timestamp and the
|
||||||
|
name of some other service. To convert the timestamp into a
|
||||||
|
human-readable format, use :command:`s6-tai64nlocal`.
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
nix-build -I liminix-config=./examples/arhcive.nix \
|
# ls -l /run/uncaught-logs/
|
||||||
--arg device "import ./devices/gl-ar750"
|
-rw-r--r-- 1 0 lock
|
||||||
-A outputs.kexecboot && \
|
-rw-r--r-- 1 0 state
|
||||||
(tar chf - result | ssh root@the-device tar -C /run -xvf -)
|
-rwxr--r-- 1 98059 @4000000000025cb629c311ac.s
|
||||||
|
-rwxr--r-- 1 98061 @40000000000260f7309c7fb4.s
|
||||||
|
-rwxr--r-- 1 98041 @40000000000265233a6cc0b6.s
|
||||||
|
-rwxr--r-- 1 98019 @400000000002695d10c06929.s
|
||||||
|
-rwxr--r-- 1 98064 @4000000000026d84189559e0.s
|
||||||
|
-rwxr--r-- 1 98055 @40000000000271ce1e031d91.s
|
||||||
|
-rwxr--r-- 1 98054 @400000000002760229733626.s
|
||||||
|
-rwxr--r-- 1 98104 @4000000000027a2e3b6f4e12.s
|
||||||
|
-rwxr--r-- 1 98023 @4000000000027e6f0ed24a6c.s
|
||||||
|
-rw-r--r-- 1 42374 current
|
||||||
|
|
||||||
and then login to the device and run
|
# tail -2 /run/uncaught-logs/current
|
||||||
|
@40000000000284f130747343 wan.link.pppoe Connect: ppp0 <--> /dev/pts/0
|
||||||
.. code-block:: console
|
@40000000000284f230acc669 wan.link.pppoe sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x667a9594> <pcomp> <accomp>]
|
||||||
|
# tail -2 /run/uncaught-logs/current | s6-tai64nlocal
|
||||||
cd /run/result
|
1970-01-02 21:51:45.828598156 wan.link.pppoe sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x667a9594> <pcomp> <accom
|
||||||
sh ./boot.sh .
|
p>]
|
||||||
|
1970-01-02 21:51:48.832588765 wan.link.pppoe sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x667a9594> <pcomp> <accom
|
||||||
|
p>]
|
||||||
|
|
||||||
|
|
||||||
This will load the new kernel and map the root filesystem into a RAM
|
|
||||||
disk, then start executing the new kernel. *This is effectively a
|
|
||||||
reboot - be sure to close all open files and finish anything else
|
|
||||||
you were doing first.*
|
|
||||||
|
|
||||||
If the new system crashes or is rebooted, then the device will revert
|
|
||||||
to the old configuration it finds in flash.
|
|
||||||
|
|
||||||
|
|
||||||
Building the second (permanent) image
|
|
||||||
-------------------------------------
|
|
||||||
|
|
||||||
While running in the kexecboot system, you can build the permanent
|
|
||||||
image and copy it to the device with :command:`ssh`
|
|
||||||
|
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
build-machine$ nix-build -I liminix-config=./examples/arhcive.nix \
|
|
||||||
--arg device "import ./devices/gl-ar750"
|
|
||||||
-A outputs.default && \
|
|
||||||
(tar chf - result | ssh root@the-device tar -C /run -xvf -)
|
|
||||||
|
|
||||||
build-machine$ tar chf - result/firmware.bin | \
|
|
||||||
ssh root@the-device tar -C /run -xvf -
|
|
||||||
|
|
||||||
Next you need to connect to the device and locate the "firmware"
|
|
||||||
partition, which you can do with a combination of :command:`dmesg`
|
|
||||||
output and the contents of :file:`/proc/mtd`
|
|
||||||
|
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
<5>[ 0.469841] Creating 4 MTD partitions on "spi0.0":
|
|
||||||
<5>[ 0.474837] 0x000000000000-0x000000040000 : "u-boot"
|
|
||||||
<5>[ 0.480796] 0x000000040000-0x000000050000 : "u-boot-env"
|
|
||||||
<5>[ 0.487056] 0x000000050000-0x000000060000 : "art"
|
|
||||||
<5>[ 0.492753] 0x000000060000-0x000001000000 : "firmware"
|
|
||||||
|
|
||||||
# cat /proc/mtd
|
|
||||||
dev: size erasesize name
|
|
||||||
mtd0: 00040000 00001000 "u-boot"
|
|
||||||
mtd1: 00010000 00001000 "u-boot-env"
|
|
||||||
mtd2: 00010000 00001000 "art"
|
|
||||||
mtd3: 00fa0000 00001000 "firmware"
|
|
||||||
mtd4: 002a0000 00001000 "kernel"
|
|
||||||
mtd5: 00d00000 00001000 "rootfs"
|
|
||||||
|
|
||||||
Now run (in this example)
|
|
||||||
|
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
flashcp -v firmware.bin /dev/mtd3
|
|
||||||
|
|
||||||
|
|
||||||
"I know my new image is good, can I skip the intermediate step?"
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
In addition to giving you a chance to see if the new image works, this
|
|
||||||
two-step process ensures that you're not copying the new image over
|
|
||||||
the top of the active root filesystem. Sometimes it works, but you
|
|
||||||
will at least need physical access to the device to power-cycle it
|
|
||||||
because it will be effectively frozen afterwards.
|
|
||||||
|
|
||||||
|
|
||||||
Flashing from the boot monitor
|
|
||||||
==============================
|
|
||||||
|
|
||||||
If you are prepared to open the device and have a TTL serial adaptor
|
|
||||||
of some kind to connect it to, you can probably use U-Boot and a TFTP
|
|
||||||
server to download and flash the image. This is quite
|
|
||||||
hardware-specific, and sometimes involves soldering: please refer
|
|
||||||
to :ref:`serial`.
|
|
||||||
|
|
||||||
|
|
||||||
Flashing from OpenWrt
|
|
||||||
=====================
|
|
||||||
|
|
||||||
.. CAUTION:: Untested! A previous version of these instructions
|
|
||||||
(without the -e flag) led to bricking the device
|
|
||||||
when flashing a jffs2 image. If you are reading
|
|
||||||
this message, nobody has yet reported on whether the
|
|
||||||
new instructions are any better.
|
|
||||||
|
|
||||||
If your device is running OpenWrt then it probably has the
|
|
||||||
:command:`mtd` command installed. After transferring the image onto the
|
|
||||||
device using e.g. :command:`ssh`, you can run it as follows:
|
|
||||||
|
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
mtd -e -r write /tmp/firmware.bin firmware
|
|
||||||
|
|
||||||
The options to this command are for "erase before writing" and "reboot
|
|
||||||
after writing".
|
|
||||||
|
|
||||||
For more information, please see the `OpenWrt manual <https://openwrt.org/docs/guide-user/installation/sysupgrade.cli>`_ which may also contain (hardware-dependent) instructions on how to flash an image using the vendor firmware - perhaps even from a web interface.
|
|
||||||
|
|
||||||
Updating an installed system (JFFS2)
|
Updating an installed system (JFFS2)
|
||||||
************************************
|
************************************
|
||||||
|
@ -165,6 +156,8 @@ Note that this only copies the package to the device: it doesn't update
|
||||||
any profile to add it to ``$PATH``
|
any profile to add it to ``$PATH``
|
||||||
|
|
||||||
|
|
||||||
|
.. _rebuilding the system:
|
||||||
|
|
||||||
Rebuilding the system
|
Rebuilding the system
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
|
@ -196,3 +189,116 @@ Caveats
|
||||||
nixpkgs).
|
nixpkgs).
|
||||||
|
|
||||||
* it cannot upgrade the kernel, only userland
|
* it cannot upgrade the kernel, only userland
|
||||||
|
|
||||||
|
.. _levitate:
|
||||||
|
|
||||||
|
Reinstalling on a running system
|
||||||
|
********************************
|
||||||
|
|
||||||
|
Liminix is initially installed from a monolithic
|
||||||
|
:file:`firmware.bin` - and unless you're running a writable
|
||||||
|
filesystem, the only way to update it is to build and install a whole
|
||||||
|
new :file:`firmware.bin`. However, you probably would prefer not to
|
||||||
|
have to remove it from its installation site, unplug it from the
|
||||||
|
network and stick serial cables in it all over again.
|
||||||
|
|
||||||
|
It is not (generally) safe to install a new firmware onto the flash
|
||||||
|
partitions that the active system is running on. To address this we
|
||||||
|
have :command:`levitate`, which a way for a running Liminix system to
|
||||||
|
"soft restart" into a ramdisk running only a limited set of services,
|
||||||
|
so that the main partitions can then be safely flashed.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
=============
|
||||||
|
|
||||||
|
Levitate *needs to be configured when you create the initial system*
|
||||||
|
to specify which services/packages/etc to run in maintenance
|
||||||
|
mode. Most likely you want to configure a network interface and an ssh
|
||||||
|
for example so that you can login to reflash it.
|
||||||
|
|
||||||
|
.. code-block:: nix
|
||||||
|
|
||||||
|
defaultProfile.packages = with pkgs; [
|
||||||
|
...
|
||||||
|
(levitate.override {
|
||||||
|
config = {
|
||||||
|
services = {
|
||||||
|
inherit (config.services) dhcpc sshd watchdog;
|
||||||
|
};
|
||||||
|
defaultProfile.packages = [ mtdutils ];
|
||||||
|
users.root = config.users.root;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Use
|
||||||
|
===
|
||||||
|
|
||||||
|
Connect (with ssh, probably) to the running Liminix system that you
|
||||||
|
wish to upgrade.
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
bash$ ssh root@the-device
|
||||||
|
|
||||||
|
Run :command:`levitate`. This takes a little while (perhaps a few
|
||||||
|
tens of seconds) to execute, and copies all config required for
|
||||||
|
maintenance mode to :file:`/run/maintenance`.
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
# levitate
|
||||||
|
|
||||||
|
Reboot into maintenance mode. You will be logged out
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
# reboot
|
||||||
|
|
||||||
|
Connect to the device again - note that the ssh host key will have changed.
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
# ssh -o UserKnownHostsFile=/dev/null root@the-device
|
||||||
|
|
||||||
|
Check we're in maintenance mode
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
# cat /etc/banner
|
||||||
|
|
||||||
|
LADIES AND GENTLEMEN WE ARE FLOATING IN SPACE
|
||||||
|
|
||||||
|
Most services are disabled. The system is operating
|
||||||
|
with a ram-based root filesystem, making it safe to
|
||||||
|
overwrite the flash devices in order to perform
|
||||||
|
upgrades and maintenance.
|
||||||
|
|
||||||
|
Don't forget to reboot when you have finished.
|
||||||
|
|
||||||
|
Perform the upgrade, using flashcp. This is an example,
|
||||||
|
your device will differ
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
# cat /proc/mtd
|
||||||
|
dev: size erasesize name
|
||||||
|
mtd0: 00030000 00010000 "u-boot"
|
||||||
|
mtd1: 00010000 00010000 "u-boot-env"
|
||||||
|
mtd2: 00010000 00010000 "factory"
|
||||||
|
mtd3: 00f80000 00010000 "firmware"
|
||||||
|
mtd4: 00220000 00010000 "kernel"
|
||||||
|
mtd5: 00d60000 00010000 "rootfs"
|
||||||
|
mtd6: 00010000 00010000 "art"
|
||||||
|
# flashcp -v firmware.bin mtd:firmware
|
||||||
|
|
||||||
|
All done
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
# reboot
|
||||||
|
|
||||||
|
|
|
@ -7,19 +7,19 @@
|
||||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
||||||
|
|
||||||
project = 'Liminix'
|
project = 'Liminix'
|
||||||
copyright = '2023, Daniel Barlow'
|
copyright = '2023-2024 Daniel Barlow'
|
||||||
author = 'Daniel Barlow'
|
author = 'Daniel Barlow'
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||||
|
|
||||||
extensions = [
|
extensions = [
|
||||||
'sphinx.ext.autosectionlabel'
|
# 'sphinx.ext.autosectionlabel'
|
||||||
]
|
]
|
||||||
autosectionlabel_prefix_document = True
|
autosectionlabel_prefix_document = True
|
||||||
|
|
||||||
templates_path = ['_templates']
|
templates_path = ['_templates']
|
||||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
exclude_patterns = ['*.inc.rst', '_build', 'Thumbs.db', '.DS_Store']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,8 @@
|
||||||
|
.. _configuration:
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
#############
|
#############
|
||||||
|
|
||||||
Liminix uses the Nix language to provide congruent configuration
|
|
||||||
management. This means that to change anything about the way in
|
|
||||||
which a Liminix system works, you make that change in
|
|
||||||
your :file:`configuration.nix` (or one of the other files it references),
|
|
||||||
and rerun :command:`nix-build` or :command:`liminix-rebuild` to action
|
|
||||||
the change. It is not possible (at least, without shenanigans) to make
|
|
||||||
changes by logging into the device and running imperative commands
|
|
||||||
whose effects may later be overridden: :file:`configuration.nix`
|
|
||||||
always describes the entire system and can be used to recreate that
|
|
||||||
system at any time. You can usefully keep it under version control.
|
|
||||||
|
|
||||||
If you are familiar with NixOS, you will notice some similarities
|
|
||||||
between NixOS and Liminix configuration, and also some
|
|
||||||
differences. Sometimes the differences are due to the
|
|
||||||
resource-constrained devices we deploy onto, sometimes due to
|
|
||||||
differences in the uses these devices are put to.
|
|
||||||
|
|
||||||
|
|
||||||
Configuration taxonomy
|
|
||||||
**********************
|
|
||||||
|
|
||||||
There are many things you can specify in a configuration, but these
|
There are many things you can specify in a configuration, but these
|
||||||
are the ones you most commonly need to change:
|
are the ones you most commonly need to change:
|
||||||
|
|
||||||
|
@ -86,14 +67,166 @@ domains, or you want to run two SSH daemons on different ports.
|
||||||
don't use the NixOS modules themselves, because the
|
don't use the NixOS modules themselves, because the
|
||||||
underlying system is not similar enough for them to work.
|
underlying system is not similar enough for them to work.
|
||||||
|
|
||||||
|
.. _configuration-services:
|
||||||
|
|
||||||
Services
|
Services
|
||||||
********
|
********
|
||||||
|
|
||||||
We use the `s6-rc service manager <https://www.skarnet.org/software/s6-rc/overview.html>`_ to start/stop/restart services and handle
|
In Liminix a service is any kind of long-running task or process on
|
||||||
service dependencies. Any attribute in `config.services` will become
|
the system, that is managed (started, stopped, and monitored) by a
|
||||||
part of the default set of services that s6-rc will try to bring up on
|
service supervisor. A typical SOHO router might have services to
|
||||||
boot.
|
|
||||||
|
* answer DHCP and DNS requests from the LAN
|
||||||
|
* provide a wireless access point
|
||||||
|
* connect using PPPoE or L2TP to an upstream network
|
||||||
|
* start/stop the firewall
|
||||||
|
* enable/disable IP packet forwarding
|
||||||
|
* mount filesystems
|
||||||
|
|
||||||
|
(Some of these might not be considered services using other
|
||||||
|
definitions of the term: for example, this L2TP process would be a
|
||||||
|
"client" in the client/server classification; and enabling packet
|
||||||
|
forwarding doesn't require any long-lived process - just a setting to
|
||||||
|
be toggled. However, there is value in being able to use the same
|
||||||
|
abstractions for all the things to manage them and specify their
|
||||||
|
dependency relationships - so in Liminix "everything is a service")
|
||||||
|
|
||||||
|
The service supervision system enables service health monitoring,
|
||||||
|
restart of unhealthy services, and failover to "backup" services when
|
||||||
|
a primary service fails or its dependencies are unavailable. The
|
||||||
|
intention is that you have a framework in which you can specify policy
|
||||||
|
requirements like "ethernet wan dhcp-client should be restarted if it
|
||||||
|
crashes, but if it can't start because the hardware link is down, then
|
||||||
|
4G ppp service should be started instead".
|
||||||
|
|
||||||
|
Any attribute in `config.services` will become part of the default set
|
||||||
|
of services that s6-rc will try to bring up. Services are usually
|
||||||
|
started at boot time, but **controlled services** are those that are
|
||||||
|
required only in particular contexts. For example, a service to mount
|
||||||
|
a USB backup drive should run only when the drive is attached to the
|
||||||
|
system. Liminix currently implements three kinds of controlled service:
|
||||||
|
|
||||||
|
* "uevent-rule" service controllers use sysfs/uevent to identify when
|
||||||
|
particular hardware devices are present, and start/stop a controlled
|
||||||
|
service appropriately.
|
||||||
|
|
||||||
|
* the "round-robin" service controller is used for service failover:
|
||||||
|
it allows you to specify a list of services and runs each of them
|
||||||
|
in turn until it exits, then runs the next.
|
||||||
|
|
||||||
|
* the "health-check" service wraps another service, and runs a "health
|
||||||
|
check" command at regular intervals. When the health check fails,
|
||||||
|
indicating that the wrapped service is not working, it is terminated
|
||||||
|
and allowed to restart.
|
||||||
|
|
||||||
|
Runtime secrets (external vault)
|
||||||
|
================================
|
||||||
|
|
||||||
|
Secrets (such as wifi passphrases, PPP username/password, SSH keys,
|
||||||
|
etc) that you provide as literal values in :file:`configuration.nix`
|
||||||
|
are processed into into config files and scripts at build time, and
|
||||||
|
eventually end up in various files in the (world-readable)
|
||||||
|
:file:`/nix/store` before being baked into a flashable image. To
|
||||||
|
change a secret - whether due to a compromise, or just as part of to a
|
||||||
|
routine key rotation - you need to rebuild the configuration and
|
||||||
|
potentially reflash the affected devices.
|
||||||
|
|
||||||
|
To avoid this, you may instead use a "secrets service", which is a
|
||||||
|
mechanism for your device to fetch secrets from a source external to
|
||||||
|
the Nix store, and create at runtime the configuration files and
|
||||||
|
scripts that start the services which require them.
|
||||||
|
|
||||||
|
Not every possible parameter to every possible service is configurable
|
||||||
|
using a secrets service. Parameters which can be configured this way
|
||||||
|
are those with the type ``liminix.lib.types.replacable``. At the time
|
||||||
|
this document was written, these include:
|
||||||
|
|
||||||
|
* ppp (pppoe and l2tp): ``username``, ``password``
|
||||||
|
* ssh: ``authorizedKeys``
|
||||||
|
* hostapd: all parameters (most likely to be useful for ``wpa_passphrase``)
|
||||||
|
|
||||||
|
To use a runtime secret for any of these parameters:
|
||||||
|
|
||||||
|
* create a secrets service to specify the source of truth for secrets
|
||||||
|
* use the :code:`outputRef` function in the service parameter to specify the secrets service and path
|
||||||
|
|
||||||
|
For example, given you had an HTTPS server hosting a JSON file with the structure
|
||||||
|
|
||||||
|
.. code-block:: json
|
||||||
|
|
||||||
|
"ssh": {
|
||||||
|
"authorizedKeys": {
|
||||||
|
"root": [ "ssh-rsa ....", "ssh-rsa ....", ... ]
|
||||||
|
"guest": [ "ssh-rsa ....", "ssh-rsa ....", ... ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
you could use a :file:`configuration.nix` fragment something like this
|
||||||
|
to make those keys visible to ssh:
|
||||||
|
|
||||||
|
.. code-block:: nix
|
||||||
|
|
||||||
|
services.secrets = svc.secrets.outboard.build {
|
||||||
|
name = "secret-service";
|
||||||
|
url = "http://10.0.0.1/secrets.json";
|
||||||
|
username = "secrets";
|
||||||
|
password = "liminix";
|
||||||
|
interval = 30; # minutes
|
||||||
|
dependencies = [ config.services.lan ];
|
||||||
|
};
|
||||||
|
services.sshd = svc.ssh.build {
|
||||||
|
authorizedKeys = outputRef config.services.secrets "ssh/authorizedKeys";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
There are presently two implementations of a secrets service:
|
||||||
|
|
||||||
|
Outboard secrets (HTTPS)
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
This service expects a URL to a JSON file containing all the secrets.
|
||||||
|
|
||||||
|
You may specify a username and password along with the URL, which are
|
||||||
|
used if the file is password-protected (HTTP Basic
|
||||||
|
authentication). Note that this is not a protection against a
|
||||||
|
malicious local user: the username and password are normal build-time
|
||||||
|
parameters so will be readable in the Nix store. This is a mitigation
|
||||||
|
against the URL being accidentally discovered due to e.g. a log file
|
||||||
|
or error message on the server leaking.
|
||||||
|
|
||||||
|
|
||||||
|
Tang secrets (encrypted local file)
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
Aternatively, secrets may be stored locally on the device, in a file
|
||||||
|
that has been encrypted using `Tang <https://github.com/latchset/tang>`_.
|
||||||
|
|
||||||
|
Tang is a server for binding data to network presence.
|
||||||
|
|
||||||
|
This sounds fancy, but the concept is simple. You have some data, but you only want it to be available when the system containing the data is on a certain, usually secure, network.
|
||||||
|
|
||||||
|
|
||||||
|
.. code-block:: nix
|
||||||
|
|
||||||
|
services.secrets = svc.secrets.tang.build {
|
||||||
|
name = "secret-service";
|
||||||
|
path = "/run/mnt/usbstick/secrets.json.jwe";
|
||||||
|
interval = 30; # minutes
|
||||||
|
dependencies = [ config.services.mount-usbstick ];
|
||||||
|
};
|
||||||
|
|
||||||
|
The encryption uses the
|
||||||
|
same scheme/algorithm as `Clevis <https://github.com/latchset/clevis>`_ : you may use the `Clevis instructions <https://github.com/latchset/clevis?tab=readme-ov-file#pin-tang>`_ to
|
||||||
|
encrypt the file on another host and then copy it to your Liminix
|
||||||
|
device, or you can use :command:`tangc encrypt` to encrypt directly on
|
||||||
|
the device. (That latter approach may pose a chicken/egg problem if
|
||||||
|
the device needs secrets to boot up and run the services you are
|
||||||
|
relying on in order to login).
|
||||||
|
|
||||||
|
|
||||||
|
Writing services
|
||||||
|
================
|
||||||
|
|
||||||
For the most part, for common use cases, hopefully the services you
|
For the most part, for common use cases, hopefully the services you
|
||||||
need will be defined by modules and you will only have to pass the
|
need will be defined by modules and you will only have to pass the
|
||||||
|
@ -141,11 +274,101 @@ Services may have dependencies: as you see above in the ``cowsayd``
|
||||||
example, it depends on some service called ``config.services.lan``,
|
example, it depends on some service called ``config.services.lan``,
|
||||||
meaning that it won't be started until that other service is up.
|
meaning that it won't be started until that other service is up.
|
||||||
|
|
||||||
..
|
Service outputs
|
||||||
TODO: explain service outputs
|
===============
|
||||||
|
|
||||||
|
Outputs are a mechanism by which a service can provide data which may
|
||||||
|
be required by other services. For example:
|
||||||
|
|
||||||
|
* the DHCP client service can expect to receive nameserver address
|
||||||
|
information as one of the fields in the response from the DHCP
|
||||||
|
server: we provide that as an output which a dependent service for a
|
||||||
|
stub name resolver can use to configure its upstream servers.
|
||||||
|
|
||||||
|
* a service that creates a new network interface (e.g. ppp) will
|
||||||
|
provide the name of the interface (:code:`ppp0`, or :code:`ppp1` or
|
||||||
|
:code:`ppp7`) as an output so that a dependent service can reference
|
||||||
|
it to set up a route, or to configure firewall rules.
|
||||||
|
|
||||||
|
A service :code:`myservice` should write its outputs as files in
|
||||||
|
:file:`/run/services/outputs/myservice`: you can look around this
|
||||||
|
directory on a running Liminix system to see how it's used currently.
|
||||||
|
Usually we use the :code:`in_outputs` shell function in the
|
||||||
|
:command:`up` or :command:`run` attributes of the service:
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
(in_outputs ${name}
|
||||||
|
for i in lease mask ip router siaddr dns serverid subnet opt53 interface ; do
|
||||||
|
(printenv $i || true) > $i
|
||||||
|
done)
|
||||||
|
|
||||||
|
The outputs are just files, so technically you can read them using
|
||||||
|
anything that can read a file. Liminix has two "preferred"
|
||||||
|
mechanisms, though:
|
||||||
|
|
||||||
|
One-off lookups
|
||||||
|
---------------
|
||||||
|
|
||||||
|
In any context that ends up being evaluated by the shell, use
|
||||||
|
:code:`output` to print the value of an output
|
||||||
|
|
||||||
|
.. code-block:: nix
|
||||||
|
|
||||||
|
services.defaultroute4 = svc.network.route.build {
|
||||||
|
via = "$(output ${services.wan} address)";
|
||||||
|
target = "default";
|
||||||
|
dependencies = [ services.wan ];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Continuous updates
|
||||||
|
------------------
|
||||||
|
|
||||||
|
The downside of using shell functions in downstream service startup
|
||||||
|
scripts is that they only run when the service starts up: if a service
|
||||||
|
output *changes*, the downstream service would have to be restarted to
|
||||||
|
notice the change. Sometimes this is OK but other times the downstream
|
||||||
|
has no other need to restart, if it can only get its new data.
|
||||||
|
|
||||||
|
For this case, there is the :code:`anoia.svc` Fennel library, which
|
||||||
|
allows you to write a simple loop which is iterated over whenever a
|
||||||
|
service's outputs change. This code is from
|
||||||
|
:file:`modules/dhcp6c/acquire-wan-address.fnl`
|
||||||
|
|
||||||
|
.. code-block:: fennel
|
||||||
|
|
||||||
|
(fn update-addresses [wan-device addresses new-addresses exec]
|
||||||
|
;; run some appropriate "ip address [add|remove]" commands
|
||||||
|
)
|
||||||
|
|
||||||
|
(fn run []
|
||||||
|
(let [[state-directory wan-device] arg
|
||||||
|
dir (svc.open state-directory)]
|
||||||
|
(accumulate [addresses []
|
||||||
|
v (dir:events)]
|
||||||
|
(update-addresses wan-device addresses
|
||||||
|
(or (v:output "address") []) system))))
|
||||||
|
|
||||||
|
The :code:`output` method seen here accepts a filename (relative
|
||||||
|
to the service's output directory), or a directory name. It
|
||||||
|
returns the first line of that file, or for directories it
|
||||||
|
returns a table (Lua's key/value datastructure, similar to
|
||||||
|
a hash/dictionary) of the outputs in that directory.
|
||||||
|
|
||||||
|
|
||||||
|
Output design considerations
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
For preference, outputs should be short and simple, and not require
|
||||||
|
downstream services to do complicated parsing in order to use them.
|
||||||
|
Shell commands in Liminix are run using the Busybox shell which
|
||||||
|
doesn't have the niceties of an advanced shell like Bash let alone
|
||||||
|
those of a real programming language.
|
||||||
|
|
||||||
|
Note also that the Lua :code:`svc` library only reads the first line
|
||||||
|
of each output.
|
||||||
|
|
||||||
..
|
|
||||||
TODO: outputs that change, and services that poll other services
|
|
||||||
|
|
||||||
Module implementation
|
Module implementation
|
||||||
*********************
|
*********************
|
||||||
|
@ -192,7 +415,7 @@ To expose a service template in a module, it needs the following:
|
||||||
|
|
||||||
.. code-block:: nix
|
.. code-block:: nix
|
||||||
|
|
||||||
config.system.service.cowsay = liminix.callService ./service.nix {
|
config.system.service.cowsay = config.system.callService ./service.nix {
|
||||||
address = mkOption {
|
address = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "0.0.0.0";
|
default = "0.0.0.0";
|
||||||
|
|
|
@ -88,64 +88,6 @@ time with configurations for RP-PPPoE and/or Accel PPP.`
|
||||||
Hardware devices
|
Hardware devices
|
||||||
****************
|
****************
|
||||||
|
|
||||||
.. _serial:
|
|
||||||
|
|
||||||
U-Boot and serial shenanigans
|
|
||||||
=============================
|
|
||||||
|
|
||||||
Every device that we have so far encountered in Liminix uses `U-Boot,
|
|
||||||
the "Universal Boot Loader" <https://docs.u-boot.org/en/latest/>`_ so
|
|
||||||
it's worth knowing a bit about it. "Universal" is in this context a
|
|
||||||
bit of a misnomer, though: encountering *mainline* U-Boot is very rare
|
|
||||||
and often you'll find it is a fork from some version last updated
|
|
||||||
in 2008. Upgrading U-Boot is more or less complicated depending on the
|
|
||||||
device and is outside scope for Liminix.
|
|
||||||
|
|
||||||
To speak to U-Boot on your device you'll usually need a serial
|
|
||||||
connection to it. This is device-specific. Usually it involves
|
|
||||||
opening the box, locating the serial header pins (TX, RX and GND) and
|
|
||||||
connecting a USB TTL converter to them.
|
|
||||||
|
|
||||||
The Rolls Royce of USB/UART cables is the `FTDI cable
|
|
||||||
<https://cpc.farnell.com/ftdi/ttl-232r-rpi/cable-debug-ttl-232-usb-rpi/dp/SC12825?st=usb%20to%20uart%20cable>`_,
|
|
||||||
but there are cheaper alternatives based on the PL2303 and CP2102 chipsets. Or
|
|
||||||
get creative and use the `UART GPIO pins <https://pinout.xyz/>`_ on a Raspberry Pi. Whatever you do, make sure
|
|
||||||
that the voltages are compatible: if your device is 3.3V (this is
|
|
||||||
typical but not universal), you don't want to be sending it 5v or
|
|
||||||
(even worse) 12v.
|
|
||||||
|
|
||||||
Run a terminal emulator such as Minicom on the computer at other end
|
|
||||||
of the link. 115200 8N1 is the typical speed.
|
|
||||||
|
|
||||||
.. NOTE::
|
|
||||||
|
|
||||||
TTL serial connections typically have no form of flow control and
|
|
||||||
so don't always like having massive chunks of text pasted into
|
|
||||||
them - and U-Boot may drop characters while it's busy. So don't
|
|
||||||
necessarily expect to copy-paste large chunks of text into the
|
|
||||||
terminal emulator and have it work just like that.
|
|
||||||
|
|
||||||
If using Minicom, you may find it helps to bring up the "Termimal
|
|
||||||
settings" dialog (C^A T), then configure "Newline tx delay" to
|
|
||||||
some small but non-zero value.
|
|
||||||
|
|
||||||
When you turn the router on you should be greeted with some messages
|
|
||||||
from U-Boot, followed by the instruction to hit some key to stop
|
|
||||||
autoboot. Do this and you will get to the prompt. If you didn't see
|
|
||||||
anything, the strong likelihood is that TX and RX are the wrong way
|
|
||||||
around. If you see garbage, try a different speed.
|
|
||||||
|
|
||||||
Interesting commands to try first in U-Boot are :command:`help` and
|
|
||||||
:command:`printenv`.
|
|
||||||
|
|
||||||
To do anything useful with U-Boot you will probably need a way to get
|
|
||||||
large binary files onto the device, and the usual way to do this is by
|
|
||||||
adding a network connection and using TFTP to download them. It's
|
|
||||||
quite common that the device's U-Boot doesn't speak DHCP so it will
|
|
||||||
need a static LAN address. You might also want to keep it away from
|
|
||||||
your "real" LAN: see :ref:`bng` for some potentially useful tooling
|
|
||||||
to use it on an isolated network.
|
|
||||||
|
|
||||||
|
|
||||||
TFTP
|
TFTP
|
||||||
====
|
====
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
{ eval, lib, pkgs }:
|
{ eval, lib, pkgs }:
|
||||||
let
|
let
|
||||||
inherit (lib) types;
|
|
||||||
conf = eval.config;
|
conf = eval.config;
|
||||||
rootDir = builtins.toPath ./..;
|
rootDir = builtins.toPath ./..;
|
||||||
stripAnyPrefixes = lib.flip (lib.fold lib.removePrefix)
|
stripAnyPrefixes = lib.flip (lib.fold lib.removePrefix) [ "${rootDir}/" ];
|
||||||
["${rootDir}/"];
|
optToDoc = name: opt: {
|
||||||
optToDoc = name: opt : {
|
|
||||||
inherit name;
|
inherit name;
|
||||||
description = opt.description or null;
|
description = opt.description or null;
|
||||||
default = opt.default or null;
|
default = opt.default or null;
|
||||||
|
@ -26,7 +24,6 @@ let
|
||||||
let x = lib.mapAttrsToList optToDoc sd.parameters; in x;
|
let x = lib.mapAttrsToList optToDoc sd.parameters; in x;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
item // { declarations = map stripAnyPrefixes item.declarations; };
|
item // { declarations = map stripAnyPrefixes item.declarations; };
|
||||||
in
|
in
|
||||||
builtins.map spliceServiceDefn
|
builtins.map spliceServiceDefn (pkgs.lib.optionAttrSetToDocList eval.options)
|
||||||
(pkgs.lib.optionAttrSetToDocList eval.options)
|
|
||||||
|
|
|
@ -1,24 +1,22 @@
|
||||||
with import <nixpkgs> {} ;
|
with import <nixpkgs> { };
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (builtins) stringLength readDir filter;
|
inherit (builtins) stringLength readDir filter;
|
||||||
devices = filter (n: n != "families")
|
devices = filter (n: n != "families") (lib.mapAttrsToList (n: t: n) (readDir ../devices));
|
||||||
(lib.mapAttrsToList (n: t: n) (readDir ../devices));
|
texts = map (
|
||||||
texts = map (n:
|
n:
|
||||||
let d = import ../devices/${n}/default.nix;
|
let
|
||||||
d' = {
|
d = import ../devices/${n}/default.nix;
|
||||||
description = "${n}\n${substring 0 (stringLength n) "********************************"}\n";
|
tag = ".. _${lib.strings.replaceStrings [" "] ["-"] n}:";
|
||||||
} // d;
|
d' = {
|
||||||
installer =
|
description = ''
|
||||||
if d ? description && d ? installer
|
${n}
|
||||||
then ''
|
${substring 0 (stringLength n) "********************************"}
|
||||||
|
'';
|
||||||
The default installation route for this device is
|
} // d;
|
||||||
:ref:`system-outputs-${d.installer}`
|
in
|
||||||
''
|
"${tag}\n\n${d'.description}"
|
||||||
else "";
|
) devices;
|
||||||
in d'.description)
|
|
||||||
devices;
|
|
||||||
in
|
in
|
||||||
writeText "hwdoc" ''
|
writeText "hwdoc" ''
|
||||||
Supported hardware
|
Supported hardware
|
||||||
|
|
|
@ -7,6 +7,7 @@ Liminix
|
||||||
|
|
||||||
intro
|
intro
|
||||||
tutorial
|
tutorial
|
||||||
|
installation
|
||||||
configuration
|
configuration
|
||||||
admin
|
admin
|
||||||
development
|
development
|
||||||
|
|
|
@ -0,0 +1,211 @@
|
||||||
|
Installation
|
||||||
|
############
|
||||||
|
|
||||||
|
Hardware devices vary wildly in their affordances for installing new
|
||||||
|
operating systems, so it should be no surprise that the Liminix
|
||||||
|
installation procedure is hardware-dependent. This section contains
|
||||||
|
generic instructions, but please refer to the documentation for your
|
||||||
|
device to find whether and how well they apply.
|
||||||
|
|
||||||
|
|
||||||
|
Building a firmware image
|
||||||
|
*************************
|
||||||
|
|
||||||
|
Liminix uses the Nix language to provide congruent configuration
|
||||||
|
management. This means that to change anything about the way in
|
||||||
|
which a Liminix system works, you make that change in
|
||||||
|
your :file:`configuration.nix` (or one of the other files it references),
|
||||||
|
and rerun :command:`nix-build` or :command:`liminix-rebuild` to action
|
||||||
|
the change. It is not possible (at least, without shenanigans) to make
|
||||||
|
changes by logging into the device and running imperative commands
|
||||||
|
whose effects may later be overridden: :file:`configuration.nix`
|
||||||
|
always describes the entire system and can be used to recreate that
|
||||||
|
system at any time. You can usefully keep it under version control.
|
||||||
|
|
||||||
|
If you are familiar with NixOS, you will notice some similarities
|
||||||
|
between NixOS and Liminix configuration, and also some
|
||||||
|
differences. Sometimes the differences are due to the
|
||||||
|
resource-constrained devices we deploy onto, sometimes due to
|
||||||
|
differences in the uses these devices are put to.
|
||||||
|
|
||||||
|
For a more full description of how to configure Liminix, see
|
||||||
|
:ref:`configuration`. Assuming for the moment that you want a typical
|
||||||
|
home wireless gateway/router, the best way to get started is to copy
|
||||||
|
:file:`examples/rotuer.nix` and edit it for your requirements.
|
||||||
|
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
$ cp examples/rotuer.nix configuration.nix
|
||||||
|
$ vi configuration.nix # other editors are available
|
||||||
|
$ # adjust this next command for your hardware device
|
||||||
|
$ nix-build -I liminix-config=./configuration.nix \
|
||||||
|
--arg device "import ./devices/gl-mt300a" -A outputs.default
|
||||||
|
|
||||||
|
Usually (not always, *please check the documentation for your device*)
|
||||||
|
this will leave you with a file :file:`result/firmware.bin`
|
||||||
|
which you now need to flash to the device.
|
||||||
|
|
||||||
|
|
||||||
|
Flashing from the boot monitor (TFTP install)
|
||||||
|
*********************************************
|
||||||
|
|
||||||
|
If you are prepared to open the device and have a TTL serial adaptor
|
||||||
|
of some kind to connect it to, you can probably use U-Boot and a TFTP
|
||||||
|
server to download and flash the image.
|
||||||
|
|
||||||
|
This is quite hardware-specific and may even involve soldering - see
|
||||||
|
the documention for your device. However, it is in some ways the most
|
||||||
|
"reliable" option: if you can see what's happening (or not happening)
|
||||||
|
in early boot, the risk of "bricking" is substantially reduced and you
|
||||||
|
have options for recovering if you misstep or flash a bad image.
|
||||||
|
|
||||||
|
|
||||||
|
.. _serial:
|
||||||
|
|
||||||
|
U-Boot and serial shenanigans
|
||||||
|
=============================
|
||||||
|
|
||||||
|
Every device that we have so far encountered in Liminix uses `U-Boot,
|
||||||
|
the "Universal Boot Loader" <https://docs.u-boot.org/en/latest/>`_ so
|
||||||
|
it's worth knowing a bit about it. "Universal" is in this context a
|
||||||
|
bit of a misnomer, though: encountering *mainline* U-Boot is very rare
|
||||||
|
and often you'll find it is a fork from some version last updated
|
||||||
|
in 2008. Upgrading U-Boot is more or less complicated depending on the
|
||||||
|
device and is outside scope for Liminix.
|
||||||
|
|
||||||
|
To speak to U-Boot on your device you'll usually need a serial
|
||||||
|
connection to it. This typically involves opening the box, locating
|
||||||
|
the serial header pins (TX, RX and GND) and connecting a USB TTL
|
||||||
|
converter to them.
|
||||||
|
|
||||||
|
The Rolls Royce of USB/UART cables is the `FTDI cable
|
||||||
|
<https://cpc.farnell.com/ftdi/ttl-232r-rpi/cable-debug-ttl-232-usb-rpi/dp/SC12825?st=usb%20to%20uart%20cable>`_,
|
||||||
|
but there are cheaper alternatives based on the PL2303 and CP2102 chipsets - or you could even
|
||||||
|
get creative and use the `UART GPIO pins <https://pinout.xyz/>`_ on a Raspberry Pi. Whatever you do, make sure
|
||||||
|
that the voltages are compatible: if your device is 3.3V (this is
|
||||||
|
typical but not universal), you don't want to be sending it 5v or
|
||||||
|
(even worse) 12v.
|
||||||
|
|
||||||
|
Run a terminal emulator such as Minicom on the computer at other end
|
||||||
|
of the link. 115200 8N1 is the typical speed.
|
||||||
|
|
||||||
|
.. NOTE::
|
||||||
|
|
||||||
|
TTL serial connections often have no flow control and
|
||||||
|
so don't always like having massive chunks of text pasted into
|
||||||
|
them - and U-Boot may drop characters while it's busy. So don't
|
||||||
|
do that.
|
||||||
|
|
||||||
|
If using Minicom, you may find it helps to bring up the "Termimal
|
||||||
|
settings" dialog (C^A T), then configure "Newline tx delay" to
|
||||||
|
some small but non-zero value.
|
||||||
|
|
||||||
|
When you turn the router on you should be greeted with some messages
|
||||||
|
from U-Boot, followed by the instruction to hit some key to stop
|
||||||
|
autoboot. Do this and you will get to the prompt. If you didn't see
|
||||||
|
anything, the strong likelihood is that TX and RX are the wrong way
|
||||||
|
around. If you see garbage, try a different speed.
|
||||||
|
|
||||||
|
Interesting commands to try first in U-Boot are :command:`help` and
|
||||||
|
:command:`printenv`.
|
||||||
|
|
||||||
|
You will also need to configure a TFTP server on a network that's
|
||||||
|
accessible to the device: how you do that will vary according to which
|
||||||
|
TFTP server you're using and so is out of scope for this document.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Buildiing and installing the image
|
||||||
|
==================================
|
||||||
|
|
||||||
|
Follow the device-specific instructions for "TFTP install": usually,
|
||||||
|
the steps are
|
||||||
|
|
||||||
|
* build the `outputs.mtdimage` output
|
||||||
|
* copy :file:`result/firmware.bin` to your TFTP server
|
||||||
|
* copy/paste the commands in :file:`result/flash.scr` one at a time into the U-Boot command line
|
||||||
|
* reset the device
|
||||||
|
|
||||||
|
You should now see messages from U-Boot, then from the Linux kernel
|
||||||
|
and eventually a shell prompt.
|
||||||
|
|
||||||
|
.. NOTE:: Before you reboot, check which networks the device is
|
||||||
|
plugged into, and disconnect as necessary. If you've just
|
||||||
|
installed a DHCP server or anything similar that responds to
|
||||||
|
broadcasts, you may not want it to do that on the network
|
||||||
|
that you temporarily connected it to for installing it.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Flashing from OpenWrt
|
||||||
|
*********************
|
||||||
|
|
||||||
|
.. CAUTION:: Untested! A previous version of these instructions
|
||||||
|
(without the -e flag) led to bricking the device
|
||||||
|
when flashing a jffs2 image. If you are reading
|
||||||
|
this message, nobody has yet reported on whether the
|
||||||
|
new instructions are any better.
|
||||||
|
|
||||||
|
If your device is running OpenWrt then it probably has the
|
||||||
|
:command:`mtd` command installed. Build the `outputs.mtdimage` output
|
||||||
|
(as you would for a TFTP install) and then transfer
|
||||||
|
:file:`result/firmware.bin` onto the device using e.g.
|
||||||
|
:command:`scp`. Now flash as follows:
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
mtd -e -r write /tmp/firmware.bin firmware
|
||||||
|
|
||||||
|
The options to this command are for "erase before writing" and "reboot
|
||||||
|
after writing".
|
||||||
|
|
||||||
|
For more information, please see the `OpenWrt manual <https://openwrt.org/docs/guide-user/installation/sysupgrade.cli>`_ which may also contain (hardware-dependent) instructions on how to flash an image using the vendor firmware - perhaps even from a web interface.
|
||||||
|
|
||||||
|
|
||||||
|
Flashing from Liminix
|
||||||
|
*********************
|
||||||
|
|
||||||
|
If the device is already running Liminix and has been configured with
|
||||||
|
:command:`levitate`, you can use that to safely flash your new image.
|
||||||
|
Refer to :ref:`levitate` for an explanation.
|
||||||
|
|
||||||
|
If the device is running Liminix but doesn't have :command:`levitate`
|
||||||
|
your options are more limited. You may attempt to use
|
||||||
|
:command:`flashcp` but it doesn't always work: as it copies the new
|
||||||
|
image over the top of the active root filesystem, surprise may ensue.
|
||||||
|
Consider instead using a serial connection: you may need one anyway
|
||||||
|
after trying flashcp if it corrupts the image.
|
||||||
|
|
||||||
|
flashcp (not generally recommended)
|
||||||
|
===================================
|
||||||
|
|
||||||
|
Connect to the device and locate the "firmware" partition, which you
|
||||||
|
can do with a combination of :command:`dmesg` output and the contents
|
||||||
|
of :file:`/proc/mtd`
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
<5>[ 0.469841] Creating 4 MTD partitions on "spi0.0":
|
||||||
|
<5>[ 0.474837] 0x000000000000-0x000000040000 : "u-boot"
|
||||||
|
<5>[ 0.480796] 0x000000040000-0x000000050000 : "u-boot-env"
|
||||||
|
<5>[ 0.487056] 0x000000050000-0x000000060000 : "art"
|
||||||
|
<5>[ 0.492753] 0x000000060000-0x000001000000 : "firmware"
|
||||||
|
|
||||||
|
# cat /proc/mtd
|
||||||
|
dev: size erasesize name
|
||||||
|
mtd0: 00040000 00001000 "u-boot"
|
||||||
|
mtd1: 00010000 00001000 "u-boot-env"
|
||||||
|
mtd2: 00010000 00001000 "art"
|
||||||
|
mtd3: 00fa0000 00001000 "firmware"
|
||||||
|
mtd4: 002a0000 00001000 "kernel"
|
||||||
|
mtd5: 00d00000 00001000 "rootfs"
|
||||||
|
|
||||||
|
Copy :file:`result/firmware.bin` to the device and now run (in this
|
||||||
|
example)
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
flashcp -v firmware.bin /dev/mtd3
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Module options
|
Module options
|
||||||
##############
|
##############
|
||||||
|
|
||||||
.. include:: modules-generated.rst
|
.. include:: modules-generated.inc.rst
|
||||||
|
|
|
@ -10,4 +10,4 @@ different artefacts, or have different ways to get that artefact
|
||||||
installed. The options available for a particular device are described in
|
installed. The options available for a particular device are described in
|
||||||
the section for that device.
|
the section for that device.
|
||||||
|
|
||||||
.. include:: outputs-generated.rst
|
.. include:: outputs-generated.inc.rst
|
||||||
|
|
|
@ -16,4 +16,4 @@
|
||||||
(each [_ option (ipairs (sorted-options (yaml.load (io.read "*a"))))]
|
(each [_ option (ipairs (sorted-options (yaml.load (io.read "*a"))))]
|
||||||
(when (and (output? option) (not option.internal))
|
(when (and (output? option) (not option.internal))
|
||||||
(print (.. ".. _" (string.gsub option.name "%." "-") ":") "\n")
|
(print (.. ".. _" (string.gsub option.name "%." "-") ":") "\n")
|
||||||
(print option.description)))
|
(print option.description "\n")))
|
||||||
|
|
|
@ -300,7 +300,7 @@ machine, which for a test/demo system might involve a second network
|
||||||
device in your build system - USB ethernet adapters are cheap - or
|
device in your build system - USB ethernet adapters are cheap - or
|
||||||
a bit of messing around unplugging cables.)
|
a bit of messing around unplugging cables.)
|
||||||
|
|
||||||
For more information about :code:`liminix-rebuild`, see the manual section :ref:`admin:Rebuilding the system`.
|
For more information about :code:`liminix-rebuild`, see the manual section :ref:`Rebuilding the system`.
|
||||||
|
|
||||||
|
|
||||||
Final thoughts
|
Final thoughts
|
||||||
|
|
|
@ -11,15 +11,15 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
secrets = import ./extneder-secrets.nix;
|
secrets = import ./extneder-secrets.nix;
|
||||||
inherit (pkgs.liminix.services) oneshot longrun bundle target;
|
inherit (pkgs.liminix.services) oneshot longrun target;
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs) writeText dropbear ifwait serviceFns;
|
inherit (pkgs) writeText serviceFns;
|
||||||
svc = config.system.service;
|
svc = config.system.service;
|
||||||
in rec {
|
in rec {
|
||||||
boot = {
|
boot = {
|
||||||
tftp = {
|
tftp = {
|
||||||
serverip = "192.168.8.148";
|
serverip = "10.0.0.1";
|
||||||
ipaddr = "192.168.8.251";
|
ipaddr = "10.0.0.8";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,34 +28,12 @@ in rec {
|
||||||
../modules/network
|
../modules/network
|
||||||
../modules/vlan
|
../modules/vlan
|
||||||
../modules/ssh
|
../modules/ssh
|
||||||
|
../modules/usb.nix
|
||||||
../modules/watchdog
|
../modules/watchdog
|
||||||
../modules/mount
|
../modules/mount
|
||||||
];
|
];
|
||||||
hostname = "arhcive";
|
hostname = "arhcive";
|
||||||
|
|
||||||
kernel = {
|
|
||||||
config = {
|
|
||||||
USB = "y";
|
|
||||||
USB_EHCI_HCD = "y";
|
|
||||||
USB_EHCI_HCD_PLATFORM = "y";
|
|
||||||
USB_OHCI_HCD = "y";
|
|
||||||
USB_OHCI_HCD_PLATFORM = "y";
|
|
||||||
USB_SUPPORT = "y";
|
|
||||||
USB_COMMON = "y";
|
|
||||||
USB_STORAGE = "y";
|
|
||||||
USB_STORAGE_DEBUG = "n";
|
|
||||||
USB_UAS = "y";
|
|
||||||
USB_ANNOUNCE_NEW_DEVICES = "y";
|
|
||||||
SCSI = "y";
|
|
||||||
BLK_DEV_SD = "y";
|
|
||||||
USB_PRINTER = "y";
|
|
||||||
MSDOS_PARTITION = "y";
|
|
||||||
EFI_PARTITION = "y";
|
|
||||||
EXT4_FS = "y";
|
|
||||||
EXT4_USE_FOR_EXT2 = "y";
|
|
||||||
FS_ENCRYPTION = "y";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.dhcpc =
|
services.dhcpc =
|
||||||
let iface = config.hardware.networkInterfaces.lan;
|
let iface = config.hardware.networkInterfaces.lan;
|
||||||
|
@ -74,7 +52,6 @@ in rec {
|
||||||
dependencies = [ services.dhcpc ];
|
dependencies = [ services.dhcpc ];
|
||||||
name = "resolvconf";
|
name = "resolvconf";
|
||||||
up = ''
|
up = ''
|
||||||
. ${serviceFns}
|
|
||||||
( in_outputs ${name}
|
( in_outputs ${name}
|
||||||
for i in $(output ${services.dhcpc} dns); do
|
for i in $(output ${services.dhcpc} dns); do
|
||||||
echo "nameserver $i" > resolv.conf
|
echo "nameserver $i" > resolv.conf
|
||||||
|
@ -105,7 +82,7 @@ in rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
services.mount_external_disk = svc.mount.build {
|
services.mount_external_disk = svc.mount.build {
|
||||||
device = "LABEL=backup-disk";
|
partlabel = "backup-disk";
|
||||||
mountpoint = "/srv";
|
mountpoint = "/srv";
|
||||||
fstype = "ext4";
|
fstype = "ext4";
|
||||||
};
|
};
|
||||||
|
@ -115,7 +92,6 @@ in rec {
|
||||||
secrets_file = oneshot rec {
|
secrets_file = oneshot rec {
|
||||||
name = "rsync-secrets";
|
name = "rsync-secrets";
|
||||||
up = ''
|
up = ''
|
||||||
. ${serviceFns}
|
|
||||||
(in_outputs ${name}
|
(in_outputs ${name}
|
||||||
echo "backup:${secrets.rsync_secret}" > secrets)
|
echo "backup:${secrets.rsync_secret}" > secrets)
|
||||||
'';
|
'';
|
||||||
|
@ -141,23 +117,37 @@ in rec {
|
||||||
secrets_file
|
secrets_file
|
||||||
services.mount_external_disk
|
services.mount_external_disk
|
||||||
config.hardware.networkInterfaces.lan
|
config.hardware.networkInterfaces.lan
|
||||||
] ;
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
users.root = {
|
users.root = {
|
||||||
passwd = lib.mkForce secrets.root.passwd;
|
passwd = lib.mkForce secrets.root.passwd;
|
||||||
# openssh.authorizedKeys.keys = [
|
openssh.authorizedKeys.keys = secrets.root.keys;
|
||||||
# (builtins.readFile "/home/dan/.ssh/id_rsa.pub")
|
|
||||||
# ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
users.backup = {
|
users.backup = {
|
||||||
uid=500; gid=500; gecos="Storage owner"; dir="/srv";
|
uid = 500;
|
||||||
shell="/dev/null";
|
gid = 500;
|
||||||
|
gecos = "Storage owner";
|
||||||
|
dir = "/srv";
|
||||||
|
shell = "/dev/null";
|
||||||
};
|
};
|
||||||
groups.backup = {
|
groups.backup = {
|
||||||
gid=500; usernames = ["backup"];
|
gid = 500;
|
||||||
|
usernames = [ "backup" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultProfile.packages = with pkgs; [e2fsprogs strace tcpdump ];
|
defaultProfile.packages = with pkgs; [
|
||||||
|
e2fsprogs
|
||||||
|
mtdutils
|
||||||
|
(levitate.override {
|
||||||
|
config = {
|
||||||
|
services = {
|
||||||
|
inherit (config.services) dhcpc sshd watchdog;
|
||||||
|
};
|
||||||
|
defaultProfile.packages = [ mtdutils ];
|
||||||
|
users.root.openssh.authorizedKeys.keys = secrets.root.keys;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
# wherever the text "EDIT" appears - please consult the tutorial
|
# wherever the text "EDIT" appears - please consult the tutorial
|
||||||
# documentation for details.
|
# documentation for details.
|
||||||
|
|
||||||
{ config, pkgs, lib, ... } :
|
{ config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (pkgs.liminix.services) bundle oneshot longrun;
|
inherit (pkgs.liminix.services) bundle oneshot;
|
||||||
inherit (pkgs) serviceFns;
|
inherit (pkgs) serviceFns;
|
||||||
# EDIT: you can pick your preferred RFC1918 address space
|
# EDIT: you can pick your preferred RFC1918 address space
|
||||||
# for NATted connections, if you don't like this one.
|
# for NATted connections, if you don't like this one.
|
||||||
|
@ -49,31 +49,40 @@ in rec {
|
||||||
country_code = "GB";
|
country_code = "GB";
|
||||||
wpa_passphrase = "not a real wifi password";
|
wpa_passphrase = "not a real wifi password";
|
||||||
|
|
||||||
hw_mode="g";
|
hw_mode = "g";
|
||||||
ieee80211n = 1;
|
ieee80211n = 1;
|
||||||
auth_algs = 1; # 1=wpa2, 2=wep, 3=both
|
auth_algs = 1; # 1=wpa2, 2=wep, 3=both
|
||||||
wpa = 2; # 1=wpa, 2=wpa2, 3=both
|
wpa = 2; # 1=wpa, 2=wpa2, 3=both
|
||||||
wpa_key_mgmt = "WPA-PSK";
|
wpa_key_mgmt = "WPA-PSK";
|
||||||
wpa_pairwise = "TKIP CCMP"; # auth for wpa (may not need this?)
|
wpa_pairwise = "TKIP CCMP"; # auth for wpa (may not need this?)
|
||||||
rsn_pairwise = "CCMP"; # auth for wpa2
|
rsn_pairwise = "CCMP"; # auth for wpa2
|
||||||
wmm_enabled = 1;
|
wmm_enabled = 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.int = svc.network.address.build {
|
services.int = svc.network.address.build {
|
||||||
interface = svc.bridge.primary.build { ifname = "int"; };
|
interface = svc.bridge.primary.build { ifname = "int"; };
|
||||||
family = "inet"; address = "${ipv4LocalNet}.1"; prefixLength = 16;
|
family = "inet";
|
||||||
|
address = "${ipv4LocalNet}.1";
|
||||||
|
prefixLength = 16;
|
||||||
};
|
};
|
||||||
|
|
||||||
services.bridge = svc.bridge.members.build {
|
services.bridge = svc.bridge.members.build {
|
||||||
primary = services.int;
|
primary = services.int;
|
||||||
members = with config.hardware.networkInterfaces;
|
members = with config.hardware.networkInterfaces; [
|
||||||
[ wlan lan ];
|
wlan
|
||||||
|
lan
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.ntp = svc.ntp.build {
|
services.ntp = svc.ntp.build {
|
||||||
pools = { "pool.ntp.org" = ["iburst"]; };
|
pools = {
|
||||||
makestep = { threshold = 1.0; limit = 3; };
|
"pool.ntp.org" = [ "iburst" ];
|
||||||
|
};
|
||||||
|
makestep = {
|
||||||
|
threshold = 1.0;
|
||||||
|
limit = 3;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.sshd = svc.ssh.build { };
|
services.sshd = svc.ssh.build { };
|
||||||
|
@ -128,7 +137,6 @@ in rec {
|
||||||
dependencies = [ services.wan ];
|
dependencies = [ services.wan ];
|
||||||
name = "resolvconf";
|
name = "resolvconf";
|
||||||
up = ''
|
up = ''
|
||||||
. ${serviceFns}
|
|
||||||
( in_outputs ${name}
|
( in_outputs ${name}
|
||||||
echo "nameserver $(output ${services.wan} ns1)" > resolv.conf
|
echo "nameserver $(output ${services.wan} ns1)" > resolv.conf
|
||||||
echo "nameserver $(output ${services.wan} ns2)" >> resolv.conf
|
echo "nameserver $(output ${services.wan} ns2)" >> resolv.conf
|
||||||
|
@ -157,9 +165,7 @@ in rec {
|
||||||
interface = services.wan;
|
interface = services.wan;
|
||||||
};
|
};
|
||||||
|
|
||||||
services.firewall = svc.firewall.build {
|
services.firewall = svc.firewall.build { };
|
||||||
ruleset = import ./demo-firewall.nix;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.packet_forwarding = svc.network.forward.build { };
|
services.packet_forwarding = svc.network.forward.build { };
|
||||||
|
|
||||||
|
@ -196,7 +202,5 @@ in rec {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultProfile.packages = with pkgs; [
|
defaultProfile.packages = with pkgs; [ min-collect-garbage ];
|
||||||
min-collect-garbage
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
|
modulesPath,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
secrets = import ./extneder-secrets.nix;
|
secrets = import ./extneder-secrets.nix;
|
||||||
|
svc = config.system.service;
|
||||||
in rec {
|
in rec {
|
||||||
boot = {
|
boot = {
|
||||||
tftp = {
|
tftp = {
|
||||||
|
@ -20,47 +22,13 @@ in rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
../modules/profiles/wap.nix
|
"${modulesPath}/profiles/wap.nix"
|
||||||
../modules/vlan
|
"${modulesPath}/vlan"
|
||||||
|
"${modulesPath}/ssh"
|
||||||
];
|
];
|
||||||
|
|
||||||
hostname = "extneder";
|
hostname = "extneder";
|
||||||
|
|
||||||
kernel = {
|
|
||||||
config = {
|
|
||||||
|
|
||||||
NETFILTER_XT_MATCH_CONNTRACK = "y";
|
|
||||||
|
|
||||||
IP6_NF_IPTABLES = "y"; # do we still need these
|
|
||||||
IP_NF_IPTABLES = "y"; # if using nftables directly
|
|
||||||
|
|
||||||
# these are copied from rotuer and need review.
|
|
||||||
# we're not running a firewall, so why do we need
|
|
||||||
# nftables config?
|
|
||||||
IP_NF_NAT = "y";
|
|
||||||
IP_NF_TARGET_MASQUERADE = "y";
|
|
||||||
NETFILTER = "y";
|
|
||||||
NETFILTER_ADVANCED = "y";
|
|
||||||
NETFILTER_XTABLES = "y";
|
|
||||||
|
|
||||||
NFT_COMPAT = "y";
|
|
||||||
NFT_CT = "y";
|
|
||||||
NFT_LOG = "y";
|
|
||||||
NFT_MASQ = "y";
|
|
||||||
NFT_NAT = "y";
|
|
||||||
NFT_REJECT = "y";
|
|
||||||
NFT_REJECT_INET = "y";
|
|
||||||
|
|
||||||
NF_CONNTRACK = "y";
|
|
||||||
NF_NAT = "y";
|
|
||||||
NF_NAT_MASQUERADE = "y";
|
|
||||||
NF_TABLES = "y";
|
|
||||||
NF_TABLES_INET = "y";
|
|
||||||
NF_TABLES_IPV4 = "y";
|
|
||||||
NF_TABLES_IPV6 = "y";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
profile.wap = {
|
profile.wap = {
|
||||||
interfaces = with config.hardware.networkInterfaces; [
|
interfaces = with config.hardware.networkInterfaces; [
|
||||||
lan
|
lan
|
||||||
|
@ -79,6 +47,7 @@ in rec {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.sshd = svc.ssh.build {};
|
||||||
users.root.passwd = lib.mkForce secrets.root.passwd;
|
users.root.passwd = lib.mkForce secrets.root.passwd;
|
||||||
defaultProfile.packages = with pkgs; [nftables strace tcpdump swconfig];
|
defaultProfile.packages = with pkgs; [nftables strace tcpdump swconfig];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{ config, pkgs, lib, ... } :
|
{ config, pkgs, ... } :
|
||||||
let
|
let
|
||||||
inherit (pkgs) serviceFns;
|
|
||||||
svc = config.system.service;
|
svc = config.system.service;
|
||||||
|
|
||||||
in rec {
|
in rec {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{ config, pkgs, lib, ... } :
|
{ config, pkgs, ... } :
|
||||||
let
|
let
|
||||||
inherit (pkgs) serviceFns;
|
|
||||||
svc = config.system.service;
|
svc = config.system.service;
|
||||||
|
|
||||||
in rec {
|
in rec {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{ config, pkgs, ... } :
|
{ config, pkgs, ... } :
|
||||||
let
|
let
|
||||||
inherit (pkgs.liminix.services) oneshot longrun bundle target;
|
inherit (pkgs.liminix.services) target;
|
||||||
inherit (pkgs) writeText;
|
|
||||||
svc = config.system.service;
|
svc = config.system.service;
|
||||||
secrets-1 = {
|
secrets-1 = {
|
||||||
ssid = "Zyxel 2G (N)";
|
ssid = "Zyxel 2G (N)";
|
||||||
|
|
|
@ -3,8 +3,8 @@ let
|
||||||
inherit (pkgs) serviceFns;
|
inherit (pkgs) serviceFns;
|
||||||
svc = config.system.service;
|
svc = config.system.service;
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs.liminix.services) oneshot longrun bundle target;
|
inherit (pkgs.liminix.services) oneshot target;
|
||||||
some-util-linux = pkgs.runCommand "some-util-linux" {} ''
|
some-util-linux = pkgs.runCommand "some-util-linux" { } ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cd ${pkgs.util-linux-small}/bin
|
cd ${pkgs.util-linux-small}/bin
|
||||||
cp fdisk sfdisk mkswap $out/bin
|
cp fdisk sfdisk mkswap $out/bin
|
||||||
|
@ -53,14 +53,13 @@ in rec {
|
||||||
services.defaultroute4 = svc.network.route.build {
|
services.defaultroute4 = svc.network.route.build {
|
||||||
via = "$(output ${services.dhcpc} router)";
|
via = "$(output ${services.dhcpc} router)";
|
||||||
target = "default";
|
target = "default";
|
||||||
dependencies = [services.dhcpc];
|
dependencies = [ services.dhcpc ];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.resolvconf = oneshot rec {
|
services.resolvconf = oneshot rec {
|
||||||
dependencies = [ services.dhcpc ];
|
dependencies = [ services.dhcpc ];
|
||||||
name = "resolvconf";
|
name = "resolvconf";
|
||||||
up = ''
|
up = ''
|
||||||
. ${serviceFns}
|
|
||||||
( in_outputs ${name}
|
( in_outputs ${name}
|
||||||
for i in $(output ${services.dhcpc} dns); do
|
for i in $(output ${services.dhcpc} dns); do
|
||||||
echo "nameserver $i" > resolv.conf
|
echo "nameserver $i" > resolv.conf
|
||||||
|
@ -72,7 +71,6 @@ in rec {
|
||||||
services.growfs = let name = "growfs"; in oneshot {
|
services.growfs = let name = "growfs"; in oneshot {
|
||||||
inherit name;
|
inherit name;
|
||||||
up = ''
|
up = ''
|
||||||
. ${serviceFns}
|
|
||||||
device=$(grep /persist /proc/1/mountinfo | cut -f9 -d' ')
|
device=$(grep /persist /proc/1/mountinfo | cut -f9 -d' ')
|
||||||
${pkgs.e2fsprogs}/bin/resize2fs $device
|
${pkgs.e2fsprogs}/bin/resize2fs $device
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -8,12 +8,10 @@
|
||||||
root = {
|
root = {
|
||||||
# mkpasswd -m sha512crypt
|
# mkpasswd -m sha512crypt
|
||||||
passwd = "$6$6pt0mpbgcB7kC2RJ$kSBoCYGyi1.qxt7dqmexLj1l8E6oTZJZmfGyJSsMYMW.jlsETxdgQSdv6ptOYDM7DHAwf6vLG0pz3UD31XBfC1";
|
passwd = "$6$6pt0mpbgcB7kC2RJ$kSBoCYGyi1.qxt7dqmexLj1l8E6oTZJZmfGyJSsMYMW.jlsETxdgQSdv6ptOYDM7DHAwf6vLG0pz3UD31XBfC1";
|
||||||
openssh.authorizedKeys.keys = [
|
openssh.authorizedKeys.keys = [ ];
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
lan = {
|
lan = {
|
||||||
prefix = "10.8.0";
|
prefix = "10.8.0";
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,19 @@
|
||||||
# This is not part of Liminix per se. This is my "scratchpad"
|
# This is an example that uses the "gateway" profile to create a
|
||||||
# configuration for the device I'm testing with.
|
# "typical home wireless router" configuration suitable for a Gl.inet
|
||||||
#
|
# gl-ar750 router. It should be fairly simple to edit it for other
|
||||||
# Parts of it do do things that Liminix eventually needs to do, but
|
# devices: mostly you will need to attend to the number of wlan and lan
|
||||||
# don't look in here for solutions - just for identifying the
|
# interfaces
|
||||||
# problems.
|
|
||||||
|
|
||||||
|
{ config, pkgs, lib, modulesPath, ... } :
|
||||||
{ config, pkgs, lib, ... } :
|
|
||||||
let
|
let
|
||||||
secrets = {
|
secrets = {
|
||||||
domainName = "fake.liminix.org";
|
domainName = "fake.liminix.org";
|
||||||
firewallRules = {};
|
firewallRules = { };
|
||||||
} // (import ./rotuer-secrets.nix);
|
} // (import ./rotuer-secrets.nix);
|
||||||
inherit (pkgs.liminix.services) oneshot longrun bundle;
|
|
||||||
inherit (pkgs) serviceFns;
|
|
||||||
svc = config.system.service;
|
svc = config.system.service;
|
||||||
wirelessConfig = {
|
wirelessConfig = {
|
||||||
country_code = "GB";
|
country_code = "GB";
|
||||||
inherit (secrets) wpa_passphrase;
|
inherit (secrets) wpa_passphrase;
|
||||||
auth_algs = 1; # 1=wpa2, 2=wep, 3=both
|
|
||||||
wpa = 2; # 1=wpa, 2=wpa2, 3=both
|
|
||||||
wpa_key_mgmt = "WPA-PSK";
|
|
||||||
wpa_pairwise = "TKIP CCMP"; # auth for wpa (may not need this?)
|
|
||||||
rsn_pairwise = "CCMP"; # auth for wpa2
|
|
||||||
wmm_enabled = 1;
|
wmm_enabled = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,65 +27,71 @@ in rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
../modules/wlan.nix
|
"${modulesPath}/profiles/gateway.nix"
|
||||||
../modules/network
|
|
||||||
../modules/ppp
|
|
||||||
../modules/dnsmasq
|
|
||||||
../modules/dhcp6c
|
|
||||||
../modules/firewall
|
|
||||||
../modules/hostapd
|
|
||||||
../modules/bridge
|
|
||||||
../modules/ntp
|
|
||||||
../modules/schnapps
|
|
||||||
../modules/ssh
|
|
||||||
../modules/outputs/btrfs.nix
|
|
||||||
../modules/outputs/extlinux.nix
|
|
||||||
];
|
];
|
||||||
hostname = "rotuer";
|
hostname = "rotuer";
|
||||||
rootfsType = "btrfs";
|
|
||||||
rootOptions = "subvol=@";
|
|
||||||
boot.loader.extlinux.enable = true;
|
|
||||||
|
|
||||||
services.hostap = svc.hostapd.build {
|
profile.gateway = {
|
||||||
interface = config.hardware.networkInterfaces.wlan;
|
lan = {
|
||||||
params = {
|
interfaces = with config.hardware.networkInterfaces;
|
||||||
ssid = secrets.ssid;
|
[
|
||||||
hw_mode="g";
|
# EDIT: these are the interfaces exposed by the gl.inet gl-ar750:
|
||||||
channel = "2";
|
# if your device has more or differently named lan interfaces,
|
||||||
ieee80211n = 1;
|
# specify them here
|
||||||
} // wirelessConfig;
|
wlan wlan5
|
||||||
};
|
lan
|
||||||
|
];
|
||||||
|
inherit (secrets.lan) prefix;
|
||||||
|
address = {
|
||||||
|
family = "inet"; address ="${secrets.lan.prefix}.1"; prefixLength = 24;
|
||||||
|
};
|
||||||
|
dhcp = {
|
||||||
|
start = 10;
|
||||||
|
end = 240;
|
||||||
|
hosts = { } // lib.optionalAttrs (builtins.pathExists ./static-leases.nix) (import ./static-leases.nix);
|
||||||
|
localDomain = "lan";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
wan = {
|
||||||
|
# wan interface depends on your upstream - could be dhcp, static
|
||||||
|
# ethernet, a pppoe, ppp over serial, a complicated bonded
|
||||||
|
# failover ... who knows what else?
|
||||||
|
interface = svc.pppoe.build {
|
||||||
|
interface = config.hardware.networkInterfaces.wan;
|
||||||
|
username = secrets.l2tp.name;
|
||||||
|
password = secrets.l2tp.password;
|
||||||
|
};
|
||||||
|
# once the wan has ipv4 connnectivity, should we run dhcp6
|
||||||
|
# client to potentially get an address range ("prefix
|
||||||
|
# delegation")
|
||||||
|
dhcp6.enable = true;
|
||||||
|
};
|
||||||
|
firewall = {
|
||||||
|
enable = true;
|
||||||
|
rules = secrets.firewallRules;
|
||||||
|
};
|
||||||
|
wireless.networks = {
|
||||||
|
# EDIT: if you have more or fewer wireless radios, here is where
|
||||||
|
# you need to say so. hostapd tuning is hardware-specific and
|
||||||
|
# left as an exercise for the reader :-).
|
||||||
|
|
||||||
services.hostap5 = svc.hostapd.build {
|
"${secrets.ssid}" = {
|
||||||
interface = config.hardware.networkInterfaces.wlan5;
|
interface = config.hardware.networkInterfaces.wlan;
|
||||||
params = rec {
|
hw_mode = "g";
|
||||||
ssid = "${secrets.ssid}5";
|
channel = "2";
|
||||||
hw_mode="a";
|
ieee80211n = 1;
|
||||||
channel = 36;
|
} // wirelessConfig;
|
||||||
ht_capab = "[HT40+]";
|
"${secrets.ssid}5" = rec {
|
||||||
vht_oper_chwidth = 1;
|
interface = config.hardware.networkInterfaces.wlan5;
|
||||||
vht_oper_centr_freq_seg0_idx = channel + 6;
|
hw_mode = "a";
|
||||||
ieee80211n = 1;
|
channel = 36;
|
||||||
ieee80211ac = 1;
|
ht_capab = "[HT40+]";
|
||||||
} // wirelessConfig;
|
vht_oper_chwidth = 1;
|
||||||
};
|
vht_oper_centr_freq_seg0_idx = channel + 6;
|
||||||
|
ieee80211n = 1;
|
||||||
services.int = svc.network.address.build {
|
ieee80211ac = 1;
|
||||||
interface = svc.bridge.primary.build { ifname = "int"; };
|
} // wirelessConfig;
|
||||||
family = "inet"; address ="${secrets.lan.prefix}.1"; prefixLength = 24;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
services.bridge = svc.bridge.members.build {
|
|
||||||
primary = services.int;
|
|
||||||
members = with config.hardware.networkInterfaces;
|
|
||||||
[ wlan
|
|
||||||
wlan5
|
|
||||||
lan0
|
|
||||||
lan1
|
|
||||||
lan2
|
|
||||||
lan3
|
|
||||||
lan4
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.ntp = svc.ntp.build {
|
services.ntp = svc.ntp.build {
|
||||||
|
@ -106,95 +103,6 @@ in rec {
|
||||||
|
|
||||||
users.root = secrets.root;
|
users.root = secrets.root;
|
||||||
|
|
||||||
services.dns =
|
|
||||||
let interface = services.int;
|
|
||||||
in svc.dnsmasq.build {
|
|
||||||
resolvconf = services.resolvconf;
|
|
||||||
inherit interface;
|
|
||||||
ranges = [
|
|
||||||
"${secrets.lan.prefix}.10,${secrets.lan.prefix}.240"
|
|
||||||
# ra-stateless: sends router advertisements with the O and A
|
|
||||||
# bits set, and provides a stateless DHCP service. The client
|
|
||||||
# will use a SLAAC address, and use DHCP for other
|
|
||||||
# configuration information.
|
|
||||||
"::,constructor:$(output ${interface} ifname),ra-stateless"
|
|
||||||
];
|
|
||||||
|
|
||||||
# You can add static addresses for the DHCP server here. I'm
|
|
||||||
# not putting my actual MAC addresses in a public git repo ...
|
|
||||||
hosts = { } // lib.optionalAttrs (builtins.pathExists ./static-leases.nix) (import ./static-leases.nix);
|
|
||||||
upstreams = [ "/${secrets.domainName}/" ];
|
|
||||||
domain = secrets.domainName;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.wan = svc.pppoe.build {
|
|
||||||
interface = config.hardware.networkInterfaces.wan;
|
|
||||||
ppp-options = [
|
|
||||||
"debug" "+ipv6" "noauth"
|
|
||||||
"name" secrets.l2tp.name
|
|
||||||
"password" secrets.l2tp.password
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.resolvconf = oneshot rec {
|
|
||||||
dependencies = [ services.wan ];
|
|
||||||
name = "resolvconf";
|
|
||||||
up = ''
|
|
||||||
. ${serviceFns}
|
|
||||||
( in_outputs ${name}
|
|
||||||
echo "nameserver $(output ${services.wan} ns1)" > resolv.conf
|
|
||||||
echo "nameserver $(output ${services.wan} ns2)" >> resolv.conf
|
|
||||||
chmod 0444 resolv.conf
|
|
||||||
)
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
filesystem =
|
|
||||||
let inherit (pkgs.pseudofile) dir symlink;
|
|
||||||
in dir {
|
|
||||||
etc = dir {
|
|
||||||
"resolv.conf" = symlink "${services.resolvconf}/.outputs/resolv.conf";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.defaultroute4 = svc.network.route.build {
|
|
||||||
via = "$(output ${services.wan} address)";
|
|
||||||
target = "default";
|
|
||||||
dependencies = [ services.wan ];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.defaultroute6 = svc.network.route.build {
|
|
||||||
via = "$(output ${services.wan} ipv6-peer-address)";
|
|
||||||
target = "default";
|
|
||||||
interface = services.wan;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.firewall = svc.firewall.build {
|
|
||||||
ruleset =
|
|
||||||
let defaults = import ./demo-firewall.nix;
|
|
||||||
in lib.recursiveUpdate defaults secrets.firewallRules;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.packet_forwarding = svc.network.forward.build { };
|
|
||||||
|
|
||||||
services.dhcp6c =
|
|
||||||
let client = svc.dhcp6c.client.build {
|
|
||||||
interface = services.wan;
|
|
||||||
};
|
|
||||||
in bundle {
|
|
||||||
name = "dhcp6c";
|
|
||||||
contents = [
|
|
||||||
(svc.dhcp6c.prefix.build {
|
|
||||||
inherit client;
|
|
||||||
interface = services.int;
|
|
||||||
})
|
|
||||||
(svc.dhcp6c.address.build {
|
|
||||||
inherit client;
|
|
||||||
interface = services.wan;
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultProfile.packages = with pkgs; [
|
defaultProfile.packages = with pkgs; [
|
||||||
min-collect-garbage
|
min-collect-garbage
|
||||||
nftables
|
nftables
|
||||||
|
|
|
@ -0,0 +1,211 @@
|
||||||
|
# A demonstration config for a home/soho router with PPPoE upstream
|
||||||
|
# and fallback to an L2TP tunnel over a USB WWAN device
|
||||||
|
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
secrets = import ./extneder-secrets.nix;
|
||||||
|
rsecrets = import ./rotuer-secrets.nix;
|
||||||
|
|
||||||
|
# https://support.aa.net.uk/Category:Incoming_L2TP says:
|
||||||
|
# "Please use the DNS name (l2tp.aa.net.uk) instead of hardcoding an
|
||||||
|
# IP address; IP addresses can and do change. If you have to use an
|
||||||
|
# IP, use 194.4.172.12, but do check the DNS for l2tp.aa.net.uk in
|
||||||
|
# case it changes."
|
||||||
|
|
||||||
|
# but (1) we don't want to use the wwan stick's dns as our main
|
||||||
|
# resolver: it's provided by some mobile ISP and they aren't
|
||||||
|
# necessarily the best at providing unfettered services without
|
||||||
|
# deciding to do something weird; (2) it's not simple to arrange
|
||||||
|
# that xl2tpd gets a different resolver than every other process;
|
||||||
|
# (3) there's no way to specify an lns address to xl2tpd at runtime
|
||||||
|
# except by rewriting its config file. So what we will do is lookup
|
||||||
|
# the lns hostname using the mobile ISP's dns server and then refuse
|
||||||
|
# to start l2tp unless the expected lns address is one of the
|
||||||
|
# addresses returned. I think this satisfies "do check the DNS"
|
||||||
|
|
||||||
|
lns = { hostname = "l2tp.aaisp.net.uk"; address = "194.4.172.12"; };
|
||||||
|
|
||||||
|
inherit (pkgs.liminix.services) oneshot longrun target;
|
||||||
|
inherit (pkgs.liminix) outputRef;
|
||||||
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
|
inherit (pkgs) serviceFns;
|
||||||
|
svc = config.system.service;
|
||||||
|
wirelessConfig = {
|
||||||
|
country_code = "GB";
|
||||||
|
inherit (rsecrets) wpa_passphrase;
|
||||||
|
wmm_enabled = 1;
|
||||||
|
};
|
||||||
|
in rec {
|
||||||
|
boot = {
|
||||||
|
tftp = {
|
||||||
|
serverip = "10.0.0.1";
|
||||||
|
ipaddr = "10.0.0.8";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
../modules/wwan
|
||||||
|
../modules/network
|
||||||
|
../modules/ssh
|
||||||
|
../modules/usb.nix
|
||||||
|
../modules/ppp
|
||||||
|
../modules/round-robin
|
||||||
|
../modules/health-check
|
||||||
|
../modules/secrets
|
||||||
|
../modules/profiles/gateway.nix
|
||||||
|
];
|
||||||
|
hostname = "thing";
|
||||||
|
|
||||||
|
services.wan-address-for-secrets = svc.network.address.build {
|
||||||
|
interface = config.hardware.networkInterfaces.wan;
|
||||||
|
family = "inet"; address ="10.0.0.10"; prefixLength = 24;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.secrets = svc.secrets.outboard.build {
|
||||||
|
name = "secret-service";
|
||||||
|
url = "http://10.0.0.1/liminix/examples/real-secrets.json";
|
||||||
|
username = "demo";
|
||||||
|
password = "demo";
|
||||||
|
interval = 5;
|
||||||
|
dependencies = [ services.wan-address-for-secrets ];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.wwan = svc.wwan.huawei-e3372.build {
|
||||||
|
apn = "data.uk";
|
||||||
|
username = "user";
|
||||||
|
password = "one2one";
|
||||||
|
authType = "chap";
|
||||||
|
};
|
||||||
|
|
||||||
|
profile.gateway = {
|
||||||
|
lan = {
|
||||||
|
interfaces = with config.hardware.networkInterfaces;
|
||||||
|
[
|
||||||
|
# EDIT: these are the interfaces exposed by the gl.inet gl-ar750:
|
||||||
|
# if your device has more or differently named lan interfaces,
|
||||||
|
# specify them here
|
||||||
|
wlan wlan5
|
||||||
|
lan
|
||||||
|
];
|
||||||
|
inherit (rsecrets.lan) prefix;
|
||||||
|
address = {
|
||||||
|
family = "inet"; address ="${rsecrets.lan.prefix}.1"; prefixLength = 24;
|
||||||
|
};
|
||||||
|
dhcp = {
|
||||||
|
start = 10;
|
||||||
|
end = 240;
|
||||||
|
hosts = { } // lib.optionalAttrs (builtins.pathExists ./static-leases.nix) (import ./static-leases.nix);
|
||||||
|
localDomain = "lan";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
wan =
|
||||||
|
let
|
||||||
|
secret = outputRef config.services.secrets;
|
||||||
|
username = secret "ppp/username";
|
||||||
|
password = secret "ppp/password";
|
||||||
|
in {
|
||||||
|
interface =
|
||||||
|
let
|
||||||
|
pppoe = svc.pppoe.build {
|
||||||
|
interface = config.hardware.networkInterfaces.wan;
|
||||||
|
debug = true;
|
||||||
|
inherit username password;
|
||||||
|
};
|
||||||
|
|
||||||
|
l2tp =
|
||||||
|
let
|
||||||
|
check-address = oneshot rec {
|
||||||
|
name = "check-lns-address";
|
||||||
|
up = "grep -Fx ${lns.address} $(output_path ${services.lns-address} addresses)";
|
||||||
|
dependencies = [ services.lns-address ];
|
||||||
|
};
|
||||||
|
route = svc.network.route.build {
|
||||||
|
via = "$(output ${services.bootstrap-dhcpc} router)";
|
||||||
|
target = lns.address;
|
||||||
|
dependencies = [services.bootstrap-dhcpc check-address];
|
||||||
|
};
|
||||||
|
l2tpd= svc.l2tp.build {
|
||||||
|
lns = lns.address;
|
||||||
|
inherit username password;
|
||||||
|
dependencies = [config.services.lns-address route check-address];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
svc.health-check.build {
|
||||||
|
service = l2tpd;
|
||||||
|
threshold = 3;
|
||||||
|
interval = 2;
|
||||||
|
healthCheck = pkgs.writeAshScript "ping-check" {} "ping 1.1.1.1";
|
||||||
|
};
|
||||||
|
in svc.round-robin.build {
|
||||||
|
name = "wan";
|
||||||
|
services = [
|
||||||
|
pppoe
|
||||||
|
l2tp
|
||||||
|
];
|
||||||
|
};
|
||||||
|
dhcp6.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
wireless.networks = {
|
||||||
|
"${rsecrets.ssid}" = {
|
||||||
|
interface = config.hardware.networkInterfaces.wlan;
|
||||||
|
hw_mode = "g";
|
||||||
|
channel = "6";
|
||||||
|
ieee80211n = 1;
|
||||||
|
} // wirelessConfig // {
|
||||||
|
wpa_passphrase = outputRef config.services.secrets "wpa_passphrase";
|
||||||
|
};
|
||||||
|
|
||||||
|
"${rsecrets.ssid}5" = rec {
|
||||||
|
interface = config.hardware.networkInterfaces.wlan5;
|
||||||
|
hw_mode = "a";
|
||||||
|
channel = 36;
|
||||||
|
ht_capab = "[HT40+]";
|
||||||
|
vht_oper_chwidth = 1;
|
||||||
|
vht_oper_centr_freq_seg0_idx = channel + 6;
|
||||||
|
ieee80211n = 1;
|
||||||
|
ieee80211ac = 1;
|
||||||
|
} // wirelessConfig // {
|
||||||
|
wpa_passphrase = outputRef config.services.secrets "wpa_passphrase";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.bootstrap-dhcpc = svc.network.dhcp.client.build {
|
||||||
|
interface = config.services.wwan;
|
||||||
|
dependencies = [ config.services.hostname ];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.sshd = svc.ssh.build {
|
||||||
|
authorizedKeys = outputRef config.services.secrets "ssh/authorizedKeys";
|
||||||
|
};
|
||||||
|
|
||||||
|
services.lns-address = let
|
||||||
|
ns = "$(output_word ${services.bootstrap-dhcpc} dns 1)";
|
||||||
|
route-to-bootstrap-nameserver = svc.network.route.build {
|
||||||
|
via = "$(output ${services.bootstrap-dhcpc} router)";
|
||||||
|
target = ns;
|
||||||
|
dependencies = [services.bootstrap-dhcpc];
|
||||||
|
};
|
||||||
|
in oneshot rec {
|
||||||
|
name = "resolve-l2tp-server";
|
||||||
|
dependencies = [ services.bootstrap-dhcpc route-to-bootstrap-nameserver ];
|
||||||
|
up = ''
|
||||||
|
(in_outputs ${name}
|
||||||
|
DNSCACHEIP="${ns}" ${pkgs.s6-dns}/bin/s6-dnsip4 ${lns.hostname} \
|
||||||
|
> addresses
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
users.root = rsecrets.root;
|
||||||
|
|
||||||
|
programs.busybox.options = {
|
||||||
|
FEATURE_FANCY_TAIL = "y";
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"wpa_passphrase": "you bring light in",
|
||||||
|
"ssid": "liminix",
|
||||||
|
"l2tp": {
|
||||||
|
"name": "abcde@a.1",
|
||||||
|
"password": "NotMyIspPassword"
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"passwd": "$6$6pt0mpbgcB7kC2RJ$kSBoCYGyi1.qxt7dqmexLj1l8E6oTZJZmfGyJSsMYMW.jlsETxdgQSdv6ptOYDM7DHAwf6vLG0pz3UD31XBfC1",
|
||||||
|
"openssh": {
|
||||||
|
"authorizedKeys": {
|
||||||
|
"keys": [ ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lan": {
|
||||||
|
"prefix": "10.8.0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
{ config, pkgs, lib, lim, ... } :
|
{ config, pkgs, lim, ... } :
|
||||||
let
|
let
|
||||||
inherit (pkgs) serviceFns;
|
|
||||||
svc = config.system.service;
|
svc = config.system.service;
|
||||||
|
|
||||||
in rec {
|
in rec {
|
||||||
|
|
|
@ -9,29 +9,29 @@
|
||||||
./busybox.nix
|
./busybox.nix
|
||||||
./dhcp6c
|
./dhcp6c
|
||||||
./dnsmasq
|
./dnsmasq
|
||||||
./outputs/ext4fs.nix
|
|
||||||
./firewall
|
./firewall
|
||||||
./hardware.nix
|
./hardware.nix
|
||||||
./hostapd
|
./hostapd
|
||||||
./hostname.nix
|
./hostname.nix
|
||||||
./outputs/initramfs.nix
|
|
||||||
./outputs/jffs2.nix
|
|
||||||
./kernel
|
./kernel
|
||||||
./outputs/kexecboot.nix
|
./mdevd.nix
|
||||||
./mount
|
./mount
|
||||||
./network
|
./network
|
||||||
./ntp
|
./ntp
|
||||||
./outputs.nix
|
./outputs.nix
|
||||||
./outputs/vmroot.nix
|
./outputs/ext4fs.nix
|
||||||
./outputs/ubimage.nix
|
./outputs/initramfs.nix
|
||||||
|
./outputs/jffs2.nix
|
||||||
|
./outputs/kexecboot.nix
|
||||||
./outputs/mtdimage.nix
|
./outputs/mtdimage.nix
|
||||||
|
./outputs/tftpboot.nix
|
||||||
|
./outputs/ubifs.nix
|
||||||
|
./outputs/ubimage.nix
|
||||||
|
./outputs/vmroot.nix
|
||||||
./ppp
|
./ppp
|
||||||
./ramdisk.nix
|
./ramdisk.nix
|
||||||
./squashfs.nix
|
./squashfs.nix
|
||||||
./ssh
|
./ssh
|
||||||
./outputs/tftpboot.nix
|
|
||||||
./outputs/ubifs.nix
|
|
||||||
./ubinize.nix
|
|
||||||
./users.nix
|
./users.nix
|
||||||
./vlan
|
./vlan
|
||||||
./watchdog
|
./watchdog
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, lim, pkgs, config, ...}:
|
{ lim, pkgs, config, ...}:
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
kernel.config = {
|
kernel.config = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, lim, pkgs, config, ...}:
|
{ lim, pkgs, config, ...}:
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
kernel.config = {
|
kernel.config = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, pkgs, config, lim, ...}:
|
{ config, lim, ...}:
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
kernel.config = {
|
kernel.config = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, pkgs, config, ...}:
|
{ pkgs, config, ...}:
|
||||||
{
|
{
|
||||||
imports = [ ./mips.nix ];
|
imports = [ ./mips.nix ];
|
||||||
config = {
|
config = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, pkgs, config, ...}:
|
{ config, ...}:
|
||||||
{
|
{
|
||||||
imports = [ ./mips.nix ];
|
imports = [ ./mips.nix ];
|
||||||
config = {
|
config = {
|
||||||
|
|
|
@ -4,17 +4,12 @@
|
||||||
|
|
||||||
{ lib, pkgs, config, ...}:
|
{ lib, pkgs, config, ...}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
|
inherit (lib) mkOption types;
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs.liminix.networking) address interface;
|
|
||||||
inherit (pkgs.liminix.services) bundle;
|
|
||||||
|
|
||||||
type_service = pkgs.liminix.lib.types.service;
|
type_service = pkgs.liminix.lib.types.service;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
imports = [
|
|
||||||
./kernel # kernel is a separate module for doc purposes
|
|
||||||
];
|
|
||||||
options = {
|
options = {
|
||||||
defaultProfile = {
|
defaultProfile = {
|
||||||
packages = mkOption {
|
packages = mkOption {
|
||||||
|
@ -29,6 +24,10 @@ in {
|
||||||
services = mkOption {
|
services = mkOption {
|
||||||
type = types.attrsOf type_service;
|
type = types.attrsOf type_service;
|
||||||
};
|
};
|
||||||
|
system.callService = mkOption {
|
||||||
|
type = types.functionTo (types.functionTo types.anything);
|
||||||
|
};
|
||||||
|
|
||||||
filesystem = mkOption {
|
filesystem = mkOption {
|
||||||
type = types.anything;
|
type = types.anything;
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -37,7 +36,7 @@ in {
|
||||||
'';
|
'';
|
||||||
# internal = true; # probably a good case to make this internal
|
# internal = true; # probably a good case to make this internal
|
||||||
};
|
};
|
||||||
rootfsType = mkOption {
|
rootfsType = mkOption {
|
||||||
default = "squashfs";
|
default = "squashfs";
|
||||||
type = types.enum [
|
type = types.enum [
|
||||||
"btrfs"
|
"btrfs"
|
||||||
|
@ -47,7 +46,7 @@ in {
|
||||||
"ubifs"
|
"ubifs"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
rootOptions = mkOption {
|
rootOptions = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
|
@ -55,20 +54,29 @@ in {
|
||||||
boot = {
|
boot = {
|
||||||
commandLine = mkOption {
|
commandLine = mkOption {
|
||||||
type = types.listOf types.nonEmptyStr;
|
type = types.listOf types.nonEmptyStr;
|
||||||
default = [];
|
default = [ ];
|
||||||
description = "Kernel command line";
|
description = "Kernel command line";
|
||||||
};
|
};
|
||||||
commandLineDtbNode = mkOption {
|
commandLineDtbNode = mkOption {
|
||||||
type = types.enum [ "bootargs" "bootargs-override" ];
|
type = types.enum [
|
||||||
|
"bootargs"
|
||||||
|
"bootargs-override"
|
||||||
|
];
|
||||||
default = "bootargs";
|
default = "bootargs";
|
||||||
description = "Kernel command line's devicetree node";
|
description = "Kernel command line's devicetree node";
|
||||||
};
|
};
|
||||||
imageType = mkOption {
|
imageType = mkOption {
|
||||||
type = types.enum [ "primary" "secondary" ];
|
type = types.enum [
|
||||||
|
"primary"
|
||||||
|
"secondary"
|
||||||
|
];
|
||||||
default = "primary";
|
default = "primary";
|
||||||
};
|
};
|
||||||
imageFormat = mkOption {
|
imageFormat = mkOption {
|
||||||
type = types.enum ["fit" "uimage"];
|
type = types.enum [
|
||||||
|
"fit"
|
||||||
|
"uimage"
|
||||||
|
];
|
||||||
default = "uimage";
|
default = "uimage";
|
||||||
};
|
};
|
||||||
tftp = {
|
tftp = {
|
||||||
|
@ -84,7 +92,7 @@ in {
|
||||||
};
|
};
|
||||||
# These names match the uboot environment variables. I reserve
|
# These names match the uboot environment variables. I reserve
|
||||||
# the right to change them if I think of better ones.
|
# the right to change them if I think of better ones.
|
||||||
ipaddr = mkOption {
|
ipaddr = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = ''
|
description = ''
|
||||||
Our IP address to use when creating scripts to
|
Our IP address to use when creating scripts to
|
||||||
|
@ -111,6 +119,29 @@ in {
|
||||||
"fw_devlink=off"
|
"fw_devlink=off"
|
||||||
] ++ lib.optional (config.rootOptions != null) "rootflags=${config.rootOptions}";
|
] ++ lib.optional (config.rootOptions != null) "rootflags=${config.rootOptions}";
|
||||||
|
|
||||||
|
system.callService = path : parameters :
|
||||||
|
let
|
||||||
|
typeChecked = caller: type: value:
|
||||||
|
let
|
||||||
|
inherit (lib) types mergeDefinitions;
|
||||||
|
defs = [{ file = caller; inherit value; }];
|
||||||
|
type' = types.submodule { options = type; };
|
||||||
|
in (mergeDefinitions [] type' defs).mergedValue;
|
||||||
|
cp = lib.callPackageWith(pkgs // { svc = config.system.service; });
|
||||||
|
pkg = cp path {};
|
||||||
|
checkTypes = t : p : typeChecked (builtins.toString path) t p;
|
||||||
|
in {
|
||||||
|
inherit parameters;
|
||||||
|
build = { dependencies ? [], ... } @ args :
|
||||||
|
let
|
||||||
|
s = pkg (checkTypes parameters
|
||||||
|
(builtins.removeAttrs args ["dependencies"]));
|
||||||
|
in s.overrideAttrs (o: {
|
||||||
|
dependencies = dependencies ++ o.dependencies;
|
||||||
|
buildInputs = dependencies ++ o.buildInputs;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
users.root = {
|
users.root = {
|
||||||
uid = 0; gid= 0; gecos = "Root of all evaluation";
|
uid = 0; gid= 0; gecos = "Root of all evaluation";
|
||||||
dir = "/home/root/";
|
dir = "/home/root/";
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
{ lib, pkgs, config, ...}:
|
{ lib, pkgs, config, ...}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
inherit (pkgs.liminix.services) oneshot;
|
|
||||||
inherit (pkgs) liminix;
|
inherit (pkgs) liminix;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
imports = [ ../ifwait ];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
system.service.bridge = {
|
system.service.bridge = {
|
||||||
primary = mkOption { type = liminix.lib.types.serviceDefn; };
|
primary = mkOption { type = liminix.lib.types.serviceDefn; };
|
||||||
|
@ -21,13 +22,13 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config.system.service.bridge = {
|
config.system.service.bridge = {
|
||||||
primary = liminix.callService ./primary.nix {
|
primary = config.system.callService ./primary.nix {
|
||||||
ifname = mkOption {
|
ifname = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = "bridge interface name to create";
|
description = "bridge interface name to create";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
members = liminix.callService ./members.nix {
|
members = config.system.callService ./members.nix {
|
||||||
primary = mkOption {
|
primary = mkOption {
|
||||||
type = liminix.lib.types.interface;
|
type = liminix.lib.types.interface;
|
||||||
description = "primary bridge interface";
|
description = "primary bridge interface";
|
||||||
|
|
|
@ -1,23 +1,28 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
, ifwait
|
, ifwait
|
||||||
, lib
|
, svc
|
||||||
}:
|
}:
|
||||||
{ members, primary } :
|
{ members, primary } :
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (liminix.networking) interface;
|
inherit (liminix.networking) interface;
|
||||||
inherit (liminix.services) bundle oneshot;
|
inherit (liminix.services) bundle oneshot;
|
||||||
inherit (lib) mkOption types;
|
|
||||||
addif = member :
|
addif = member :
|
||||||
oneshot {
|
# how do we get sight of services from here? maybe we need to
|
||||||
name = "${primary.name}.member.${member.name}";
|
# implement ifwait as a regualr derivation instead of a
|
||||||
up = ''
|
# servicedefinition
|
||||||
dev=$(output ${member} ifname)
|
svc.ifwait.build {
|
||||||
${ifwait}/bin/ifwait $dev running && ip link set dev $dev master $(output ${primary} ifname)
|
state = "running";
|
||||||
'';
|
interface = member;
|
||||||
down = "ip link set dev $(output ${member} ifname) nomaster";
|
|
||||||
dependencies = [ primary member ];
|
dependencies = [ primary member ];
|
||||||
|
service = oneshot {
|
||||||
|
name = "${primary.name}.member.${member.name}";
|
||||||
|
up = ''
|
||||||
|
ip link set dev $(output ${member} ifname) master $(output ${primary} ifname)
|
||||||
|
'';
|
||||||
|
down = "ip link set dev $(output ${member} ifname) nomaster";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in bundle {
|
in bundle {
|
||||||
name = "${primary.name}.members";
|
name = "${primary.name}.members";
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
, ifwait
|
|
||||||
, lib
|
, lib
|
||||||
}:
|
}:
|
||||||
{ ifname } :
|
{ ifname } :
|
||||||
let
|
let
|
||||||
inherit (liminix.services) bundle oneshot;
|
inherit (liminix.services) oneshot;
|
||||||
inherit (lib) mkOption types;
|
|
||||||
in oneshot rec {
|
in oneshot rec {
|
||||||
name = "${ifname}.link";
|
name = "${ifname}.link";
|
||||||
up = ''
|
up = ''
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
{ lib, pkgs, config, ...}:
|
{ lib, pkgs, config, ...}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption mkEnableOption types mapAttrsToList;
|
inherit (lib) mkOption types mapAttrsToList;
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (lib.strings) toUpper;
|
inherit (lib.strings) toUpper;
|
||||||
|
|
||||||
|
@ -85,10 +85,13 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
filesystem = dir {
|
filesystem = dir {
|
||||||
bin = dir ({
|
bin = dir (
|
||||||
busybox = symlink "${busybox}/bin/busybox";
|
{
|
||||||
sh = symlink "${busybox}/bin/busybox";
|
busybox = symlink "${busybox}/bin/busybox";
|
||||||
} // makeLinks);
|
sh = symlink "${busybox}/bin/busybox";
|
||||||
|
}
|
||||||
|
// makeLinks
|
||||||
|
);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,6 @@
|
||||||
dir (svc.open state-directory)]
|
dir (svc.open state-directory)]
|
||||||
(accumulate [addresses []
|
(accumulate [addresses []
|
||||||
v (dir:events)]
|
v (dir:events)]
|
||||||
(update-prefixes lan-device addresses (v:output "prefix") system))))
|
(update-prefixes lan-device addresses (or (v:output "prefix") []) system))))
|
||||||
|
|
||||||
{ : changes : run }
|
{ : changes : run }
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
writeFennel
|
writeFennel
|
||||||
, linotify
|
, linotify
|
||||||
, anoia
|
, anoia
|
||||||
, lua
|
, lualinux
|
||||||
}:
|
}:
|
||||||
writeFennel "acquire-delegated-prefix" {
|
writeFennel "acquire-delegated-prefix" {
|
||||||
packages = [ linotify anoia lua.pkgs.luafilesystem ];
|
packages = [ linotify anoia lualinux ];
|
||||||
mainFunction = "run";
|
mainFunction = "run";
|
||||||
} ./acquire-delegated-prefix.fnl
|
} ./acquire-delegated-prefix.fnl
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
(local subject (require :acquire-wan-address))
|
(local subject (require :acquire-wan-address))
|
||||||
(local { : view } (require :fennel))
|
(import-macros { : expect= } :anoia.assert)
|
||||||
(local { : merge : dup } (require :anoia))
|
(local { : merge : dup } (require :anoia))
|
||||||
|
|
||||||
|
;; nix-shell --run "cd modules/dhcp6c && fennelrepl acquire-wan-address-test.fnl"
|
||||||
|
|
||||||
(local a1
|
(local a1
|
||||||
{
|
{
|
||||||
|
@ -47,19 +48,6 @@
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
(macro expect [assertion]
|
|
||||||
(let [msg (.. "expectation failed: " (view assertion))]
|
|
||||||
`(when (not ,assertion)
|
|
||||||
(assert false ,msg))))
|
|
||||||
|
|
||||||
(macro expect= [actual expected]
|
|
||||||
`(let [ve# (view ,expected)
|
|
||||||
va# (view ,actual)]
|
|
||||||
(when (not (= ve# va#))
|
|
||||||
(assert false
|
|
||||||
(.. "\nexpected " ve# "\ngot " va#)
|
|
||||||
))))
|
|
||||||
|
|
||||||
(fn first-address []
|
(fn first-address []
|
||||||
(let [deleted
|
(let [deleted
|
||||||
(subject.deletions
|
(subject.deletions
|
||||||
|
|
|
@ -27,6 +27,6 @@
|
||||||
dir (svc.open state-directory)]
|
dir (svc.open state-directory)]
|
||||||
(accumulate [addresses []
|
(accumulate [addresses []
|
||||||
v (dir:events)]
|
v (dir:events)]
|
||||||
(update-addresses wan-device addresses (v:output "address") system))))
|
(update-addresses wan-device addresses (or (v:output "address") []) system))))
|
||||||
|
|
||||||
{ : update-addresses : deletions : run }
|
{ : update-addresses : deletions : run }
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
writeFennel
|
writeFennel
|
||||||
, linotify
|
, linotify
|
||||||
, anoia
|
, anoia
|
||||||
, lua
|
, lualinux
|
||||||
}:
|
}:
|
||||||
writeFennel "acquire-wan-address" {
|
writeFennel "acquire-wan-address" {
|
||||||
packages = [ linotify anoia lua.pkgs.luafilesystem ];
|
packages = [ linotify anoia lualinux ];
|
||||||
mainFunction = "run";
|
mainFunction = "run";
|
||||||
} ./acquire-wan-address.fnl
|
} ./acquire-wan-address.fnl
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
, lib
|
|
||||||
, callPackage
|
, callPackage
|
||||||
}:
|
}:
|
||||||
{ client, interface } :
|
{ client, interface } :
|
||||||
let
|
let
|
||||||
inherit (liminix.services) longrun;
|
inherit (liminix.services) longrun;
|
||||||
inherit (lib) mkOption types;
|
|
||||||
name = "dhcp6c.addr.${client.name}.${interface.name}";
|
name = "dhcp6c.addr.${client.name}.${interface.name}";
|
||||||
script = callPackage ./acquire-wan-address.nix { };
|
script = callPackage ./acquire-wan-address.nix { };
|
||||||
in longrun {
|
in longrun {
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
, lib
|
|
||||||
, odhcp6c
|
, odhcp6c
|
||||||
, odhcp-script
|
, odhcp-script
|
||||||
}:
|
}:
|
||||||
{ interface } :
|
{ interface } :
|
||||||
let
|
let
|
||||||
inherit (liminix.services) longrun;
|
inherit (liminix.services) longrun;
|
||||||
inherit (lib) mkOption types;
|
|
||||||
name = "dhcp6c.${interface.name}";
|
name = "dhcp6c.${interface.name}";
|
||||||
in longrun {
|
in longrun {
|
||||||
inherit name;
|
inherit name;
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
{ lib, pkgs, config, ...}:
|
{ lib, pkgs, config, ...}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
inherit (pkgs.liminix.services) oneshot;
|
|
||||||
inherit (pkgs) liminix;
|
inherit (pkgs) liminix;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -24,13 +23,13 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config.system.service.dhcp6c = {
|
config.system.service.dhcp6c = {
|
||||||
client = liminix.callService ./client.nix {
|
client = config.system.callService ./client.nix {
|
||||||
interface = mkOption {
|
interface = mkOption {
|
||||||
type = liminix.lib.types.interface;
|
type = liminix.lib.types.interface;
|
||||||
description = "interface (usually WAN) to query for DHCP6";
|
description = "interface (usually WAN) to query for DHCP6";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
address = liminix.callService ./address.nix {
|
address = config.system.callService ./address.nix {
|
||||||
client = mkOption {
|
client = mkOption {
|
||||||
type = types.anything; # liminix.lib.types.service;
|
type = types.anything; # liminix.lib.types.service;
|
||||||
};
|
};
|
||||||
|
@ -39,7 +38,7 @@ in
|
||||||
description = "interface to assign the address to";
|
description = "interface to assign the address to";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
prefix = liminix.callService ./prefix.nix {
|
prefix = config.system.callService ./prefix.nix {
|
||||||
client = mkOption {
|
client = mkOption {
|
||||||
type = types.anything; # liminix.lib.types.service;
|
type = types.anything; # liminix.lib.types.service;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
, lib
|
|
||||||
, callPackage
|
, callPackage
|
||||||
}:
|
}:
|
||||||
{ client, interface } :
|
{ client, interface } :
|
||||||
let
|
let
|
||||||
inherit (liminix.services) longrun;
|
inherit (liminix.services) longrun;
|
||||||
inherit (lib) mkOption types;
|
|
||||||
name = "dhcp6c.prefix.${client.name}.${interface.name}";
|
name = "dhcp6c.prefix.${client.name}.${interface.name}";
|
||||||
script = callPackage ./acquire-delegated-prefix.nix { };
|
script = callPackage ./acquire-delegated-prefix.nix { };
|
||||||
in longrun {
|
in longrun {
|
||||||
|
|
|
@ -16,7 +16,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
system.service.dnsmasq = liminix.callService ./service.nix {
|
system.service.dnsmasq = config.system.callService ./service.nix {
|
||||||
user = mkOption {
|
user = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "dnsmasq";
|
default = "dnsmasq";
|
||||||
|
|
|
@ -18,7 +18,7 @@ let
|
||||||
name = "${interface.name}.dnsmasq";
|
name = "${interface.name}.dnsmasq";
|
||||||
inherit (liminix.services) longrun;
|
inherit (liminix.services) longrun;
|
||||||
inherit (lib) concatStrings concatStringsSep mapAttrsToList;
|
inherit (lib) concatStrings concatStringsSep mapAttrsToList;
|
||||||
hostOpt = name : { mac, v4, v6, leasetime } @ attrs:
|
hostOpt = name : { mac, v4, v6, leasetime }:
|
||||||
let v6s = concatStrings (map (a : ",[${a}]") v6);
|
let v6s = concatStrings (map (a : ",[${a}]") v6);
|
||||||
in "--dhcp-host=${mac},${v4}${v6s},${name},${builtins.toString leasetime}";
|
in "--dhcp-host=${mac},${v4}${v6s},${name},${builtins.toString leasetime}";
|
||||||
in
|
in
|
||||||
|
@ -26,7 +26,6 @@ longrun {
|
||||||
inherit name;
|
inherit name;
|
||||||
dependencies = [ interface ];
|
dependencies = [ interface ];
|
||||||
run = ''
|
run = ''
|
||||||
. ${serviceFns}
|
|
||||||
${dnsmasq}/bin/dnsmasq \
|
${dnsmasq}/bin/dnsmasq \
|
||||||
--user=${user} \
|
--user=${user} \
|
||||||
--domain=${domain} \
|
--domain=${domain} \
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
inherit (pkgs) liminix;
|
inherit (pkgs) liminix;
|
||||||
inherit (pkgs.liminix.services) oneshot;
|
|
||||||
|
|
||||||
kmodules = pkgs.kmodloader.override {
|
kmodules = pkgs.kmodloader.override {
|
||||||
inherit (config.system.outputs) kernel;
|
inherit (config.system.outputs) kernel;
|
||||||
|
@ -55,9 +54,15 @@ in
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
system.service.firewall =
|
system.service.firewall =
|
||||||
let svc = liminix.callService ./service.nix {
|
let svc = config.system.callService ./service.nix {
|
||||||
ruleset = mkOption {
|
extraRules = mkOption {
|
||||||
|
type = types.attrsOf types.attrs;
|
||||||
|
description = "firewall ruleset";
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
rules = mkOption {
|
||||||
type = types.attrsOf types.attrs; # we could usefully tighten this a bit :-)
|
type = types.attrsOf types.attrs; # we could usefully tighten this a bit :-)
|
||||||
|
default = import ./default-rules.nix;
|
||||||
description = "firewall ruleset";
|
description = "firewall ruleset";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -68,13 +73,17 @@ in
|
||||||
};
|
};
|
||||||
in svc.build args' ;
|
in svc.build args' ;
|
||||||
};
|
};
|
||||||
|
programs.busybox.applets = [
|
||||||
|
"insmod" "rmmod"
|
||||||
|
];
|
||||||
kernel.config = {
|
kernel.config = {
|
||||||
NETFILTER = "y";
|
NETFILTER = "y";
|
||||||
NETFILTER_ADVANCED = "y";
|
NETFILTER_ADVANCED = "y";
|
||||||
NETFILTER_NETLINK = "m";
|
NETFILTER_NETLINK = "m";
|
||||||
NF_CONNTRACK = "m";
|
NF_CONNTRACK = "m";
|
||||||
|
|
||||||
|
NETLINK_DIAG = "y";
|
||||||
|
|
||||||
IP6_NF_IPTABLES= "m";
|
IP6_NF_IPTABLES= "m";
|
||||||
IP_NF_IPTABLES = "m";
|
IP_NF_IPTABLES = "m";
|
||||||
IP_NF_NAT = "m";
|
IP_NF_NAT = "m";
|
||||||
|
|
|
@ -4,12 +4,10 @@
|
||||||
, firewallgen
|
, firewallgen
|
||||||
, nftables
|
, nftables
|
||||||
}:
|
}:
|
||||||
{ ruleset }:
|
{ rules, extraRules }:
|
||||||
let
|
let
|
||||||
inherit (liminix.services) oneshot;
|
inherit (liminix.services) oneshot;
|
||||||
inherit (liminix.lib) typeChecked;
|
script = firewallgen "firewall.nft" (lib.recursiveUpdate rules extraRules);
|
||||||
inherit (lib) mkOption types;
|
|
||||||
script = firewallgen "firewall.nft" ruleset;
|
|
||||||
in oneshot {
|
in oneshot {
|
||||||
name = "firewall";
|
name = "firewall";
|
||||||
up = script;
|
up = script;
|
||||||
|
|
|
@ -5,14 +5,13 @@
|
||||||
## you want to run on it, and would usually be set in the "device" file:
|
## you want to run on it, and would usually be set in the "device" file:
|
||||||
## :file:`devices/manuf-model/default.nix`
|
## :file:`devices/manuf-model/default.nix`
|
||||||
|
|
||||||
|
{ lib, ... }:
|
||||||
{ lib, pkgs, config, ...}:
|
|
||||||
let
|
let
|
||||||
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
|
inherit (lib) mkOption types;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options = {
|
options = {
|
||||||
boot = {
|
boot = { };
|
||||||
};
|
|
||||||
hardware = {
|
hardware = {
|
||||||
dts = {
|
dts = {
|
||||||
src = mkOption {
|
src = mkOption {
|
||||||
|
@ -26,7 +25,7 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
includes = mkOption {
|
includes = mkOption {
|
||||||
default = [];
|
default = [ ];
|
||||||
description = "List of directories to search for DTS includes (.dtsi files)";
|
description = "List of directories to search for DTS includes (.dtsi files)";
|
||||||
type = types.listOf types.path;
|
type = types.listOf types.path;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
## Health check
|
||||||
|
##
|
||||||
|
## Runs a service and a separate periodic health process. When the
|
||||||
|
## health check starts failing over a period of time, kill the service.
|
||||||
|
## (Usually that means the supervisor will restart it, but you can
|
||||||
|
## have other behaviours by e.g. combining this service with a round-robin
|
||||||
|
## for failover)
|
||||||
|
|
||||||
|
|
||||||
|
{ lib, pkgs, config, ...}:
|
||||||
|
let
|
||||||
|
inherit (lib) mkOption types;
|
||||||
|
inherit (pkgs) liminix;
|
||||||
|
# inherit (pkgs.liminix.services) longrun;
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
system.service.health-check = mkOption {
|
||||||
|
description = "run a service while periodically checking it is healthy";
|
||||||
|
type = liminix.lib.types.serviceDefn;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config.system.service.health-check = config.system.callService ./service.nix {
|
||||||
|
service = mkOption {
|
||||||
|
type = liminix.lib.types.service;
|
||||||
|
};
|
||||||
|
interval = mkOption {
|
||||||
|
description = "interval between checks, in seconds";
|
||||||
|
type = types.int;
|
||||||
|
default = 10;
|
||||||
|
example = 10;
|
||||||
|
};
|
||||||
|
threshold = mkOption {
|
||||||
|
description = "number of consecutive failures required for the service to be kicked";
|
||||||
|
type = types.int;
|
||||||
|
example = 3;
|
||||||
|
};
|
||||||
|
healthCheck = mkOption {
|
||||||
|
description = "health check command or script. Expected to exit 0 if the service is healthy or any other exit status otherwise";
|
||||||
|
type = types.path;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config.programs.busybox.applets = ["expr"];
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
liminix, lib, lim, s6
|
||||||
|
}:
|
||||||
|
{ service, interval, threshold, healthCheck } :
|
||||||
|
let
|
||||||
|
inherit (liminix.services) oneshot longrun;
|
||||||
|
inherit (builtins) toString;
|
||||||
|
inherit (service) name;
|
||||||
|
checker = let name' = "check-${name}"; in longrun {
|
||||||
|
name = name';
|
||||||
|
run = ''
|
||||||
|
fails=0
|
||||||
|
echo waiting for /run/service/${name}
|
||||||
|
${s6}/bin/s6-svwait -U /run/service/${name} || exit
|
||||||
|
while sleep ${toString interval} ; do
|
||||||
|
${healthCheck}
|
||||||
|
if test $? -gt 0; then
|
||||||
|
fails=$(expr $fails + 1)
|
||||||
|
else
|
||||||
|
fails=0
|
||||||
|
fi
|
||||||
|
echo fails $fails/${toString threshold} for ${name}
|
||||||
|
if test "$fails" -gt "${toString threshold}" ; then
|
||||||
|
echo time to die
|
||||||
|
${s6}/bin/s6-svc -r /run/service/${name}
|
||||||
|
echo bounced
|
||||||
|
fails=0
|
||||||
|
echo waiting for /run/service/${name}
|
||||||
|
${s6}/bin/s6-svwait -U /run/service/${name}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in service.overrideAttrs(o: {
|
||||||
|
buildInputs = (lim.orEmpty o.buildInputs) ++ [ checker ];
|
||||||
|
dependencies = (lim.orEmpty o.dependencies) ++ [ checker ];
|
||||||
|
})
|
|
@ -16,13 +16,14 @@ let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
inherit (pkgs) liminix;
|
inherit (pkgs) liminix;
|
||||||
in {
|
in {
|
||||||
|
imports = [ ../secrets ];
|
||||||
options = {
|
options = {
|
||||||
system.service.hostapd = mkOption {
|
system.service.hostapd = mkOption {
|
||||||
type = liminix.lib.types.serviceDefn;
|
type = liminix.lib.types.serviceDefn;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
system.service.hostapd = liminix.callService ./service.nix {
|
system.service.hostapd = config.system.callService ./service.nix {
|
||||||
interface = mkOption {
|
interface = mkOption {
|
||||||
type = liminix.lib.types.service;
|
type = liminix.lib.types.service;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
|
, svc
|
||||||
, hostapd
|
, hostapd
|
||||||
|
, output-template
|
||||||
, writeText
|
, writeText
|
||||||
, lib
|
, lib
|
||||||
}:
|
}:
|
||||||
{ interface, params} :
|
{ interface, params} :
|
||||||
let
|
let
|
||||||
inherit (liminix.services) longrun;
|
inherit (liminix.services) longrun;
|
||||||
inherit (lib) concatStrings mapAttrsToList;
|
inherit (lib) concatStringsSep mapAttrsToList unique ;
|
||||||
inherit (liminix.lib) typeChecked;
|
inherit (builtins) map filter attrValues length head typeOf;
|
||||||
inherit (lib) mkOption types;
|
|
||||||
|
|
||||||
# This is not a friendly interface to configuring a wireless AP: it
|
# This is not a friendly interface to configuring a wireless AP: it
|
||||||
# just passes everything straight through to the hostapd config.
|
# just passes everything straight through to the hostapd config.
|
||||||
|
@ -22,17 +23,35 @@ let
|
||||||
driver = "nl80211";
|
driver = "nl80211";
|
||||||
logger_syslog = "-1";
|
logger_syslog = "-1";
|
||||||
logger_syslog_level = 1;
|
logger_syslog_level = 1;
|
||||||
ctrl_interface = "/run/hostapd.${name}";
|
ctrl_interface = "/run/${name}";
|
||||||
ctrl_interface_group = 0;
|
ctrl_interface_group = 0;
|
||||||
};
|
};
|
||||||
|
attrs = defaults // params ;
|
||||||
|
literal_or_output = o: ({
|
||||||
|
string = builtins.toJSON;
|
||||||
|
int = builtins.toJSON;
|
||||||
|
lambda = (o: "output(${builtins.toJSON (o "service")}, ${builtins.toJSON (o "path")})");
|
||||||
|
}.${builtins.typeOf o}) o;
|
||||||
|
|
||||||
conf = writeText "hostapd.conf"
|
conf =
|
||||||
(concatStrings
|
(writeText "hostapd.conf.in"
|
||||||
(mapAttrsToList
|
((concatStringsSep
|
||||||
(name: value: "${name}=${toString value}\n")
|
"\n"
|
||||||
(defaults // params)));
|
(mapAttrsToList
|
||||||
in longrun {
|
(n : v : "${n}={{ ${literal_or_output v} }}")
|
||||||
inherit name;
|
attrs)) + "\n"));
|
||||||
dependencies = [ interface ];
|
service = longrun {
|
||||||
run = "${hostapd}/bin/hostapd -i $(output ${interface} ifname) -P /run/${name}.pid -S ${conf}";
|
inherit name;
|
||||||
|
dependencies = [ interface ];
|
||||||
|
run = ''
|
||||||
|
mkdir -p /run/${name}
|
||||||
|
chmod 0700 /run/${name}
|
||||||
|
${output-template}/bin/output-template '{{' '}}' < ${conf} > /run/${name}/hostapd.conf
|
||||||
|
exec ${hostapd}/bin/hostapd -i $(output ${interface} ifname) -P /run/${name}/hostapd.pid -S /run/${name}/hostapd.conf
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
watch = filter (f: typeOf f == "lambda") (attrValues attrs);
|
||||||
|
in svc.secrets.subscriber.build {
|
||||||
|
inherit service watch;
|
||||||
|
action = "restart-all";
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
{ config, pkgs, lib, ... } :
|
||||||
|
let
|
||||||
|
inherit (pkgs) liminix;
|
||||||
|
inherit (lib) mkOption types;
|
||||||
|
in {
|
||||||
|
options.system.service.ifwait =
|
||||||
|
mkOption { type = liminix.lib.types.serviceDefn; };
|
||||||
|
|
||||||
|
config.system.service.ifwait = config.system.callService ./ifwait.nix {
|
||||||
|
state = mkOption { type = types.str; };
|
||||||
|
interface = mkOption {
|
||||||
|
type = liminix.lib.types.interface;
|
||||||
|
};
|
||||||
|
service = mkOption {
|
||||||
|
type = liminix.lib.types.service;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
{ ifwait, liminix } :
|
||||||
|
{
|
||||||
|
state
|
||||||
|
, interface
|
||||||
|
, service
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (liminix.services) longrun;
|
||||||
|
in longrun {
|
||||||
|
name = "ifwait.${interface.name}";
|
||||||
|
buildInputs = [ service ];
|
||||||
|
restart-on-upgrade = true;
|
||||||
|
run = ''
|
||||||
|
${ifwait}/bin/ifwait -s ${service.name} $(output ${interface} ifname) ${state}
|
||||||
|
'';
|
||||||
|
}
|
|
@ -5,14 +5,9 @@
|
||||||
|
|
||||||
{ lib, pkgs, config, ...}:
|
{ lib, pkgs, config, ...}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
|
inherit (lib) mkOption types ;
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
|
||||||
inherit (pkgs.liminix.networking) address interface;
|
|
||||||
inherit (pkgs.liminix.services) bundle;
|
|
||||||
inherit (pkgs) liminix;
|
inherit (pkgs) liminix;
|
||||||
|
|
||||||
type_service = pkgs.liminix.lib.types.service;
|
|
||||||
|
|
||||||
mergeConditionals = conf : conditions :
|
mergeConditionals = conf : conditions :
|
||||||
# for each key in conditions, if it is present in conf
|
# for each key in conditions, if it is present in conf
|
||||||
# then merge the associated value into conf
|
# then merge the associated value into conf
|
||||||
|
@ -131,8 +126,6 @@ in {
|
||||||
# at boot time unless we disable trying to call it.
|
# at boot time unless we disable trying to call it.
|
||||||
# https://lkml.org/lkml/2013/8/5/175
|
# https://lkml.org/lkml/2013/8/5/175
|
||||||
FW_LOADER_USER_HELPER = "n";
|
FW_LOADER_USER_HELPER = "n";
|
||||||
|
|
||||||
MAGIC_SYSRQ = "y";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
{ config, pkgs, ...} :
|
||||||
|
let inherit (pkgs.liminix.services) oneshot longrun;
|
||||||
|
in {
|
||||||
|
config = {
|
||||||
|
services = rec {
|
||||||
|
mdevd = longrun {
|
||||||
|
name = "mdevd";
|
||||||
|
notification-fd = 3;
|
||||||
|
run = "${pkgs.mdevd}/bin/mdevd -D 3 -b 200000 -O4";
|
||||||
|
};
|
||||||
|
devout = longrun {
|
||||||
|
name = "devout";
|
||||||
|
notification-fd = 10;
|
||||||
|
timeout-up = 60 * 1000;
|
||||||
|
run = "exec ${pkgs.devout}/bin/devout /run/devout.sock 4";
|
||||||
|
dependencies = [ mdevd ];
|
||||||
|
};
|
||||||
|
coldplug = oneshot {
|
||||||
|
name = "coldplug";
|
||||||
|
# would love to know what mdevd-coldplug/udevadm trigger does
|
||||||
|
# that this doesn't
|
||||||
|
up = ''
|
||||||
|
for i in $(find /sys -name uevent); do ( echo change > $i ) ; done
|
||||||
|
'';
|
||||||
|
dependencies = [
|
||||||
|
devout
|
||||||
|
mdevd
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -7,11 +7,6 @@
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
inherit (pkgs) liminix;
|
inherit (pkgs) liminix;
|
||||||
mkBoolOption = description : mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
inherit description;
|
|
||||||
default = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
|
@ -19,28 +14,39 @@ in {
|
||||||
type = liminix.lib.types.serviceDefn;
|
type = liminix.lib.types.serviceDefn;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config.system.service = {
|
imports = [ ../mdevd.nix ../uevent-rule ];
|
||||||
mount = liminix.callService ./service.nix {
|
config.system.service.mount =
|
||||||
device = mkOption {
|
let svc = config.system.callService ./service.nix {
|
||||||
type = types.str;
|
partlabel = mkOption {
|
||||||
example = "/dev/sda1";
|
type = types.str;
|
||||||
};
|
example = "my-usb-stick";
|
||||||
mountpoint = mkOption {
|
};
|
||||||
type = types.str;
|
mountpoint = mkOption {
|
||||||
example = "/mnt/media";
|
type = types.str;
|
||||||
};
|
example = "/mnt/media";
|
||||||
options = mkOption {
|
};
|
||||||
type = types.listOf types.str;
|
options = mkOption {
|
||||||
default = [];
|
type = types.listOf types.str;
|
||||||
example = ["noatime" "ro" "sync"];
|
default = [];
|
||||||
};
|
example = ["noatime" "ro" "sync"];
|
||||||
fstype = mkOption {
|
};
|
||||||
type = types.str;
|
fstype = mkOption {
|
||||||
default = "auto";
|
type = types.str;
|
||||||
example = "vfat";
|
default = "auto";
|
||||||
};
|
example = "vfat";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in svc // {
|
||||||
|
build = args:
|
||||||
|
let args' = args // {
|
||||||
|
dependencies = (args.dependencies or []) ++ [
|
||||||
|
config.services.mdevd
|
||||||
|
config.services.devout
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in svc.build args' ;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
config.programs.busybox = {
|
config.programs.busybox = {
|
||||||
applets = ["blkid" "findfs"];
|
applets = ["blkid" "findfs"];
|
||||||
options = {
|
options = {
|
||||||
|
|
|
@ -1,18 +1,27 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
, lib
|
, lib
|
||||||
|
, svc
|
||||||
}:
|
}:
|
||||||
{ device, mountpoint, options, fstype }:
|
{ partlabel, mountpoint, options, fstype }:
|
||||||
let
|
let
|
||||||
inherit (liminix.services) oneshot;
|
inherit (liminix.services) oneshot;
|
||||||
|
device = "/dev/disk/by-partlabel/${partlabel}";
|
||||||
|
name = "mount.${lib.strings.sanitizeDerivationName (lib.escapeURL mountpoint)}";
|
||||||
|
options_string =
|
||||||
|
if options == [] then "" else "-o ${lib.concatStringsSep "," options}";
|
||||||
|
controller = svc.uevent-rule.build {
|
||||||
|
serviceName = name;
|
||||||
|
symlink = device;
|
||||||
|
terms = {
|
||||||
|
partname = partlabel;
|
||||||
|
devtype = "partition";
|
||||||
|
};
|
||||||
|
};
|
||||||
in oneshot {
|
in oneshot {
|
||||||
name = "mount.${lib.escapeURL mountpoint}";
|
inherit name;
|
||||||
up = ''
|
timeout-up = 3600;
|
||||||
while ! findfs ${device}; do
|
up = "mount -t ${fstype} ${options_string} ${device} ${mountpoint}";
|
||||||
echo waiting for device ${device}
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
mount -t ${fstype} -o ${lib.concatStringsSep "," options} ${device} ${mountpoint}
|
|
||||||
'';
|
|
||||||
down = "umount ${mountpoint}";
|
down = "umount ${mountpoint}";
|
||||||
|
inherit controller;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
, ifwait
|
|
||||||
, serviceFns
|
, serviceFns
|
||||||
, lib
|
, lib
|
||||||
}:
|
}:
|
||||||
|
@ -12,7 +11,6 @@ let
|
||||||
# prefixes, or the same but different protocols
|
# prefixes, or the same but different protocols
|
||||||
name = "${interface.name}.a.${address}";
|
name = "${interface.name}.a.${address}";
|
||||||
up = ''
|
up = ''
|
||||||
. ${serviceFns}
|
|
||||||
dev=$(output ${interface} ifname)
|
dev=$(output ${interface} ifname)
|
||||||
ip address add ${address}/${toString prefixLength} dev $dev
|
ip address add ${address}/${toString prefixLength} dev $dev
|
||||||
(in_outputs ${name}
|
(in_outputs ${name}
|
||||||
|
|
|
@ -64,7 +64,7 @@ in {
|
||||||
services.loopback = config.hardware.networkInterfaces.lo;
|
services.loopback = config.hardware.networkInterfaces.lo;
|
||||||
|
|
||||||
system.service.network = {
|
system.service.network = {
|
||||||
link = liminix.callService ./link.nix {
|
link = config.system.callService ./link.nix {
|
||||||
ifname = mkOption {
|
ifname = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
example = "eth0";
|
example = "eth0";
|
||||||
|
@ -89,7 +89,7 @@ in {
|
||||||
example = 1480;
|
example = 1480;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
address = liminix.callService ./address.nix {
|
address = config.system.callService ./address.nix {
|
||||||
interface = mkOption {
|
interface = mkOption {
|
||||||
type = liminix.lib.types.service;
|
type = liminix.lib.types.service;
|
||||||
};
|
};
|
||||||
|
@ -104,7 +104,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
route = liminix.callService ./route.nix {
|
route = config.system.callService ./route.nix {
|
||||||
interface = mkOption {
|
interface = mkOption {
|
||||||
type = types.nullOr liminix.lib.types.interface;
|
type = types.nullOr liminix.lib.types.interface;
|
||||||
default = null;
|
default = null;
|
||||||
|
@ -125,7 +125,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
forward = liminix.callService ./forward.nix {
|
forward = config.system.callService ./forward.nix {
|
||||||
enableIPv4 = mkOption {
|
enableIPv4 = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -136,7 +136,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
dhcp.client = liminix.callService ./dhcpc.nix {
|
dhcp.client = config.system.callService ./dhcpc.nix {
|
||||||
interface = mkOption {
|
interface = mkOption {
|
||||||
type = liminix.lib.types.service;
|
type = liminix.lib.types.service;
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,7 @@ let
|
||||||
ip address replace $ip/$mask dev $interface
|
ip address replace $ip/$mask dev $interface
|
||||||
(in_outputs ${name}
|
(in_outputs ${name}
|
||||||
for i in lease mask ip router siaddr dns serverid subnet opt53 interface ; do
|
for i in lease mask ip router siaddr dns serverid subnet opt53 interface ; do
|
||||||
printenv $i > $i
|
(printenv $i || true) > $i
|
||||||
done)
|
done)
|
||||||
}
|
}
|
||||||
case $action in
|
case $action in
|
||||||
|
@ -40,7 +40,7 @@ let
|
||||||
'';
|
'';
|
||||||
in longrun {
|
in longrun {
|
||||||
inherit name;
|
inherit name;
|
||||||
run = "/bin/udhcpc -f -i $(output ${interface} ifname) -x hostname:$(cat /proc/sys/kernel/hostname) -s ${script}";
|
run = "exec /bin/udhcpc -f -i $(output ${interface} ifname) -x hostname:$(cat /proc/sys/kernel/hostname) -s ${script}";
|
||||||
notification-fd = 10;
|
notification-fd = 10;
|
||||||
dependencies = [ interface ];
|
dependencies = [ interface ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
, ifwait
|
|
||||||
, serviceFns
|
|
||||||
, lib
|
, lib
|
||||||
}:
|
}:
|
||||||
{ enableIPv4, enableIPv6 }:
|
{ enableIPv4, enableIPv6 }:
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
, ifwait
|
|
||||||
, serviceFns
|
|
||||||
, lib
|
, lib
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
@ -11,8 +9,7 @@
|
||||||
# if devpath is supplied, we rename the interface at that
|
# if devpath is supplied, we rename the interface at that
|
||||||
# path to have the specified name.
|
# path to have the specified name.
|
||||||
let
|
let
|
||||||
inherit (liminix.services) longrun oneshot;
|
inherit (liminix.services) oneshot;
|
||||||
inherit (lib) concatStringsSep;
|
|
||||||
name = "${ifname}.link";
|
name = "${ifname}.link";
|
||||||
rename = if devpath != null
|
rename = if devpath != null
|
||||||
then ''
|
then ''
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
, ifwait
|
|
||||||
, serviceFns
|
|
||||||
, lib
|
, lib
|
||||||
}:
|
}:
|
||||||
{ target, via, interface ? null, metric }:
|
{ target, via, interface ? null, metric }:
|
||||||
let
|
let
|
||||||
inherit (liminix.services) oneshot;
|
inherit (liminix.services) oneshot;
|
||||||
with_dev = if interface != null then "dev $(output ${interface} ifname)" else "";
|
with_dev = if interface != null then "dev $(output ${interface} ifname)" else "";
|
||||||
|
target_hash = builtins.substring 0 12 (builtins.hashString "sha256" target);
|
||||||
|
via_hash = builtins.substring 0 12 (builtins.hashString "sha256" via);
|
||||||
in oneshot {
|
in oneshot {
|
||||||
name = "route-${target}-${builtins.substring 0 12 (builtins.hashString "sha256" "${via}-${if interface!=null then interface.name else ""}")}";
|
name = "route-${target_hash}-${builtins.substring 0 12 (builtins.hashString "sha256" "${via_hash}-${if interface!=null then interface.name else ""}")}";
|
||||||
up = ''
|
up = ''
|
||||||
ip route add ${target} via ${via} metric ${toString metric} ${with_dev}
|
ip route add ${target} via ${via} metric ${toString metric} ${with_dev}
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -18,7 +18,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
system.service.ntp = liminix.callService ./service.nix {
|
system.service.ntp = config.system.callService ./service.nix {
|
||||||
user = mkOption {
|
user = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "ntp";
|
default = "ntp";
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
liminix
|
liminix
|
||||||
, chrony
|
, chrony
|
||||||
, serviceFns
|
|
||||||
, lib
|
, lib
|
||||||
, writeText
|
, writeText
|
||||||
}:
|
}:
|
||||||
|
@ -9,10 +8,6 @@ params:
|
||||||
let
|
let
|
||||||
inherit (liminix.services) longrun;
|
inherit (liminix.services) longrun;
|
||||||
inherit (lib) concatStringsSep mapAttrsToList;
|
inherit (lib) concatStringsSep mapAttrsToList;
|
||||||
inherit (liminix.lib) typeChecked;
|
|
||||||
inherit (lib) mkOption types;
|
|
||||||
|
|
||||||
serverOpts = types.listOf types.str;
|
|
||||||
configFile = p:
|
configFile = p:
|
||||||
(mapAttrsToList (name: opts: "server ${name} ${concatStringsSep "" opts}")
|
(mapAttrsToList (name: opts: "server ${name} ${concatStringsSep "" opts}")
|
||||||
p.servers)
|
p.servers)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
config
|
config,
|
||||||
, pkgs
|
pkgs,
|
||||||
, lib
|
lib,
|
||||||
, ...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types concatStringsSep;
|
inherit (lib) mkOption types concatStringsSep;
|
||||||
inherit (pkgs) liminix callPackage writeText;
|
inherit (pkgs) liminix writeText;
|
||||||
o = config.system.outputs;
|
o = config.system.outputs;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ in
|
||||||
# but only part of one.
|
# but only part of one.
|
||||||
kernel = mkOption {
|
kernel = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
internal = true;
|
internal = true;
|
||||||
description = ''
|
description = ''
|
||||||
kernel
|
kernel
|
||||||
******
|
******
|
||||||
|
@ -42,7 +42,7 @@ in
|
||||||
};
|
};
|
||||||
dtb = mkOption {
|
dtb = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
internal = true;
|
internal = true;
|
||||||
description = ''
|
description = ''
|
||||||
dtb
|
dtb
|
||||||
***
|
***
|
||||||
|
@ -52,7 +52,7 @@ in
|
||||||
};
|
};
|
||||||
uimage = mkOption {
|
uimage = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
internal = true;
|
internal = true;
|
||||||
description = ''
|
description = ''
|
||||||
uimage
|
uimage
|
||||||
******
|
******
|
||||||
|
@ -68,7 +68,7 @@ in
|
||||||
};
|
};
|
||||||
manifest = mkOption {
|
manifest = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
internal = true;
|
internal = true;
|
||||||
description = ''
|
description = ''
|
||||||
Debugging aid. JSON rendition of config.filesystem, on
|
Debugging aid. JSON rendition of config.filesystem, on
|
||||||
which can run "nix-store -q --tree" on it and find
|
which can run "nix-store -q --tree" on it and find
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkIf mkOption types;
|
inherit (lib) mkIf;
|
||||||
o = config.system.outputs;
|
o = config.system.outputs;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkIf mkOption types;
|
inherit (lib) mkIf;
|
||||||
o = config.system.outputs;
|
o = config.system.outputs;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkEnableOption mkOption mkIf types;
|
inherit (lib) mkEnableOption mkOption mkIf types;
|
||||||
inherit (pkgs) runCommand callPackage writeText;
|
inherit (pkgs) runCommand;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkIf mkOption types;
|
inherit (lib) mkIf;
|
||||||
o = config.system.outputs;
|
o = config.system.outputs;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,13 +5,16 @@
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption mkForce types concatStringsSep;
|
inherit (lib) mkOption types concatStringsSep;
|
||||||
in {
|
in {
|
||||||
imports = [ ../ramdisk.nix ];
|
imports = [ ../ramdisk.nix ];
|
||||||
options.system.outputs = {
|
options.system.outputs = {
|
||||||
kexecboot = mkOption {
|
kexecboot = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
description = ''
|
description = ''
|
||||||
|
kexecboot
|
||||||
|
*********
|
||||||
|
|
||||||
Directory containing files needed for kexec booting.
|
Directory containing files needed for kexec booting.
|
||||||
Can be copied onto the target device using ssh or similar
|
Can be copied onto the target device using ssh or similar
|
||||||
'';
|
'';
|
||||||
|
@ -42,8 +45,7 @@ in {
|
||||||
|
|
||||||
boot-sh =
|
boot-sh =
|
||||||
let
|
let
|
||||||
inherit (pkgs.lib.trivial) toHexString;
|
inherit (config.system.outputs) rootfs;
|
||||||
inherit (config.system.outputs) rootfs kernel;
|
|
||||||
cmdline = concatStringsSep " " config.boot.commandLine;
|
cmdline = concatStringsSep " " config.boot.commandLine;
|
||||||
in
|
in
|
||||||
pkgs.buildPackages.runCommand "boot.sh.sh" {
|
pkgs.buildPackages.runCommand "boot.sh.sh" {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types concatStringsSep;
|
inherit (lib) mkOption types;
|
||||||
o = config.system.outputs;
|
o = config.system.outputs;
|
||||||
phram_address = lib.toHexString (config.hardware.ram.startAddress + 256 * 1024 * 1024);
|
phram_address = lib.toHexString (config.hardware.ram.startAddress + 256 * 1024 * 1024);
|
||||||
in {
|
in {
|
||||||
|
|
|
@ -58,7 +58,6 @@ in {
|
||||||
system.outputs = rec {
|
system.outputs = rec {
|
||||||
tftpboot =
|
tftpboot =
|
||||||
let
|
let
|
||||||
inherit (pkgs.lib.trivial) toHexString;
|
|
||||||
o = config.system.outputs;
|
o = config.system.outputs;
|
||||||
image = let choices = {
|
image = let choices = {
|
||||||
uimage = o.uimage;
|
uimage = o.uimage;
|
||||||
|
@ -122,7 +121,7 @@ in {
|
||||||
fdtput -p -t lx dtb /reserved-memory/$node reg $ac_prefix $(hex $rootfsStart) $sz_prefix $(hex $rootfsSize)
|
fdtput -p -t lx dtb /reserved-memory/$node reg $ac_prefix $(hex $rootfsStart) $sz_prefix $(hex $rootfsSize)
|
||||||
|
|
||||||
cmd="liminix ${cmdline} mtdparts=phram0:''${rootfsSize}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsSize},${toString config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0";
|
cmd="liminix ${cmdline} mtdparts=phram0:''${rootfsSize}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsSize},${toString config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0";
|
||||||
fdtput -t s dtb /chosen bootargs "$cmd"
|
fdtput -t s dtb /chosen ${config.boot.commandLineDtbNode} "$cmd"
|
||||||
|
|
||||||
dtbSize=$(binsize ./dtb )
|
dtbSize=$(binsize ./dtb )
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types concatStringsSep;
|
inherit (lib) mkOption types;
|
||||||
o = config.system.outputs;
|
o = config.system.outputs;
|
||||||
cfg = config.tplink-safeloader;
|
cfg = config.tplink-safeloader;
|
||||||
in {
|
in {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkIf mkEnableOption mkOption types concatStringsSep;
|
inherit (lib) mkIf mkOption types;
|
||||||
cfg = config.boot.tftp;
|
cfg = config.boot.tftp;
|
||||||
instructions = pkgs.writeText "env.scr" ''
|
instructions = pkgs.writeText "env.scr" ''
|
||||||
setenv serverip ${cfg.serverip}
|
setenv serverip ${cfg.serverip}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (pkgs) liminix;
|
|
||||||
inherit (lib) mkIf mkOption types concatStringsSep optionalString;
|
inherit (lib) mkIf mkOption types concatStringsSep optionalString;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkIf mkEnableOption mkOption types concatStringsSep;
|
inherit (lib) mkIf mkOption types;
|
||||||
models = "6b e1 6f e1 ff ff ff ff ff ff";
|
models = "6b e1 6f e1 ff ff ff ff ff ff";
|
||||||
in {
|
in {
|
||||||
options.system.outputs = {
|
options.system.outputs = {
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
{ writeAshScript, liminix, svc, lib, serviceFns, output-template }:
|
||||||
|
{
|
||||||
|
command,
|
||||||
|
name,
|
||||||
|
debug
|
||||||
|
, username,
|
||||||
|
password,
|
||||||
|
lcpEcho,
|
||||||
|
ppp-options,
|
||||||
|
dependencies ? []
|
||||||
|
} :
|
||||||
|
let
|
||||||
|
inherit (lib) optional optionals escapeShellArgs concatStringsSep;
|
||||||
|
inherit (liminix.services) longrun;
|
||||||
|
inherit (builtins) toJSON toString typeOf;
|
||||||
|
|
||||||
|
ip-up = writeAshScript "ip-up" {} ''
|
||||||
|
. ${serviceFns}
|
||||||
|
(in_outputs ${name}
|
||||||
|
echo $1 > ifname
|
||||||
|
echo $2 > tty
|
||||||
|
echo $3 > speed
|
||||||
|
echo $4 > address
|
||||||
|
echo $5 > peer-address
|
||||||
|
echo $DNS1 > ns1
|
||||||
|
echo $DNS2 > ns2
|
||||||
|
)
|
||||||
|
echo >/proc/self/fd/10
|
||||||
|
'';
|
||||||
|
ip6-up = writeAshScript "ip6-up" {} ''
|
||||||
|
. ${serviceFns}
|
||||||
|
(in_outputs ${name}
|
||||||
|
echo $4 > ipv6-address
|
||||||
|
echo $5 > ipv6-peer-address
|
||||||
|
)
|
||||||
|
echo >/proc/self/fd/10
|
||||||
|
'';
|
||||||
|
literal_or_output =
|
||||||
|
let v = o: ({
|
||||||
|
string = toJSON;
|
||||||
|
int = toJSON;
|
||||||
|
lambda = (o: "output(${toJSON (o "service")}, ${toJSON (o "path")})");
|
||||||
|
}.${typeOf o}) o;
|
||||||
|
in o: "{{ ${v o} }}";
|
||||||
|
|
||||||
|
ppp-options' =
|
||||||
|
["+ipv6" "noauth"]
|
||||||
|
++ optional debug "debug"
|
||||||
|
++ optionals (username != null) ["name" (literal_or_output username)]
|
||||||
|
++ optionals (password != null) ["password" (literal_or_output password)]
|
||||||
|
++ optional lcpEcho.adaptive "lcp-echo-adaptive"
|
||||||
|
++ optionals (lcpEcho.interval != null)
|
||||||
|
["lcp-echo-interval" (toString lcpEcho.interval)]
|
||||||
|
++ optionals (lcpEcho.failure != null)
|
||||||
|
["lcp-echo-failure" (toString lcpEcho.failure)]
|
||||||
|
++ ppp-options
|
||||||
|
++ ["ip-up-script" ip-up
|
||||||
|
"ipv6-up-script" ip6-up
|
||||||
|
"ipparam" name
|
||||||
|
"nodetach"
|
||||||
|
"usepeerdns"
|
||||||
|
"nodefaultroute"
|
||||||
|
"logfd" "2"
|
||||||
|
];
|
||||||
|
service = longrun {
|
||||||
|
inherit name;
|
||||||
|
run = ''
|
||||||
|
mkdir -p /run/${name}
|
||||||
|
chmod 0700 /run/${name}
|
||||||
|
in_outputs ${name}
|
||||||
|
echo ${escapeShellArgs ppp-options'} | ${output-template}/bin/output-template '{{' '}}' > /run/${name}/ppp-options
|
||||||
|
${command}
|
||||||
|
'';
|
||||||
|
notification-fd = 10;
|
||||||
|
timeout-up = if lcpEcho.failure != null
|
||||||
|
then (10 + lcpEcho.failure * lcpEcho.interval) * 1000
|
||||||
|
else 60 * 1000;
|
||||||
|
inherit dependencies;
|
||||||
|
};
|
||||||
|
in svc.secrets.subscriber.build {
|
||||||
|
watch = lib.filter (n: typeOf n=="lambda") [ username password ];
|
||||||
|
inherit service;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue