flake

Francesco Saccone's Nix flake.
git clone https://git.francescosaccone.com/flake
Log | Files | Refs | README | LICENSE

dns.nix (2541B)


      1 domain:
      2 let
      3   ttl = 3600;
      4 in
      5 (
      6   let
      7     main = {
      8       ipv4 = "193.108.52.52";
      9       ipv6 = "2001:1600:13:101::16e3";
     10     };
     11     git = {
     12       ipv4 = "83.228.193.236";
     13       ipv6 = "2001:1600:13:101::1a12";
     14     };
     15   in
     16   {
     17     "@" = main;
     18     inherit git;
     19 
     20     ns1 = main;
     21     ns2 = git;
     22   }
     23   |> builtins.mapAttrs (
     24     name:
     25     { ipv4, ipv6 }:
     26     [
     27       {
     28         inherit name;
     29         inherit ttl;
     30         class = "IN";
     31         type = "A";
     32         data = ipv4;
     33       }
     34       {
     35         inherit name;
     36         inherit ttl;
     37         class = "IN";
     38         type = "AAAA";
     39         data = ipv6;
     40       }
     41     ]
     42   )
     43   |> builtins.attrValues
     44   |> builtins.concatLists
     45 )
     46 ++ [
     47   {
     48     name = "@";
     49     inherit ttl;
     50     class = "IN";
     51     type = "SOA";
     52     data = ''
     53       ns1.${domain}. francesco.${domain}. (
     54         2021090101
     55         900
     56         900
     57         2592000
     58         900
     59       )
     60     '';
     61   }
     62   {
     63     name = "@";
     64     inherit ttl;
     65     class = "IN";
     66     type = "NS";
     67     data = "ns1.${domain}.";
     68   }
     69   {
     70     name = "@";
     71     inherit ttl;
     72     class = "IN";
     73     type = "NS";
     74     data = "ns2.${domain}.";
     75   }
     76   {
     77     name = "@";
     78     inherit ttl;
     79     class = "IN";
     80     type = "MX";
     81     data = "10 glacier.mxrouting.net.";
     82   }
     83   {
     84     name = "@";
     85     inherit ttl;
     86     class = "IN";
     87     type = "MX";
     88     data = "20 glacier-relay.mxrouting.net.";
     89   }
     90   {
     91     name = "@";
     92     inherit ttl;
     93     class = "IN";
     94     type = "TXT";
     95     data = "\"v=spf1 include:mxroute.com -all\"";
     96   }
     97   {
     98     name = "x._domainkey";
     99     inherit ttl;
    100     class = "IN";
    101     type = "TXT";
    102     data =
    103       let
    104         key =
    105           [
    106             "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArLEUDzMAOlQaKm7Ov5hJ"
    107             "4vgETJN7vMbwb2qr4mUI5nU6zpfH/609NV63mZfxTlqOKAan0zee9Yizrc1UgnGE"
    108             "8Y8Hh34vwPo2D2rMA0xuhyDiOVoLvw7AQIp38WeT7Gj7idm3lPy0iDgYIxIZaoQQ"
    109             "9u4GW3XnZmhbHUGURilSDp0kDW6m1i+fPxD0XEyrYLzwYr85KKeWKZJEn6qRk5og"
    110             "d9n7p7xJa24gvNpMSZTZHvSG9C0EMnorLqlHw5i3HMA99IO6RjZK3Ntoo5YktTbu"
    111             "q9NP+ecpDt3xHC7HOWAGetL8tPC7HZbOF+SCcFXp4LGZpruAEBnzbAbimz0B1va5"
    112             "LQIDAQAB"
    113           ]
    114           |> builtins.map (s: "\"${s}\"")
    115           |> builtins.concatStringsSep "\n";
    116       in
    117       ''
    118         (
    119           "v=DKIM1;"
    120           "k=rsa;"
    121           "p="
    122           ${key}
    123         )
    124       '';
    125   }
    126   {
    127     name = "_dmarc";
    128     inherit ttl;
    129     class = "IN";
    130     type = "TXT";
    131     data = ''
    132       (
    133         "v=DMARC1;"
    134         "p=reject;"
    135         "pct=100;"
    136         "rua=mailto:francesco@${domain};";
    137       )
    138     '';
    139   }
    140 ]