Compare commits

...

2 Commits

15 changed files with 59 additions and 62 deletions

View File

@ -174,7 +174,7 @@ To expose a service template in a module, it needs the following:
.. code-block:: nix
config.system.service.cowsay = liminix.callService ./service.nix {
config.system.service.cowsay = config.system.callService ./service.nix {
address = mkOption {
type = types.str;
default = "0.0.0.0";

View File

@ -59,63 +59,60 @@ in rec {
services.wan =
let
z = final : prev: {
controller = longrun rec {
name = "wan-switcher";
run = ''
controller = longrun rec {
name = "wan-switcher";
run = ''
in_outputs ${name}
exec ${pkgs.s6-rc-round-robin}/bin/s6-rc-round-robin \
-p ${final.proxy.name} \
-p ${proxy.name} \
${lib.concatStringsSep " "
(builtins.map (f: f.name) [final.pppoe final.l2tp])}
(builtins.map (f: f.name) [pppoe l2tp])}
'';
};
pppoe = (svc.pppoe.build {
interface = config.hardware.networkInterfaces.wan;
};
pppoe = (svc.pppoe.build {
interface = config.hardware.networkInterfaces.wan;
ppp-options = [
"debug" "+ipv6" "noauth"
"name" rsecrets.l2tp.name
"password" rsecrets.l2tp.password
];
}).overrideAttrs(o: { inherit controller; });
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.dhcpc} router)";
target = lns.address;
dependencies = [services.dhcpc check-address];
};
in (svc.l2tp.build {
lns = lns.address;
ppp-options = [
"debug" "+ipv6" "noauth"
"name" rsecrets.l2tp.name
"password" rsecrets.l2tp.password
];
}).overrideAttrs(o: { inherit (final) controller; });
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.dhcpc} router)";
target = lns.address;
dependencies = [services.dhcpc check-address];
};
in (svc.l2tp.build {
lns = lns.address;
ppp-options = [
"debug" "+ipv6" "noauth"
"name" rsecrets.l2tp.name
"connect-delay" "5000"
"password" rsecrets.l2tp.password
];
dependencies = [config.services.lns-address route check-address];
}).overrideAttrs(o: { inherit (final) controller; });
proxy = oneshot rec {
name = "wan-proxy";
inherit (final) controller;
buildInputs = with final; [ pppoe l2tp];
up = ''
dependencies = [config.services.lns-address route check-address];
}).overrideAttrs(o: { inherit controller; });
proxy = oneshot rec {
name = "wan-proxy";
inherit controller;
buildInputs = [ pppoe l2tp];
up = ''
echo start proxy ${name}
set -x
(in_outputs ${name}
cp -rv $(output_path ${final.controller} active)/* .
cp -rv $(output_path ${controller} active)/* .
)
'';
};
};
in (lib.fix (lib.extends z (prev : { }))).proxy;
in proxy;
services.sshd = svc.ssh.build { };

View File

@ -22,7 +22,7 @@ in
};
};
config.system.service.bridge = {
primary = liminix.callService ./primary.nix {
primary = config.system.callService ./primary.nix {
ifname = mkOption {
type = types.str;
description = "bridge interface name to create";

View File

@ -23,13 +23,13 @@ in
};
};
config.system.service.dhcp6c = {
client = liminix.callService ./client.nix {
client = config.system.callService ./client.nix {
interface = mkOption {
type = liminix.lib.types.interface;
description = "interface (usually WAN) to query for DHCP6";
};
};
address = liminix.callService ./address.nix {
address = config.system.callService ./address.nix {
client = mkOption {
type = types.anything; # liminix.lib.types.service;
};
@ -38,7 +38,7 @@ in
description = "interface to assign the address to";
};
};
prefix = liminix.callService ./prefix.nix {
prefix = config.system.callService ./prefix.nix {
client = mkOption {
type = types.anything; # liminix.lib.types.service;
};

View File

@ -16,7 +16,7 @@ in {
};
};
config = {
system.service.dnsmasq = liminix.callService ./service.nix {
system.service.dnsmasq = config.system.callService ./service.nix {
user = mkOption {
type = types.str;
default = "dnsmasq";

View File

@ -54,7 +54,7 @@ in
};
config = {
system.service.firewall =
let svc = liminix.callService ./service.nix {
let svc = config.system.callService ./service.nix {
extraRules = mkOption {
type = types.attrsOf types.attrs;
description = "firewall ruleset";

View File

@ -22,7 +22,7 @@ in {
};
};
config = {
system.service.hostapd = liminix.callService ./service.nix {
system.service.hostapd = config.system.callService ./service.nix {
interface = mkOption {
type = liminix.lib.types.service;
};

View File

@ -64,7 +64,7 @@ in {
services.loopback = config.hardware.networkInterfaces.lo;
system.service.network = {
link = liminix.callService ./link.nix {
link = config.system.callService ./link.nix {
ifname = mkOption {
type = types.str;
example = "eth0";
@ -89,7 +89,7 @@ in {
example = 1480;
};
};
address = liminix.callService ./address.nix {
address = config.system.callService ./address.nix {
interface = mkOption {
type = liminix.lib.types.service;
};
@ -104,7 +104,7 @@ in {
};
};
route = liminix.callService ./route.nix {
route = config.system.callService ./route.nix {
interface = mkOption {
type = types.nullOr liminix.lib.types.interface;
default = null;
@ -125,7 +125,7 @@ in {
};
};
forward = liminix.callService ./forward.nix {
forward = config.system.callService ./forward.nix {
enableIPv4 = mkOption {
type = types.bool;
default = true;
@ -136,7 +136,7 @@ in {
};
};
dhcp.client = liminix.callService ./dhcpc.nix {
dhcp.client = config.system.callService ./dhcpc.nix {
interface = mkOption {
type = liminix.lib.types.service;
};

View File

@ -18,7 +18,7 @@ in {
};
};
config = {
system.service.ntp = liminix.callService ./service.nix {
system.service.ntp = config.system.callService ./service.nix {
user = mkOption {
type = types.str;
default = "ntp";

View File

@ -22,7 +22,7 @@ in {
};
};
config = {
system.service.pppoe = pkgs.liminix.callService ./pppoe.nix {
system.service.pppoe = config.system.callService ./pppoe.nix {
interface = mkOption {
type = liminix.lib.types.service;
description = "ethernet interface to run PPPoE over";
@ -32,7 +32,7 @@ in {
description = "options supplied on ppp command line";
};
};
system.service.l2tp = pkgs.liminix.callService ./l2tp.nix {
system.service.l2tp = config.system.callService ./l2tp.nix {
lns = mkOption {
type = types.str;
description = "hostname or address of the L2TP network server";

View File

@ -14,7 +14,7 @@ in {
};
};
config = {
system.service.uevent-rule = liminix.callService ./rule.nix {
system.service.uevent-rule = config.system.callService ./rule.nix {
serviceName = mkOption {
description = "name of the service to run when the rule matches";
type = types.str;

View File

@ -20,7 +20,7 @@ in {
};
};
config.system.service = {
ssh = liminix.callService ./ssh.nix {
ssh = config.system.callService ./ssh.nix {
address = mkOption {
type = types.nullOr types.str;
default = null;

View File

@ -19,7 +19,7 @@ in
options = {
system.service.vlan = mkOption { type = liminix.lib.types.serviceDefn; };
};
config.system.service.vlan = liminix.callService ./service.nix {
config.system.service.vlan = config.system.callService ./service.nix {
ifname = mkOption {
type = types.str;
description = "interface name to create";

View File

@ -15,7 +15,7 @@ in
type = liminix.lib.types.serviceDefn;
};
};
config.system.service.watchdog = liminix.callService ./watchdog.nix {
config.system.service.watchdog = config.system.callService ./watchdog.nix {
watched = mkOption {
description = "services to watch";
type = types.listOf liminix.lib.types.service;

View File

@ -20,7 +20,7 @@ in
type = liminix.lib.types.serviceDefn;
};
config.boot.zyxel-dual-image = liminix.callService ./service.nix {
config.boot.zyxel-dual-image = config.system.callService ./service.nix {
ensureActiveImage = mkOption {
type = types.enum [ "primary" "secondary" ];
default = "primary";