Coder Social home page Coder Social logo

dns.nix's Introduction

NixOS module to manage DNS records.

What is dns.nix

dns.nix is a NixOs module and library that makes declarative management of DNS records as simple as possible, while still utilizing the flexibility of NixOS configurations.

Features

  • Typed and format checked DNS records
  • Support for multiple zones and sub-zones
  • Tool-agnostic record collection for multiple nodes
  • Zone file generation

Usage

dns.nix can be used as a flake or by directly importing default.nix in your module system.

Example using flakes:

{
  inputs = {
    dns.url = "github:fooker/dns.nix";
  };

  outputs = { dns, ... }: {
    nixosSystem = {
      modules = [ dns.nixosModules.default ];
    };
  };
}

Example using imports:

{
  imports = [ /path/to/dns.nix/default.nix ];
}

The module defines the dns option which is used to define DNS zones and records.

Example module with a simple zone definition:

{ ... }: {
  dns.zones = {
    com.example = {
      # Havine a SOA record makes this a zone
      SOA = {
        mname = "ns.example.com.";
        rname = "hostmaster";
      };
      
      # Records can have one or multiple values and will be coerced if the record type allows multiple values
      NS = [
        "ns.example.com"
        "ns2.example.com"
      ];

      # Lower-case name form record names where upper-case names are interpreted as record types.
      something = {
        # Set TTL for everything under `something.example.com`
        ttl = 60;

        # Defines an AAAA record for something.example.com
        AAAA = "2001:0db8:85a3::8a2e:0370:7334";
      };
    };
  };
}

This simple form of a DNS record tree is transformed to a tree where each level is an attribute set containing the following elements:

  • ttl: The TTL in seconds for all records in node and below.
  • records: The records defined for this node
  • nodes: The child nodes for this node.
  • includes: Includes of a static zone files on this node level. This is only evaluated during zone-file generation.
  • parent: Records propagated to the parent zone.

dns.nix's People

Contributors

fooker avatar noodlesalat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.