home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

avahi.nix (699B)


      1 { config, lib, pkgs, ... }:
      2 
      3 let
      4   inherit (lib) mkEnableOption mkIf versionOlder;
      5   cfg = config.modules.services.avahi;
      6   stable = versionOlder config.system.nixos.release "24.05";
      7 in
      8 {
      9   options = {
     10     modules.services.avahi = {
     11       enable = mkEnableOption "Enable avahi profile";
     12     };
     13   };
     14 
     15   config = mkIf cfg.enable
     16     {
     17       services = {
     18         avahi = {
     19           enable = true;
     20           ipv4 = true;
     21           ipv6 = true;
     22           publish = {
     23             enable = true;
     24             userServices = true;
     25           };
     26 	  openFirewall = true;
     27         } // (if stable
     28         then {
     29           nssmdns = true;
     30         } else {
     31           nssmdns4 = true;
     32         });
     33       };
     34     };
     35 }