Compare commits
3 Commits
7fad66ff27
...
fbb2c04132
Author | SHA1 | Date | |
---|---|---|---|
fbb2c04132 | |||
c3631f4c9d | |||
4689cebf8d |
@ -119,7 +119,7 @@ in rec {
|
|||||||
|
|
||||||
services.dns =
|
services.dns =
|
||||||
let interface = services.int;
|
let interface = services.int;
|
||||||
in svc.dnsmasq {
|
in svc.dnsmasq.build {
|
||||||
resolvconf = services.resolvconf;
|
resolvconf = services.resolvconf;
|
||||||
inherit interface;
|
inherit interface;
|
||||||
ranges = [
|
ranges = [
|
||||||
|
@ -27,7 +27,7 @@ in {
|
|||||||
kernel = {
|
kernel = {
|
||||||
src = mkOption { type = types.package; } ;
|
src = mkOption { type = types.package; } ;
|
||||||
modular = mkOption {
|
modular = mkOption {
|
||||||
type = types.boolean;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "support loadable kernel modules";
|
description = "support loadable kernel modules";
|
||||||
};
|
};
|
||||||
|
@ -1,14 +1,46 @@
|
|||||||
{ lib, pkgs, config, ...}:
|
{ lib, pkgs, config, ...}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
|
inherit (pkgs) liminix;
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
system.service.dnsmasq = mkOption {
|
system.service.dnsmasq = mkOption {
|
||||||
type = types.functionTo types.package;
|
type = liminix.lib.types.serviceDefn;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
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 = {
|
users.dnsmasq = {
|
||||||
uid = 51; gid= 51; gecos = "DNS/DHCP service user";
|
uid = 51; gid= 51; gecos = "DNS/DHCP service user";
|
||||||
dir = "/run/dnsmasq";
|
dir = "/run/dnsmasq";
|
||||||
|
@ -4,46 +4,19 @@
|
|||||||
, serviceFns
|
, serviceFns
|
||||||
, lib
|
, lib
|
||||||
}:
|
}:
|
||||||
|
{
|
||||||
|
interface
|
||||||
|
, user
|
||||||
|
, domain
|
||||||
|
, group
|
||||||
|
, ranges
|
||||||
|
, upstreams
|
||||||
|
, resolvconf
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
|
name = "${interface.device}.dnsmasq";
|
||||||
inherit (liminix.services) longrun;
|
inherit (liminix.services) longrun;
|
||||||
inherit (lib) concatStringsSep;
|
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
|
in
|
||||||
longrun {
|
longrun {
|
||||||
inherit name;
|
inherit name;
|
||||||
|
@ -11,8 +11,7 @@ in
|
|||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
boot.initramfs = {
|
boot.initramfs = {
|
||||||
enable = mkEnableOption "enable initramfs";
|
enable = mkEnableOption "initramfs";
|
||||||
default = false;
|
|
||||||
};
|
};
|
||||||
system.outputs.initramfs = mkOption {
|
system.outputs.initramfs = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
@ -10,11 +10,11 @@ in {
|
|||||||
options = {
|
options = {
|
||||||
boot = {
|
boot = {
|
||||||
ramdisk = {
|
ramdisk = {
|
||||||
enable = mkEnableOption (lib.mdDoc ''
|
enable = mkEnableOption ''
|
||||||
Configure kernel to enable reserving part of memory as
|
reserving part of memory as
|
||||||
an MTD-based RAM disk. Needed for TFTP booting or for
|
an MTD-based RAM disk. Needed for TFTP booting or for
|
||||||
kexec-based revertable upgrade
|
kexec-based revertable upgrade
|
||||||
'');
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,14 @@
|
|||||||
callPackage
|
callPackage
|
||||||
, lib
|
, lib
|
||||||
}:
|
}:
|
||||||
{
|
let
|
||||||
|
typeChecked = caller: type: value:
|
||||||
|
let
|
||||||
|
inherit (lib) types mergeDefinitions;
|
||||||
|
defs = [{ file = caller; inherit value; }];
|
||||||
|
type' = types.submodule { options = type; };
|
||||||
|
in (mergeDefinitions [] type' defs).mergedValue;
|
||||||
|
in {
|
||||||
pseudofile = callPackage ./pseudofile {};
|
pseudofile = callPackage ./pseudofile {};
|
||||||
liminix = {
|
liminix = {
|
||||||
services = callPackage ./liminix-tools/services {};
|
services = callPackage ./liminix-tools/services {};
|
||||||
@ -11,22 +18,29 @@
|
|||||||
squashfs = callPackage ./liminix-tools/builders/squashfs.nix {};
|
squashfs = callPackage ./liminix-tools/builders/squashfs.nix {};
|
||||||
kernel = callPackage ./kernel {};
|
kernel = callPackage ./kernel {};
|
||||||
};
|
};
|
||||||
|
callService = path : parameters :
|
||||||
|
let pkg = callPackage path {};
|
||||||
|
checkTypes = t : p : typeChecked (builtins.tostring path) t p;
|
||||||
|
in {
|
||||||
|
inherit parameters;
|
||||||
|
build = args : pkg (checkTypes parameters args);
|
||||||
|
};
|
||||||
lib = {
|
lib = {
|
||||||
types = {
|
types =
|
||||||
service =
|
let inherit (lib) types isDerivation;
|
||||||
let inherit (lib) types isDerivation hasAttr;
|
in {
|
||||||
in types.package // {
|
service = types.package // {
|
||||||
name = "service";
|
name = "service";
|
||||||
description = "s6-rc service";
|
description = "s6-rc service";
|
||||||
check = x: isDerivation x && hasAttr "serviceType" x;
|
check = x: isDerivation x && x ? serviceType;
|
||||||
|
};
|
||||||
|
serviceDefn = types.attrs // {
|
||||||
|
name = "service-defn";
|
||||||
|
description = "parametrisable s6-rc service definition";
|
||||||
|
check = x: lib.isAttrs x && x ? parameters && x ? build;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
typeChecked = caller: type: value:
|
inherit typeChecked;
|
||||||
let
|
|
||||||
inherit (lib) types mergeDefinitions;
|
|
||||||
defs = [{ file = caller; inherit value; }];
|
|
||||||
type' = types.submodule { options = type; };
|
|
||||||
in (mergeDefinitions [] type' defs).mergedValue;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
writeFennelScript = callPackage ./write-fennel-script {};
|
writeFennelScript = callPackage ./write-fennel-script {};
|
||||||
|
@ -41,7 +41,7 @@ in rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
services.dns =
|
services.dns =
|
||||||
config.system.service.dnsmasq {
|
config.system.service.dnsmasq.build {
|
||||||
interface = services.lan4;
|
interface = services.lan4;
|
||||||
ranges = ["192.168.19.10,192.168.19.253"];
|
ranges = ["192.168.19.10,192.168.19.253"];
|
||||||
domain = "fake.liminix.org";
|
domain = "fake.liminix.org";
|
||||||
|
Loading…
Reference in New Issue
Block a user