remove the fixpoint we didn't need
This commit is contained in:
parent
1c3242cab1
commit
75e9f8210c
@ -59,63 +59,60 @@ in rec {
|
|||||||
|
|
||||||
services.wan =
|
services.wan =
|
||||||
let
|
let
|
||||||
z = final : prev: {
|
controller = longrun rec {
|
||||||
controller = longrun rec {
|
name = "wan-switcher";
|
||||||
name = "wan-switcher";
|
run = ''
|
||||||
run = ''
|
|
||||||
in_outputs ${name}
|
in_outputs ${name}
|
||||||
exec ${pkgs.s6-rc-round-robin}/bin/s6-rc-round-robin \
|
exec ${pkgs.s6-rc-round-robin}/bin/s6-rc-round-robin \
|
||||||
-p ${final.proxy.name} \
|
-p ${proxy.name} \
|
||||||
${lib.concatStringsSep " "
|
${lib.concatStringsSep " "
|
||||||
(builtins.map (f: f.name) [final.pppoe final.l2tp])}
|
(builtins.map (f: f.name) [pppoe l2tp])}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
pppoe = (svc.pppoe.build {
|
pppoe = (svc.pppoe.build {
|
||||||
interface = config.hardware.networkInterfaces.wan;
|
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 = [
|
ppp-options = [
|
||||||
"debug" "+ipv6" "noauth"
|
"debug" "+ipv6" "noauth"
|
||||||
"name" rsecrets.l2tp.name
|
"name" rsecrets.l2tp.name
|
||||||
"password" rsecrets.l2tp.password
|
"password" rsecrets.l2tp.password
|
||||||
];
|
];
|
||||||
}).overrideAttrs(o: { inherit (final) controller; });
|
dependencies = [config.services.lns-address route check-address];
|
||||||
|
}).overrideAttrs(o: { inherit controller; });
|
||||||
l2tp =
|
proxy = oneshot rec {
|
||||||
let
|
name = "wan-proxy";
|
||||||
check-address = oneshot rec {
|
inherit controller;
|
||||||
name = "check-lns-address";
|
buildInputs = [ pppoe l2tp];
|
||||||
up = "grep -Fx ${ lns.address} $(output_path ${services.lns-address} addresses)";
|
up = ''
|
||||||
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 = ''
|
|
||||||
echo start proxy ${name}
|
echo start proxy ${name}
|
||||||
set -x
|
set -x
|
||||||
(in_outputs ${name}
|
(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 { };
|
services.sshd = svc.ssh.build { };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user