Convert "dbus" & "avahi-deamon" upstart-job to the fix-style.
svn path=/nixos/branches/fix-style/; revision=13378
This commit is contained in:
parent
dc634f5297
commit
9c0eef3bae
@ -50,13 +50,6 @@ import ../helpers/make-etc.nix {
|
||||
target = "hosts";
|
||||
}
|
||||
|
||||
{ # Name Service Switch configuration file. Required by the C library.
|
||||
source = if config.services.avahi.nssmdns
|
||||
then (assert config.services.avahi.enable; ./nsswitch-mdns.conf)
|
||||
else ./nsswitch.conf;
|
||||
target = "nsswitch.conf";
|
||||
}
|
||||
|
||||
{ # Friendly greeting on the virtual consoles.
|
||||
source = pkgs.writeText "issue" ''
|
||||
|
||||
|
@ -347,8 +347,7 @@ in
|
||||
let
|
||||
list2 =
|
||||
list
|
||||
++ pkgs.lib.optional config.users.ldap.enable pkgs.nss_ldap
|
||||
++ pkgs.lib.optional config.services.avahi.nssmdns pkgs.nssmdns;
|
||||
++ pkgs.lib.optional config.users.ldap.enable pkgs.nss_ldap;
|
||||
in {
|
||||
list = list2;
|
||||
path = pkgs.lib.makeLibraryPath list2;
|
||||
@ -1039,66 +1038,6 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
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.'';
|
||||
};
|
||||
|
||||
nssmdns = mkOption {
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to enable the mDNS NSS (Name Service Switch) plug-in.
|
||||
Enabling it allows applications to resolve names in the `.local'
|
||||
domain by transparently querying the Avahi daemon.
|
||||
|
||||
Warning: Currently, enabling this option breaks DNS lookups after
|
||||
a `nixos-rebuild'. This is because `/etc/nsswitch.conf' is
|
||||
updated to use `nss-mdns' but `libnss_mdns' is not in
|
||||
applications' `LD_LIBRARY_PATH'. The next time `/etc/profile' is
|
||||
sourced, it will set up an appropriate `LD_LIBRARY_PATH', though.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
bitlbee = {
|
||||
|
||||
enable = mkOption {
|
||||
@ -1930,19 +1869,6 @@ in
|
||||
};
|
||||
|
||||
|
||||
dbus = {
|
||||
|
||||
enable = mkOption {
|
||||
default = true;
|
||||
description = "
|
||||
Whether to start the D-Bus message bus daemon. It is required
|
||||
by the HAL service.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
udev = {
|
||||
|
||||
addFirmware = mkOption {
|
||||
@ -3007,6 +2933,8 @@ root ALL=(ALL) SETENV: ALL
|
||||
(import ../upstart-jobs/pcmcia.nix)
|
||||
|
||||
# services
|
||||
(import ../upstart-jobs/avahi-daemon.nix)
|
||||
(import ../upstart-jobs/dbus.nix)
|
||||
(import ../upstart-jobs/hal.nix)
|
||||
(import ../upstart-jobs/gpm.nix)
|
||||
(import ../upstart-jobs/nagios/default.nix)
|
||||
|
@ -160,7 +160,6 @@ rec {
|
||||
++ pkgs.lib.optional config.security.sudo.enable pkgs.sudo
|
||||
++ pkgs.lib.optional config.services.atd.enable pkgs.at
|
||||
++ pkgs.lib.optional config.services.bitlbee.enable pkgs.bitlbee
|
||||
++ pkgs.lib.optional config.services.avahi.enable pkgs.avahi
|
||||
++ pkgs.lib.optional config.networking.defaultMailServer.directDelivery pkgs.ssmtp
|
||||
++ config.environment.extraPackages
|
||||
++ pkgs.lib.optional config.fonts.enableFontDir fontDir
|
||||
|
@ -1,8 +1,83 @@
|
||||
{avahi, config, writeText, lib}:
|
||||
# Avahi daemon.
|
||||
{pkgs, config}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption;
|
||||
|
||||
avahiDaemonConf = with config; writeText "avahi-daemon.conf" ''
|
||||
options = {
|
||||
services = {
|
||||
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.'';
|
||||
};
|
||||
|
||||
nssmdns = mkOption {
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to enable the mDNS NSS (Name Service Switch) plug-in.
|
||||
Enabling it allows applications to resolve names in the `.local'
|
||||
domain by transparently querying the Avahi daemon.
|
||||
|
||||
Warning: Currently, enabling this option breaks DNS lookups after
|
||||
a `nixos-rebuild'. This is because `/etc/nsswitch.conf' is
|
||||
updated to use `nss-mdns' but `libnss_mdns' is not in
|
||||
applications' `LD_LIBRARY_PATH'. The next time `/etc/profile' is
|
||||
sourced, it will set up an appropriate `LD_LIBRARY_PATH', though.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
let
|
||||
cfg = config.services.avahi;
|
||||
ifEnable = pkgs.lib.ifEnable cfg.enable;
|
||||
|
||||
inherit (pkgs) avahi writeText lib;
|
||||
|
||||
avahiDaemonConf = with cfg; writeText "avahi-daemon.conf" ''
|
||||
[server]
|
||||
host-name=${hostName}
|
||||
browse-domains=${lib.concatStringsSep ", " browseDomains}
|
||||
@ -16,33 +91,74 @@ let
|
||||
disable-publishing=${if publishing then "no" else "yes"}
|
||||
'';
|
||||
|
||||
user = {
|
||||
name = "avahi";
|
||||
uid = (import ../system/ids.nix).uids.avahi;
|
||||
description = "`avahi-daemon' privilege separation user";
|
||||
home = "/var/empty";
|
||||
};
|
||||
|
||||
group = {
|
||||
name = "avahi";
|
||||
gid = (import ../system/ids.nix).gids.avahi;
|
||||
};
|
||||
|
||||
job = {
|
||||
name = "avahi-daemon";
|
||||
|
||||
job = ''
|
||||
start on network-interfaces/started
|
||||
stop on network-interfaces/stop
|
||||
respawn
|
||||
script
|
||||
export PATH="${avahi}/bin:${avahi}/sbin:$PATH"
|
||||
exec ${avahi}/sbin/avahi-daemon --daemonize -f "${avahiDaemonConf}"
|
||||
end script
|
||||
'';
|
||||
};
|
||||
in
|
||||
|
||||
{
|
||||
name = "avahi-daemon";
|
||||
|
||||
users = [
|
||||
{ name = "avahi";
|
||||
uid = (import ../system/ids.nix).uids.avahi;
|
||||
description = "`avahi-daemon' privilege separation user";
|
||||
home = "/var/empty";
|
||||
}
|
||||
require = [
|
||||
(import ../upstart-jobs/default.nix) # config.services.extraJobs
|
||||
# (import ../system/?) # system.nssModules
|
||||
# (import ?) # config.environment.etc
|
||||
# (import ../system/user.nix) # users.*
|
||||
# (import ../upstart-jobs/udev.nix) # services.udev.*
|
||||
(import ../upstart-jobs/dbus.nix) # services.dbus.*
|
||||
# (import ?) # config.environment.extraPackages
|
||||
options
|
||||
];
|
||||
|
||||
groups = [
|
||||
{ name = "avahi";
|
||||
gid = (import ../system/ids.nix).gids.avahi;
|
||||
}
|
||||
];
|
||||
system = {
|
||||
nssModules = ifEnable (pkgs.lib.optional
|
||||
cfg.nssmdns pkgs.nssmdns
|
||||
);
|
||||
};
|
||||
|
||||
job = ''
|
||||
start on network-interfaces/started
|
||||
stop on network-interfaces/stop
|
||||
respawn
|
||||
script
|
||||
export PATH="${avahi}/bin:${avahi}/sbin:$PATH"
|
||||
exec ${avahi}/sbin/avahi-daemon --daemonize -f "${avahiDaemonConf}"
|
||||
end script
|
||||
'';
|
||||
environment = {
|
||||
extraPackages = ifEnable [avahi];
|
||||
|
||||
}
|
||||
# Name Service Switch configuration file. Required by the C library.
|
||||
etc = [{
|
||||
source = if cfg.nssmdns
|
||||
then (assert cfg.enable; ../etc/nsswitch-mdns.conf)
|
||||
else ../etc/nsswitch.conf;
|
||||
target = "nsswitch.conf";
|
||||
}];
|
||||
};
|
||||
|
||||
users = {
|
||||
extraUsers = ifEnable [user];
|
||||
extraGroups = ifEnable [group];
|
||||
};
|
||||
|
||||
services = {
|
||||
extraJobs = ifEnable [job];
|
||||
|
||||
dbus = {
|
||||
enable = cfg.enable;
|
||||
services = ifEnable [avahi];
|
||||
};
|
||||
};
|
||||
}
|
@ -1,6 +1,40 @@
|
||||
{stdenv, dbus, dbusServices ? []}:
|
||||
# D-Bus system-wide daemon.
|
||||
{pkgs, config}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption;
|
||||
|
||||
options = {
|
||||
services = {
|
||||
dbus = {
|
||||
|
||||
enable = mkOption {
|
||||
default = true;
|
||||
description = "
|
||||
Whether to start the D-Bus message bus daemon. It is required
|
||||
by the HAL service.
|
||||
";
|
||||
merge = pkgs.lib.mergeEnableOption;
|
||||
};
|
||||
|
||||
services = mkOption {
|
||||
default = [];
|
||||
description = ".. fill me ..";
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
let
|
||||
cfg = config.services.dbus;
|
||||
ifEnable = pkgs.lib.ifEnable cfg.enable;
|
||||
services = cfg.services;
|
||||
|
||||
inherit (pkgs) stdenv dbus;
|
||||
|
||||
homeDir = "/var/run/dbus";
|
||||
|
||||
@ -14,49 +48,66 @@ let
|
||||
--replace '<fork/>' ''
|
||||
|
||||
ensureDir $out/system.d
|
||||
for i in ${toString dbusServices}; do
|
||||
for i in ${toString services}; do
|
||||
ln -s $i/etc/dbus-1/system.d/* $out/system.d/
|
||||
done
|
||||
";
|
||||
};
|
||||
|
||||
user = {
|
||||
name = "messagebus";
|
||||
uid = (import ../system/ids.nix).uids.messagebus;
|
||||
description = "D-Bus system message bus daemon user";
|
||||
home = homeDir;
|
||||
};
|
||||
|
||||
job = {
|
||||
name = "dbus";
|
||||
|
||||
job = ''
|
||||
description "D-Bus system message bus daemon"
|
||||
|
||||
start on startup
|
||||
stop on shutdown
|
||||
|
||||
start script
|
||||
|
||||
mkdir -m 0755 -p ${homeDir}
|
||||
chown messagebus ${homeDir}
|
||||
|
||||
mkdir -m 0755 -p /var/lib/dbus
|
||||
${dbus.tools}/bin/dbus-uuidgen --ensure
|
||||
|
||||
end script
|
||||
|
||||
respawn
|
||||
|
||||
script
|
||||
rm -f ${homeDir}/pid
|
||||
exec ${dbus}/bin/dbus-daemon --config-file=${configFile}/system.conf
|
||||
end script
|
||||
'';
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
name = "dbus";
|
||||
|
||||
users = [
|
||||
{ name = "messagebus";
|
||||
uid = (import ../system/ids.nix).uids.messagebus;
|
||||
description = "D-Bus system message bus daemon user";
|
||||
home = homeDir;
|
||||
}
|
||||
require = [
|
||||
(import ../upstart-jobs/default.nix) # config.services.extraJobs
|
||||
# (import ../system/user.nix) # users.*
|
||||
# (import ?) # config.environment.extraPackages
|
||||
options
|
||||
];
|
||||
|
||||
extraPath = [dbus.daemon dbus.tools];
|
||||
|
||||
job = ''
|
||||
description "D-Bus system message bus daemon"
|
||||
|
||||
start on startup
|
||||
stop on shutdown
|
||||
environment = {
|
||||
extraPackages = ifEnable [dbus.daemon dbus.tools];
|
||||
};
|
||||
|
||||
start script
|
||||
users = {
|
||||
extraUsers = ifEnable [user];
|
||||
};
|
||||
|
||||
mkdir -m 0755 -p ${homeDir}
|
||||
chown messagebus ${homeDir}
|
||||
|
||||
mkdir -m 0755 -p /var/lib/dbus
|
||||
${dbus.tools}/bin/dbus-uuidgen --ensure
|
||||
|
||||
end script
|
||||
|
||||
respawn
|
||||
|
||||
script
|
||||
rm -f ${homeDir}/pid
|
||||
exec ${dbus}/bin/dbus-daemon --config-file=${configFile}/system.conf
|
||||
end script
|
||||
'';
|
||||
|
||||
services = {
|
||||
extraJobs = ifEnable [job];
|
||||
};
|
||||
}
|
||||
|
@ -272,13 +272,6 @@ let
|
||||
inherit (pkgs) makePortmap;
|
||||
})
|
||||
|
||||
# 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 {
|
||||
@ -388,18 +381,6 @@ let
|
||||
inherit (pkgs) alsaUtils;
|
||||
})
|
||||
|
||||
# D-Bus system-wide daemon.
|
||||
++ optional config.services.dbus.enable
|
||||
(import ../upstart-jobs/dbus.nix {
|
||||
inherit (pkgs) stdenv dbus;
|
||||
dbusServices =
|
||||
# add config.services.dbus.services
|
||||
pkgs.lib.optional config.services.hal.enable pkgs.hal ++
|
||||
pkgs.lib.optional config.services.avahi.enable pkgs.avahi ++
|
||||
pkgs.lib.optional config.services.disnix.enable pkgs.disnix
|
||||
;
|
||||
})
|
||||
|
||||
# Postfix mail server.
|
||||
++ optional config.services.postfix.enable
|
||||
(import ../upstart-jobs/postfix.nix {
|
||||
|
@ -30,6 +30,7 @@ in
|
||||
###### implementation
|
||||
let
|
||||
cfg = config.services.disnix;
|
||||
ifEnable = pkgs.lib.ifEnable cfg.enable;
|
||||
|
||||
job = {
|
||||
name = "disnix";
|
||||
@ -53,10 +54,16 @@ in
|
||||
{
|
||||
require = [
|
||||
(import ../upstart-jobs/default.nix)
|
||||
(import ../upstart-jobs/dbus.nix) # services.dbus.*
|
||||
options
|
||||
];
|
||||
|
||||
services = {
|
||||
extraJobs = pkgs.lib.optional cfg.enable job;
|
||||
extraJobs = ifEnable [job];
|
||||
|
||||
dbus = {
|
||||
enable = cfg.enable;
|
||||
services = ifEnable [pkgs.disnix];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ in
|
||||
(import ../upstart-jobs/default.nix) # config.services.extraJobs
|
||||
# (import ../system/user.nix) # users.*
|
||||
# (import ../upstart-jobs/udev.nix) # services.udev.*
|
||||
# (import ../upstart-jobs/dbus.nix) # services.dbus.*
|
||||
(import ../upstart-jobs/dbus.nix) # services.dbus.*
|
||||
# (import ?) # config.environment.extraPackages
|
||||
options
|
||||
];
|
||||
@ -89,7 +89,7 @@ in
|
||||
|
||||
dbus = {
|
||||
enable = cfg.enable;
|
||||
# services = ifEnable [hal];
|
||||
services = ifEnable [hal];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user