2015-05-16 22:22:35 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) mkEnableOption mkIf mkOption singleton types;
|
|
|
|
inherit (pkgs) bird;
|
|
|
|
cfg = config.services.bird;
|
|
|
|
|
|
|
|
configFile = pkgs.writeText "bird.conf" ''
|
|
|
|
${cfg.config}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.bird = {
|
|
|
|
|
|
|
|
enable = mkEnableOption "BIRD Internet Routing Daemon";
|
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.string;
|
|
|
|
description = ''
|
|
|
|
BIRD Internet Routing Daemon configuration file.
|
2015-05-21 02:53:54 +01:00
|
|
|
<link xlink:href='http://bird.network.cz/'/>
|
2015-05-16 22:22:35 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.string;
|
2016-03-07 00:11:41 +00:00
|
|
|
default = "bird";
|
2015-05-16 22:22:35 +01:00
|
|
|
description = ''
|
|
|
|
BIRD Internet Routing Daemon user.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.string;
|
2016-03-07 00:11:41 +00:00
|
|
|
default = "bird";
|
2015-05-16 22:22:35 +01:00
|
|
|
description = ''
|
|
|
|
BIRD Internet Routing Daemon group.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
users.extraUsers = singleton {
|
|
|
|
name = cfg.user;
|
|
|
|
description = "BIRD Internet Routing Daemon user";
|
|
|
|
uid = config.ids.uids.bird;
|
|
|
|
group = cfg.group;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.extraGroups = singleton {
|
|
|
|
name = cfg.group;
|
|
|
|
gid = config.ids.gids.bird;
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.bird = {
|
|
|
|
description = "BIRD Internet Routing Daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${bird}/bin/bird -d -c ${configFile} -s /var/run/bird.ctl -u ${cfg.user} -g ${cfg.group}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|