{ pkgs, lib, config, ... }:
let
    settings = import ./../settings.nix;
in
{
    config = lib.mkMerge [
        {
            services.printing.enable = true;
        }
        # Avahi daemon
        (lib.mkIf settings.printing.avahi {
            services.avahi.enable = true;
            # for a WiFi printer
            services.avahi.openFirewall = true;
            services.avahi.nssmdns = false; # Use the settings from below
            # settings from avahi-daemon.nix where mdns is replaced with mdns4
            system.nssModules = pkgs.lib.optional (!config.services.avahi.nssmdns) pkgs.nssmdns;
            system.nssDatabases.hosts = with pkgs.lib; optionals (!config.services.avahi.nssmdns) (mkMerge [
                (mkBefore [ "mdns4_minimal [NOTFOUND=return]" ]) # before resolve
                (mkAfter [ "mdns4" ]) # after dns
            ]);
        })
    ];
}
