move module-based-service parameter types into service
This is in preparation for writing something that extracts them into documentation. user configurations now call config.system.service.foo.build { ...params } instead of config.system.service.foo the parameter type definitions themselves now move into the config stanza of the module referencing the service new helper function liminix.callService The only service moved so far is dnsmasq
This commit is contained in:
parent
c3631f4c9d
commit
fbb2c04132
5 changed files with 73 additions and 54 deletions
|
@ -1,14 +1,46 @@
|
|||
{ lib, pkgs, config, ...}:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
inherit (pkgs) liminix;
|
||||
in {
|
||||
options = {
|
||||
system.service.dnsmasq = mkOption {
|
||||
type = types.functionTo types.package;
|
||||
type = liminix.lib.types.serviceDefn;
|
||||
};
|
||||
};
|
||||
config = {
|
||||
system.service.dnsmasq = pkgs.callPackage ./service.nix {};
|
||||
system.service.dnsmasq = liminix.callService ./service.nix {
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "dnsmasq";
|
||||
};
|
||||
group = mkOption {
|
||||
type = types.str;
|
||||
default = "dnsmasq";
|
||||
};
|
||||
resolvconf = mkOption {
|
||||
type = types.nullOr liminix.lib.types.service;
|
||||
default = null;
|
||||
};
|
||||
interface = mkOption {
|
||||
type = liminix.lib.types.service;
|
||||
default = null;
|
||||
};
|
||||
upstreams = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
};
|
||||
ranges = mkOption {
|
||||
type = types.listOf types.str;
|
||||
};
|
||||
domain = mkOption {
|
||||
# this can be given multiple times so probably should be
|
||||
# domains plural and list of string
|
||||
description = "Domain name for DHCP service: causes the DHCP server to return the domain to any hosts which request it, and sets the domain which it is legal for DHCP-configured hosts to claim";
|
||||
type = types.str;
|
||||
example = "example.com";
|
||||
};
|
||||
};
|
||||
users.dnsmasq = {
|
||||
uid = 51; gid= 51; gecos = "DNS/DHCP service user";
|
||||
dir = "/run/dnsmasq";
|
||||
|
|
|
@ -4,46 +4,19 @@
|
|||
, serviceFns
|
||||
, lib
|
||||
}:
|
||||
{
|
||||
interface
|
||||
, user
|
||||
, domain
|
||||
, group
|
||||
, ranges
|
||||
, upstreams
|
||||
, resolvconf
|
||||
}:
|
||||
let
|
||||
name = "${interface.device}.dnsmasq";
|
||||
inherit (liminix.services) longrun;
|
||||
inherit (lib) concatStringsSep;
|
||||
inherit (liminix.lib) typeChecked;
|
||||
inherit (lib) mkOption types;
|
||||
|
||||
t = {
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "dnsmasq";
|
||||
};
|
||||
group = mkOption {
|
||||
type = types.str;
|
||||
default = "dnsmasq";
|
||||
};
|
||||
resolvconf = mkOption {
|
||||
type = types.nullOr liminix.lib.types.service;
|
||||
default = null;
|
||||
};
|
||||
interface = mkOption {
|
||||
type = liminix.lib.types.service;
|
||||
default = null;
|
||||
};
|
||||
upstreams = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
};
|
||||
ranges = mkOption {
|
||||
type = types.listOf types.str;
|
||||
};
|
||||
domain = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
in
|
||||
params:
|
||||
let
|
||||
inherit (typeChecked "dnsmasq" t params)
|
||||
interface user domain group ranges upstreams resolvconf;
|
||||
name = "${interface.device}.dnsmasq";
|
||||
in
|
||||
longrun {
|
||||
inherit name;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue