change output references from attrset to lambda
this is so that we can distinguish a ref from a literal parameter that might be a attrset
This commit is contained in:
parent
dd75322c10
commit
9c30b6f882
@ -30,6 +30,7 @@
|
|||||||
lns = { hostname = "l2tp.aaisp.net.uk"; address = "194.4.172.12"; };
|
lns = { hostname = "l2tp.aaisp.net.uk"; address = "194.4.172.12"; };
|
||||||
|
|
||||||
inherit (pkgs.liminix.services) oneshot longrun target;
|
inherit (pkgs.liminix.services) oneshot longrun target;
|
||||||
|
inherit (pkgs.liminix) outputRef;
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs) serviceFns;
|
inherit (pkgs) serviceFns;
|
||||||
svc = config.system.service;
|
svc = config.system.service;
|
||||||
@ -99,53 +100,53 @@ in rec {
|
|||||||
localDomain = "lan";
|
localDomain = "lan";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
wan = {
|
wan =
|
||||||
interface = let
|
let
|
||||||
secret = path: { service = config.services.secrets; inherit path; };
|
secret = outputRef config.services.secrets;
|
||||||
pppoe = svc.pppoe.build {
|
username = secret "ppp/username";
|
||||||
interface = config.hardware.networkInterfaces.wan;
|
password = secret "ppp/password";
|
||||||
debug = true;
|
in {
|
||||||
username = secret "ppp/username";
|
interface =
|
||||||
password = secret "ppp/password";
|
|
||||||
};
|
|
||||||
|
|
||||||
l2tp =
|
|
||||||
let
|
let
|
||||||
check-address = oneshot rec {
|
pppoe = svc.pppoe.build {
|
||||||
name = "check-lns-address";
|
interface = config.hardware.networkInterfaces.wan;
|
||||||
up = "grep -Fx ${lns.address} $(output_path ${services.lns-address} addresses)";
|
debug = true;
|
||||||
dependencies = [ services.lns-address ];
|
inherit username password;
|
||||||
};
|
};
|
||||||
route = svc.network.route.build {
|
|
||||||
via = "$(output ${services.bootstrap-dhcpc} router)";
|
l2tp =
|
||||||
target = lns.address;
|
let
|
||||||
dependencies = [services.bootstrap-dhcpc check-address];
|
check-address = oneshot rec {
|
||||||
};
|
name = "check-lns-address";
|
||||||
l2tpd= svc.l2tp.build {
|
up = "grep -Fx ${lns.address} $(output_path ${services.lns-address} addresses)";
|
||||||
lns = lns.address;
|
dependencies = [ services.lns-address ];
|
||||||
ppp-options = [
|
};
|
||||||
"debug" "+ipv6" "noauth"
|
route = svc.network.route.build {
|
||||||
"name" rsecrets.l2tp.name
|
via = "$(output ${services.bootstrap-dhcpc} router)";
|
||||||
"password" rsecrets.l2tp.password
|
target = lns.address;
|
||||||
];
|
dependencies = [services.bootstrap-dhcpc check-address];
|
||||||
dependencies = [config.services.lns-address route check-address];
|
};
|
||||||
};
|
l2tpd= svc.l2tp.build {
|
||||||
in
|
lns = lns.address;
|
||||||
svc.health-check.build {
|
inherit username password;
|
||||||
service = l2tpd;
|
dependencies = [config.services.lns-address route check-address];
|
||||||
threshold = 3;
|
};
|
||||||
interval = 2;
|
in
|
||||||
healthCheck = pkgs.writeAshScript "ping-check" {} "ping 1.1.1.1";
|
svc.health-check.build {
|
||||||
};
|
service = l2tpd;
|
||||||
in svc.round-robin.build {
|
threshold = 3;
|
||||||
name = "wan";
|
interval = 2;
|
||||||
services = [
|
healthCheck = pkgs.writeAshScript "ping-check" {} "ping 1.1.1.1";
|
||||||
pppoe
|
};
|
||||||
l2tp
|
in svc.round-robin.build {
|
||||||
];
|
name = "wan";
|
||||||
|
services = [
|
||||||
|
pppoe
|
||||||
|
l2tp
|
||||||
|
];
|
||||||
|
};
|
||||||
|
dhcp6.enable = true;
|
||||||
};
|
};
|
||||||
dhcp6.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
wireless.networks = {
|
wireless.networks = {
|
||||||
"${rsecrets.ssid}" = {
|
"${rsecrets.ssid}" = {
|
||||||
@ -153,11 +154,8 @@ in rec {
|
|||||||
hw_mode = "g";
|
hw_mode = "g";
|
||||||
channel = "6";
|
channel = "6";
|
||||||
ieee80211n = 1;
|
ieee80211n = 1;
|
||||||
} // wirelessConfig //{
|
} // wirelessConfig // {
|
||||||
wpa_passphrase = {
|
wpa_passphrase = outputRef config.services.secrets "wpa_passphrase";
|
||||||
service = config.services.secrets;
|
|
||||||
path = "wpa_passphrase";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
"${rsecrets.ssid}5" = rec {
|
"${rsecrets.ssid}5" = rec {
|
||||||
@ -170,15 +168,11 @@ in rec {
|
|||||||
ieee80211n = 1;
|
ieee80211n = 1;
|
||||||
ieee80211ac = 1;
|
ieee80211ac = 1;
|
||||||
} // wirelessConfig // {
|
} // wirelessConfig // {
|
||||||
wpa_passphrase = {
|
wpa_passphrase = outputRef config.services.secrets "wpa_passphrase";
|
||||||
service = config.services.secrets;
|
|
||||||
path = "wpa_passphrase";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
services.bootstrap-dhcpc = svc.network.dhcp.client.build {
|
services.bootstrap-dhcpc = svc.network.dhcp.client.build {
|
||||||
interface = config.services.wwan;
|
interface = config.services.wwan;
|
||||||
dependencies = [ config.services.hostname ];
|
dependencies = [ config.services.hostname ];
|
||||||
|
@ -30,7 +30,7 @@ let
|
|||||||
literal_or_output = o: ({
|
literal_or_output = o: ({
|
||||||
string = builtins.toJSON;
|
string = builtins.toJSON;
|
||||||
int = builtins.toJSON;
|
int = builtins.toJSON;
|
||||||
set = (o: "output(${builtins.toJSON o.service}, ${builtins.toJSON o.path})");
|
lambda = (o: "output(${builtins.toJSON (o "service")}, ${builtins.toJSON (o "path")})");
|
||||||
}.${builtins.typeOf o}) o;
|
}.${builtins.typeOf o}) o;
|
||||||
|
|
||||||
conf =
|
conf =
|
||||||
|
@ -40,12 +40,12 @@ in {
|
|||||||
description = "ethernet interface to run PPPoE over";
|
description = "ethernet interface to run PPPoE over";
|
||||||
};
|
};
|
||||||
username = mkOption {
|
username = mkOption {
|
||||||
type = types.nullOr liminix.lib.types.replacable;
|
type = types.nullOr (liminix.lib.types.replacable types.str);
|
||||||
default = null;
|
default = null;
|
||||||
description = "username";
|
description = "username";
|
||||||
};
|
};
|
||||||
password = mkOption {
|
password = mkOption {
|
||||||
type = types.nullOr liminix.lib.types.replacable;
|
type = types.nullOr (liminix.lib.types.replacable types.str);
|
||||||
default = null;
|
default = null;
|
||||||
description = "password";
|
description = "password";
|
||||||
};
|
};
|
||||||
@ -83,12 +83,12 @@ in {
|
|||||||
description = "hostname or address of the L2TP network server";
|
description = "hostname or address of the L2TP network server";
|
||||||
};
|
};
|
||||||
username = mkOption {
|
username = mkOption {
|
||||||
type = types.nullOr liminix.lib.types.replacable;
|
type = types.nullOr (liminix.lib.types.replacable types.str);
|
||||||
default = null;
|
default = null;
|
||||||
description = "username";
|
description = "username";
|
||||||
};
|
};
|
||||||
password = mkOption {
|
password = mkOption {
|
||||||
type = types.nullOr liminix.lib.types.replacable;
|
type = types.nullOr (liminix.lib.types.replacable types.str);
|
||||||
default = null;
|
default = null;
|
||||||
description = "password";
|
description = "password";
|
||||||
};
|
};
|
||||||
@ -116,6 +116,7 @@ in {
|
|||||||
};
|
};
|
||||||
ppp-options = mkOption {
|
ppp-options = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
|
default = [];
|
||||||
description = "options supplied on ppp command line";
|
description = "options supplied on ppp command line";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,7 @@ let
|
|||||||
let v = o: ({
|
let v = o: ({
|
||||||
string = builtins.toJSON;
|
string = builtins.toJSON;
|
||||||
int = builtins.toJSON;
|
int = builtins.toJSON;
|
||||||
set = (o: "output(${builtins.toJSON o.service}, ${builtins.toJSON o.path})");
|
lambda = (o: "output(${builtins.toJSON (o "service")}, ${builtins.toJSON (o "path")})");
|
||||||
}.${builtins.typeOf o}) o;
|
}.${builtins.typeOf o}) o;
|
||||||
in o: "{{ ${v o} }}";
|
in o: "{{ ${v o} }}";
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ let
|
|||||||
let v = o: ({
|
let v = o: ({
|
||||||
string = builtins.toJSON;
|
string = builtins.toJSON;
|
||||||
int = builtins.toJSON;
|
int = builtins.toJSON;
|
||||||
set = (o: "output(${builtins.toJSON o.service}, ${builtins.toJSON o.path})");
|
lambda = (o: "output(${builtins.toJSON (o "service")}, ${builtins.toJSON (o "path")})");
|
||||||
}.${builtins.typeOf o}) o;
|
}.${builtins.typeOf o}) o;
|
||||||
in o: "{{ ${v o} }}";
|
in o: "{{ ${v o} }}";
|
||||||
ppp-options' =
|
ppp-options' =
|
||||||
|
@ -14,6 +14,9 @@ in {
|
|||||||
uimage = callPackage ./kernel/uimage.nix { };
|
uimage = callPackage ./kernel/uimage.nix { };
|
||||||
kernel = callPackage ./kernel { };
|
kernel = callPackage ./kernel { };
|
||||||
};
|
};
|
||||||
|
outputRef = service : path :
|
||||||
|
let h = { inherit service path; };
|
||||||
|
in x : h.${x};
|
||||||
callService = path : parameters :
|
callService = path : parameters :
|
||||||
let pkg = callPackage path {};
|
let pkg = callPackage path {};
|
||||||
checkTypes = t : p : typeChecked (builtins.toString path) t p;
|
checkTypes = t : p : typeChecked (builtins.toString path) t p;
|
||||||
@ -43,18 +46,10 @@ in {
|
|||||||
description = "parametrisable s6-rc service definition";
|
description = "parametrisable s6-rc service definition";
|
||||||
check = x: lib.isAttrs x && x ? parameters && x ? build;
|
check = x: lib.isAttrs x && x ? parameters && x ? build;
|
||||||
};
|
};
|
||||||
replacable = types.either
|
replacable = t : types.either
|
||||||
types.str
|
t
|
||||||
(types.submodule {
|
# function might return a service or a path
|
||||||
options = {
|
(types.functionTo types.anything);
|
||||||
service = mkOption {
|
|
||||||
type = service;
|
|
||||||
};
|
|
||||||
path = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
inherit typeChecked;
|
inherit typeChecked;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user