forked from DGNum/liminix
accept attr args to pppoe service, and typecheck them
We use (abuse, arguably) the nixos module system for typechecking. Un the plus side, it gives us documentation of the options and their expected types. On the downside, the error message doesn't tell us the file in which the error was encountered. (This is subject to change, if I can find a better way)
This commit is contained in:
parent
9441f48819
commit
69e6eb5a89
3 changed files with 21 additions and 7 deletions
|
@ -191,7 +191,8 @@ in rec {
|
||||||
|
|
||||||
services.wan =
|
services.wan =
|
||||||
let iface = config.hardware.networkInterfaces.wan;
|
let iface = config.hardware.networkInterfaces.wan;
|
||||||
in config.system.service.pppoe iface {
|
in config.system.service.pppoe {
|
||||||
|
interface = iface;
|
||||||
ppp-options = [
|
ppp-options = [
|
||||||
"debug" "+ipv6" "noauth"
|
"debug" "+ipv6" "noauth"
|
||||||
"name" secrets.l2tp.name
|
"name" secrets.l2tp.name
|
||||||
|
|
|
@ -6,7 +6,7 @@ let
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
system.service.pppoe = mkOption {
|
system.service.pppoe = mkOption {
|
||||||
type = types.functionTo (types.functionTo types.package);
|
type = types.functionTo types.package;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
|
|
|
@ -8,13 +8,26 @@
|
||||||
} :
|
} :
|
||||||
let
|
let
|
||||||
inherit (liminix.services) longrun;
|
inherit (liminix.services) longrun;
|
||||||
|
inherit (lib)
|
||||||
|
mergeDefinitions
|
||||||
|
mkEnableOption mkOption isType types isDerivation hasAttr;
|
||||||
|
t = {
|
||||||
|
interface = mkOption {
|
||||||
|
type = types.package; # actually a service
|
||||||
|
description = "ethernet interface to run PPPoE over";
|
||||||
|
};
|
||||||
|
ppp-options = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
t' = types.submodule { options = t; };
|
||||||
|
typeChecked = type: value:
|
||||||
|
let defs = [{ file = "pppoe.nix"; inherit value; }];
|
||||||
|
in (lib.mergeDefinitions [ ] type defs).mergedValue;
|
||||||
in
|
in
|
||||||
interface: {
|
params:
|
||||||
synchronous ? false
|
|
||||||
, ppp-options ? []
|
|
||||||
, ...
|
|
||||||
} @ args:
|
|
||||||
let
|
let
|
||||||
|
inherit (typeChecked t' params) ppp-options interface;
|
||||||
name = "${interface.device}.pppoe";
|
name = "${interface.device}.pppoe";
|
||||||
ip-up = writeAshScript "ip-up" {} ''
|
ip-up = writeAshScript "ip-up" {} ''
|
||||||
. ${serviceFns}
|
. ${serviceFns}
|
||||||
|
|
Loading…
Reference in a new issue