forked from DGNum/liminix
convert bridge service to serviceDefn
This commit is contained in:
parent
f82501d278
commit
93e04bb834
4 changed files with 25 additions and 33 deletions
|
@ -78,12 +78,12 @@ in rec {
|
|||
};
|
||||
|
||||
services.int =
|
||||
let iface = svc.bridge.primary { ifname = "int"; };
|
||||
let iface = svc.bridge.primary.build { ifname = "int"; };
|
||||
in address iface {
|
||||
family = "inet4"; address ="10.8.0.1"; prefixLength = 16;
|
||||
};
|
||||
|
||||
services.bridge = svc.bridge.members {
|
||||
services.bridge = svc.bridge.members.build {
|
||||
primary = services.int;
|
||||
members = with config.hardware.networkInterfaces; [
|
||||
wlan_24 lan wlan_5
|
||||
|
|
|
@ -2,21 +2,36 @@
|
|||
let
|
||||
inherit (lib) mkOption types;
|
||||
inherit (pkgs.liminix.services) oneshot;
|
||||
inherit (pkgs) liminix;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
system.service.bridge = {
|
||||
primary = mkOption {
|
||||
type = types.functionTo pkgs.liminix.lib.types.service;
|
||||
type = liminix.lib.types.serviceDefn;
|
||||
};
|
||||
members = mkOption {
|
||||
type = types.functionTo pkgs.liminix.lib.types.service;
|
||||
type = liminix.lib.types.serviceDefn;
|
||||
};
|
||||
};
|
||||
};
|
||||
config = {
|
||||
system.service.bridge.primary = pkgs.callPackage ./primary.nix {};
|
||||
system.service.bridge.members = pkgs.callPackage ./members.nix {};
|
||||
kernel.config.BRIDGE = "y";
|
||||
config.system.service.bridge = {
|
||||
primary = liminix.callService ./primary.nix {
|
||||
ifname = mkOption {
|
||||
type = types.str;
|
||||
description = "interface name for the bridge device";
|
||||
};
|
||||
};
|
||||
members = liminix.callService ./members.nix {
|
||||
members = mkOption {
|
||||
type = types.listOf liminix.lib.types.service;
|
||||
description = "interfaces to add to the bridge";
|
||||
};
|
||||
primary = mkOption {
|
||||
type = liminix.lib.types.service;
|
||||
description = "bridge interface to add them to";
|
||||
};
|
||||
};
|
||||
};
|
||||
config.kernel.config.BRIDGE = "y";
|
||||
}
|
||||
|
|
|
@ -3,25 +3,11 @@
|
|||
, ifwait
|
||||
, lib
|
||||
}:
|
||||
{ members, primary } :
|
||||
let
|
||||
inherit (liminix.networking) interface;
|
||||
inherit (liminix.services) bundle oneshot;
|
||||
inherit (liminix.lib) typeChecked;
|
||||
inherit (lib) mkOption types;
|
||||
t = {
|
||||
members = mkOption {
|
||||
type = types.listOf liminix.lib.types.service;
|
||||
description = "interfaces to add to the bridge";
|
||||
};
|
||||
primary = mkOption {
|
||||
type = liminix.lib.types.service;
|
||||
description = "bridge interface to add them to";
|
||||
};
|
||||
};
|
||||
in
|
||||
params:
|
||||
let
|
||||
inherit (typeChecked "bridge-members" t params) members primary;
|
||||
addif = member :
|
||||
oneshot {
|
||||
name = "add-${member.device}-to-br-${primary.device}";
|
||||
|
|
|
@ -2,20 +2,11 @@
|
|||
liminix
|
||||
, lib
|
||||
}:
|
||||
{ ifname } :
|
||||
let
|
||||
inherit (liminix.networking) interface;
|
||||
inherit (liminix.lib) typeChecked;
|
||||
inherit (lib) mkOption types;
|
||||
t = {
|
||||
ifname = mkOption {
|
||||
type = types.str;
|
||||
description = "interface name for the bridge device";
|
||||
};
|
||||
};
|
||||
in
|
||||
params:
|
||||
let
|
||||
inherit (typeChecked "bridge" t params) ifname;
|
||||
in interface {
|
||||
device = ifname;
|
||||
type = "bridge";
|
||||
|
|
Loading…
Reference in a new issue