From 43a4353c67188825b8ecdd0fa24ba914171affd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 6 Mar 2008 17:11:22 +0000 Subject: [PATCH] Add support for the Avahi daemon. The daemon starts correctly but, for some reason, clients fail to connect to it. svn path=/nixos/trunk/; revision=10999 --- system/ids.nix | 4 +++ system/options.nix | 47 ++++++++++++++++++++++++++++++++++- upstart-jobs/avahi-daemon.nix | 44 ++++++++++++++++++++++++++++++++ upstart-jobs/default.nix | 7 ++++++ 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 upstart-jobs/avahi-daemon.nix diff --git a/system/ids.nix b/system/ids.nix index b83f9a531c5..fee56a5303b 100644 --- a/system/ids.nix +++ b/system/ids.nix @@ -11,6 +11,8 @@ vsftpd = 7; ftp = 8; bitlbee = 9; + avahi = 10; + nixbld = 30000; # start of range of uids nobody = 65534; }; @@ -21,7 +23,9 @@ haldaemon = 5; vsftpd = 7; ftp = 8; + avahi = 10; audio = 17; + users = 100; nixbld = 30000; nogroup = 65534; diff --git a/system/options.nix b/system/options.nix index 11b4e90a426..0689789c27d 100644 --- a/system/options.nix +++ b/system/options.nix @@ -914,12 +914,57 @@ }; + avahi = { + + enable = mkOption { + default = false; + description = '' + Whether to run the Avahi daemon, which allows Avahi clients + to use Avahi's service discovery facilities and also allows + the local machine to advertise its presence and services + (through the mDNS responder implemented by `avahi-daemon'). + ''; + }; + + hostName = mkOption { + default = "nixos"; # XXX: Would be nice to use `networking.hostName'. + description = ''Host name advertised on the LAN.''; + }; + + browseDomains = mkOption { + default = [ "0pointer.de" "zeroconf.org" ]; + description = '' + List of non-local DNS domains to be browsed. + ''; + }; + + ipv4 = mkOption { + default = true; + description = ''Whether to use IPv4''; + }; + + ipv6 = mkOption { + default = false; + description = ''Whether to use IPv6''; + }; + + wideArea = mkOption { + default = true; + description = ''Whether to enable wide-area service discovery.''; + }; + + publishing = mkOption { + default = true; + description = ''Whether to allow publishing.''; + }; + }; + bitlbee = { enable = mkOption { default = false; description = '' - Whether the run the BitlBee IRC to other chat network gateway. + Whether to run the BitlBee IRC to other chat network gateway. Running it allows you to access the MSN, Jabber, Yahoo! and ICQ chat networks via an IRC client. ''; diff --git a/upstart-jobs/avahi-daemon.nix b/upstart-jobs/avahi-daemon.nix new file mode 100644 index 00000000000..481bdb712bb --- /dev/null +++ b/upstart-jobs/avahi-daemon.nix @@ -0,0 +1,44 @@ +{avahi, config, writeText, lib}: + +let + + avahiDaemonConf = with config; writeText "avahi-daemon.conf" '' + [server] + host-name=${hostName} + browse-domains=${lib.concatStringsSep ", " browseDomains} + use-ipv4=${if ipv4 then "yes" else "no"} + use-ipv6=${if ipv6 then "yes" else "no"} + + [wide-area] + enable-wide-area=${if wideArea then "yes" else "no"} + + [publish] + disable-publishing=${if publishing then "no" else "yes"} + ''; + + avahiUid = (import ../system/ids.nix).uids.avahi; + +in + +{ + name = "avahi-daemon"; + + users = [ + { name = "avahi"; + uid = (import ../system/ids.nix).uids.avahi; + description = "`avahi-daemon' privilege separation user"; + home = "/var/empty"; + } + ]; + + job = '' + start on startup + stop on shutdown + respawn + script + export PATH="${avahi}/bin:${avahi}/sbin:$PATH" + exec ${avahi}/sbin/avahi-daemon --daemonize -f "${avahiDaemonConf}" + end script + ''; + +} diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index 065e8cda08a..fcf15c74a5d 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -157,6 +157,13 @@ let servers = config.services.ntp.servers; }) + # Avahi daemon. + ++ optional config.services.avahi.enable + (import ../upstart-jobs/avahi-daemon.nix { + inherit (pkgs) avahi writeText lib; + config = config.services.avahi; + }) + # X server. ++ optional config.services.xserver.enable (import ../upstart-jobs/xserver.nix {