Added NixOS module
This commit is contained in:
52
nix/qddns-module.nix
Normal file
52
nix/qddns-module.nix
Normal file
@@ -0,0 +1,52 @@
|
||||
flake:
|
||||
{ config, options, lib, pkgs, ...}:
|
||||
let
|
||||
cfg = config.services.qddns-server;
|
||||
pkg = flake.defaultPackage.${pkgs.system};
|
||||
in
|
||||
{
|
||||
options.services.qddns-server = with lib; {
|
||||
enable = mkEnableOption "QDDNS";
|
||||
db = mkOption {
|
||||
default = "postgresql:///pdns";
|
||||
type = types.str;
|
||||
description = "Connection string for PDNS backend database";
|
||||
};
|
||||
sockUser = mkOption {
|
||||
default = cfg.user;
|
||||
type = types.str;
|
||||
description = "The desired owner of the listen socket";
|
||||
};
|
||||
user = mkOption {
|
||||
default = "qddns";
|
||||
type = types.str;
|
||||
description = "The user to run QDDNS as";
|
||||
};
|
||||
group = mkOption {
|
||||
default = "qddns";
|
||||
description = "The group to run QDDNS as";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.sockets.qddns = {
|
||||
enable = true;
|
||||
listenStreams = [ "/run/qddns.sock" ];
|
||||
socketConfig = {
|
||||
SocketUser = cfg.sockUser;
|
||||
};
|
||||
};
|
||||
systemd.services.qddns = {
|
||||
enable = true;
|
||||
script = "${pkg}/bin/qddns-server";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment.QDDNS_SERVER = cfg.db;
|
||||
ServiceConfig = {
|
||||
DynamicUser="yes";
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user