summaryrefslogtreecommitdiff
path: root/os/srv/avahi.nix
blob: f14b33a4d7e2432931827a5e9b3c537f64c89e8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{ config, lib, ... }:
let
  cfg = config.os.srv.avahi;
in
{
  options.os.srv.avahi.enable = lib.mkEnableOption "enables avahis";
  config = lib.mkIf cfg.enable {
    services.avahi = {
      enable = true;
      ipv4 = true;

      publish = {
        enable = true;
        addresses = true;
        workstation = true;
      };

      nssmdns4 = true;

      extraServiceFiles = {
        nfs = ''
          <?xml version="1.0" standalone='no'?>
          <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
          <service-group>
            <name replace-wildcards="yes">NFS Share on %h</name>
            <service>
              <type>_nfs._tcp</type>
              <port>2049</port>
              <txt-record>path=/data/vault</txt-record>
            </service>
            <service>
                <type>_nfs._tcp</type>
                <port>2049</port>
                <txt-record>path=/data/media</txt-record>
              </service>
          </service-group>
        '';
      };
    };
  };
}