2022-10-06 23:10:47 +02:00
|
|
|
{
|
|
|
|
description = "A DNS server for the ACME DNS-01 challenge written in dependency-free nim";
|
|
|
|
|
|
|
|
inputs.nixpkgs.url = github:NixOS/nixpkgs;
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs }:
|
|
|
|
let
|
|
|
|
# System types to support.
|
|
|
|
supportedSystems = [ "x86_64-linux" "aarch64-darwin" ];
|
|
|
|
|
|
|
|
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
|
|
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
|
|
|
|
|
|
|
# Nixpkgs instantiated for supported system types.
|
|
|
|
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
|
|
|
in
|
|
|
|
{
|
|
|
|
packages = forAllSystems(system:
|
|
|
|
let
|
|
|
|
pkgs = nixpkgsFor.${system};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
default = pkgs.nimPackages.buildNimPackage {
|
|
|
|
name = "norbert";
|
|
|
|
src = self;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
nixosModules.default = { config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let cfg = config.mawalu.services.norbert;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.mawalu.services.norbert = {
|
|
|
|
enable = mkEnableOption "Enable the norbert DNS server";
|
|
|
|
|
|
|
|
config = {
|
|
|
|
baseDomain = mkOption {
|
|
|
|
type = types.str;
|
2022-10-07 00:00:43 +02:00
|
|
|
description = "Base domain.";
|
2022-10-06 23:10:47 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.norbert = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = let pkg = self.packages.${pkgs.system}.default;
|
|
|
|
in {
|
|
|
|
Restart = "on-failure";
|
2022-10-07 00:00:43 +02:00
|
|
|
ExecStart = "${pkg}/bin/norbert ${generators.toINI {} { global = cfg.config; }}";
|
2022-10-06 23:10:47 +02:00
|
|
|
DynamicUser = "yes";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|