* Added a module for the bluetooth daemon.
* Refactored some other modules (dbus, hal). svn path=/nixos/trunk/; revision=16652
This commit is contained in:
parent
0ab6be1c81
commit
2331a5140d
38
modules/services/hardware/bluetooth.nix
Normal file
38
modules/services/hardware/bluetooth.nix
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
|
with pkgs.lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
|
||||||
|
options = {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
|
config = {
|
||||||
|
|
||||||
|
jobs = pkgs.lib.singleton
|
||||||
|
{ name = "bluetoothd";
|
||||||
|
|
||||||
|
startOn = "dbus";
|
||||||
|
stopOn = "dbus";
|
||||||
|
|
||||||
|
preStart =
|
||||||
|
''
|
||||||
|
mkdir -m 0755 -p /var/lib/bluetooth
|
||||||
|
'';
|
||||||
|
|
||||||
|
exec = "${pkgs.bluez}/sbin/bluetoothd --nodaemon --debug";
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.systemPackages = [pkgs.bluez pkgs.openobex pkgs.obexftp];
|
||||||
|
|
||||||
|
services.dbus.enable = true;
|
||||||
|
services.dbus.packages = [pkgs.bluez];
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -1,13 +1,34 @@
|
|||||||
# HAL daemon.
|
# HAL daemon.
|
||||||
{pkgs, config, ...}:
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
###### interface
|
with pkgs.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (pkgs.lib) mkOption;
|
|
||||||
|
cfg = config.services.hal;
|
||||||
|
|
||||||
|
inherit (pkgs) hal;
|
||||||
|
|
||||||
|
fdi =
|
||||||
|
if cfg.extraFdi == [] then
|
||||||
|
"${hal}/share/hal/fdi"
|
||||||
|
else
|
||||||
|
pkgs.buildEnv {
|
||||||
|
name = "hal-fdi";
|
||||||
|
pathsToLink = [ "/preprobe" "/information" "/policy" ];
|
||||||
|
paths = [ "${hal}/share/hal/fdi" ] ++ cfg.extraFdi;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
services = {
|
|
||||||
hal = {
|
services.hal = {
|
||||||
|
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
default = true;
|
default = true;
|
||||||
description = "
|
description = "
|
||||||
@ -22,98 +43,62 @@ let
|
|||||||
Extend HAL daemon configuration with additionnal paths.
|
Extend HAL daemon configuration with additionnal paths.
|
||||||
";
|
";
|
||||||
};
|
};
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
|
|
||||||
###### implementation
|
};
|
||||||
let
|
|
||||||
cfg = config.services.hal;
|
|
||||||
inherit (pkgs.lib) mkIf;
|
|
||||||
|
|
||||||
inherit (pkgs) hal;
|
};
|
||||||
|
|
||||||
user = {
|
|
||||||
name = "haldaemon";
|
###### implementation
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
environment.systemPackages = [hal];
|
||||||
|
|
||||||
|
users.extraUsers = singleton
|
||||||
|
{ name = "haldaemon";
|
||||||
uid = config.ids.uids.haldaemon;
|
uid = config.ids.uids.haldaemon;
|
||||||
description = "HAL daemon user";
|
description = "HAL daemon user";
|
||||||
};
|
};
|
||||||
|
|
||||||
group = {
|
users.extraGroups = singleton
|
||||||
name = "haldaemon";
|
{ name = "haldaemon";
|
||||||
gid = config.ids.gids.haldaemon;
|
gid = config.ids.gids.haldaemon;
|
||||||
};
|
};
|
||||||
|
|
||||||
fdi =
|
jobs = singleton
|
||||||
if cfg.extraFdi == [] then
|
{ name = "hal";
|
||||||
hal + "/share/hal/fdi"
|
|
||||||
else
|
|
||||||
pkgs.buildEnv {
|
|
||||||
name = "hal-fdi";
|
|
||||||
pathsToLink = [ "/preprobe" "/information" "/policy" ];
|
|
||||||
paths = [ (hal + "/share/hal/fdi") ] ++ cfg.extraFdi;
|
|
||||||
};
|
|
||||||
|
|
||||||
job = {
|
description = "HAL daemon";
|
||||||
name = "hal";
|
|
||||||
|
|
||||||
job = ''
|
|
||||||
description "HAL daemon"
|
|
||||||
|
|
||||||
# !!! TODO: make sure that HAL starts after acpid,
|
# !!! TODO: make sure that HAL starts after acpid,
|
||||||
# otherwise hald-addon-acpi will grab /proc/acpi/event.
|
# otherwise hald-addon-acpi will grab /proc/acpi/event.
|
||||||
start on ${if config.powerManagement.enable then "acpid" else "dbus"}
|
startOn = if config.powerManagement.enable then "acpid" else "dbus";
|
||||||
stop on shutdown
|
stopOn = "shutdown";
|
||||||
|
|
||||||
start script
|
# !!! HACK? These environment variables manipulated inside
|
||||||
|
# 'src'/hald/mmap_cache.c are used for testing the daemon
|
||||||
|
environment =
|
||||||
|
{ HAL_FDI_SOURCE_PREPROBE = "${fdi}/preprobe";
|
||||||
|
HAL_FDI_SOURCE_INFORMATION = "${fdi}/information";
|
||||||
|
HAL_FDI_SOURCE_POLICY = "${fdi}/policy";
|
||||||
|
};
|
||||||
|
|
||||||
|
preStart =
|
||||||
|
''
|
||||||
mkdir -m 0755 -p /var/cache/hald
|
mkdir -m 0755 -p /var/cache/hald
|
||||||
|
|
||||||
rm -f /var/cache/hald/fdi-cache
|
rm -f /var/cache/hald/fdi-cache
|
||||||
|
|
||||||
end script
|
|
||||||
|
|
||||||
# HACK ? These environment variables manipulated inside
|
|
||||||
# 'src'/hald/mmap_cache.c are used for testing the daemon
|
|
||||||
env HAL_FDI_SOURCE_PREPROBE=${fdi}/preprobe
|
|
||||||
env HAL_FDI_SOURCE_INFORMATION=${fdi}/information
|
|
||||||
env HAL_FDI_SOURCE_POLICY=${fdi}/policy
|
|
||||||
|
|
||||||
respawn ${hal}/sbin/hald --daemon=no
|
|
||||||
'';
|
'';
|
||||||
};
|
|
||||||
in
|
|
||||||
|
|
||||||
mkIf cfg.enable {
|
exec = "${hal}/sbin/hald --daemon=no";
|
||||||
require = [
|
|
||||||
# ../upstart-jobs/default.nix # config.services.extraJobs
|
|
||||||
# ../system/user.nix # users.*
|
|
||||||
# ../upstart-jobs/udev.nix # services.udev.*
|
|
||||||
# ../upstart-jobs/dbus.nix # services.dbus.*
|
|
||||||
# ? # config.environment.extraPackages
|
|
||||||
options
|
|
||||||
];
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
extraPackages = [hal];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
users = {
|
services.udev.addUdevPkgs = [hal];
|
||||||
extraUsers = [user];
|
|
||||||
extraGroups = [group];
|
services.dbus.enable = true;
|
||||||
|
services.dbus.packages = [hal];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
|
||||||
extraJobs = [job];
|
|
||||||
|
|
||||||
udev = {
|
|
||||||
addUdevPkgs = [hal];
|
|
||||||
};
|
|
||||||
|
|
||||||
dbus = {
|
|
||||||
enable = true;
|
|
||||||
services = [hal];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
@ -58,7 +58,7 @@ mkIf cfg.enable {
|
|||||||
|
|
||||||
dbus = {
|
dbus = {
|
||||||
enable = true;
|
enable = true;
|
||||||
services = [pkgs.disnix];
|
packages = [pkgs.disnix];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ mkIf cfg.enable {
|
|||||||
|
|
||||||
dbus = {
|
dbus = {
|
||||||
enable = true;
|
enable = true;
|
||||||
services = [avahi];
|
packages = [avahi];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,12 @@ in
|
|||||||
) config.networking.firewall.allowedTCPPorts
|
) config.networking.firewall.allowedTCPPorts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Accept multicast. Not a big security risk since
|
||||||
|
# probably nobody is listening anyway.
|
||||||
|
${iptables} -A INPUT -d 224.0.0.0/4 -j ACCEPT
|
||||||
|
|
||||||
# Drop everything else.
|
# Drop everything else.
|
||||||
|
${iptables} -A INPUT -j LOG --log-level info --log-prefix "firewall: "
|
||||||
${iptables} -A INPUT -j DROP
|
${iptables} -A INPUT -j DROP
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ mkIf cfg.enable {
|
|||||||
|
|
||||||
dbus = {
|
dbus = {
|
||||||
enable = true;
|
enable = true;
|
||||||
services = [ConsoleKit];
|
packages = [ConsoleKit];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,76 +1,87 @@
|
|||||||
# D-Bus system-wide daemon.
|
# D-Bus system-wide daemon.
|
||||||
{pkgs, config, ...}:
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
###### interface
|
with pkgs.lib;
|
||||||
|
|
||||||
let
|
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;
|
cfg = config.services.dbus;
|
||||||
services = cfg.services;
|
|
||||||
inherit (pkgs.lib) mkIf;
|
|
||||||
|
|
||||||
inherit (pkgs) stdenv dbus;
|
inherit (pkgs) dbus;
|
||||||
|
|
||||||
homeDir = "/var/run/dbus";
|
homeDir = "/var/run/dbus";
|
||||||
|
|
||||||
# Take the standard system configuration file, except that we don't
|
configFile = pkgs.stdenv.mkDerivation {
|
||||||
# want to fork (Upstart will monitor the daemon).
|
|
||||||
configFile = stdenv.mkDerivation {
|
|
||||||
name = "dbus-conf";
|
name = "dbus-conf";
|
||||||
buildCommand = "
|
buildCommand = ''
|
||||||
ensureDir $out
|
ensureDir $out
|
||||||
ln -s ${dbus}/etc/dbus-1/system.conf $out/system.conf
|
ln -s ${dbus}/etc/dbus-1/system.conf $out/system.conf
|
||||||
|
|
||||||
|
# Note: system.conf includes ./system.d (i.e. it has a relative,
|
||||||
|
# not absolute path).
|
||||||
ensureDir $out/system.d
|
ensureDir $out/system.d
|
||||||
for i in ${toString services}; do
|
for i in ${toString cfg.packages}; do
|
||||||
ln -s $i/etc/dbus-1/system.d/* $out/system.d/
|
ln -s $i/etc/dbus-1/system.d/* $out/system.d/
|
||||||
done
|
done
|
||||||
";
|
''; # */
|
||||||
};
|
};
|
||||||
|
|
||||||
user = {
|
in
|
||||||
name = "messagebus";
|
|
||||||
|
{
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
|
||||||
|
options = {
|
||||||
|
|
||||||
|
services.dbus = {
|
||||||
|
|
||||||
|
enable = mkOption {
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Whether to start the D-Bus message bus daemon, which is
|
||||||
|
required by many other system services and applications.
|
||||||
|
'';
|
||||||
|
merge = pkgs.lib.mergeEnableOption;
|
||||||
|
};
|
||||||
|
|
||||||
|
packages = mkOption {
|
||||||
|
default = [];
|
||||||
|
description = ''
|
||||||
|
Packages whose D-Bus configuration files should be included in
|
||||||
|
the configuration of the D-Bus system-wide message bus.
|
||||||
|
Specifically, every file in
|
||||||
|
<filename><replaceable>pkg</replaceable>/etc/dbus-1/system.d</filename>
|
||||||
|
is included.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
environment.systemPackages = [dbus.daemon dbus.tools];
|
||||||
|
|
||||||
|
users.extraUsers = singleton
|
||||||
|
{ name = "messagebus";
|
||||||
uid = config.ids.uids.messagebus;
|
uid = config.ids.uids.messagebus;
|
||||||
description = "D-Bus system message bus daemon user";
|
description = "D-Bus system message bus daemon user";
|
||||||
home = homeDir;
|
home = homeDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
job = {
|
jobs = singleton
|
||||||
name = "dbus";
|
{ name = "dbus";
|
||||||
|
|
||||||
job = ''
|
startOn = "startup";
|
||||||
description "D-Bus system message bus daemon"
|
stopOn = "shutdown";
|
||||||
|
|
||||||
start on startup
|
|
||||||
stop on shutdown
|
|
||||||
|
|
||||||
start script
|
|
||||||
|
|
||||||
|
preStart =
|
||||||
|
''
|
||||||
mkdir -m 0755 -p ${homeDir}
|
mkdir -m 0755 -p ${homeDir}
|
||||||
chown messagebus ${homeDir}
|
chown messagebus ${homeDir}
|
||||||
|
|
||||||
@ -78,39 +89,21 @@ let
|
|||||||
${dbus.tools}/bin/dbus-uuidgen --ensure
|
${dbus.tools}/bin/dbus-uuidgen --ensure
|
||||||
|
|
||||||
rm -f ${homeDir}/pid
|
rm -f ${homeDir}/pid
|
||||||
|
# !!! hack - dbus should be running once this job is
|
||||||
|
# considered "running"; should be fixable once we have
|
||||||
|
# Upstart 0.6.
|
||||||
${dbus}/bin/dbus-daemon --config-file=${configFile}/system.conf
|
${dbus}/bin/dbus-daemon --config-file=${configFile}/system.conf
|
||||||
end script
|
'';
|
||||||
|
|
||||||
respawn sleep 1000000
|
postStop =
|
||||||
|
''
|
||||||
stop script
|
|
||||||
pid=$(cat ${homeDir}/pid)
|
pid=$(cat ${homeDir}/pid)
|
||||||
if test -n "$pid"; then
|
if test -n "$pid"; then
|
||||||
kill -9 $pid
|
kill -9 $pid
|
||||||
fi
|
fi
|
||||||
end script
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
mkIf cfg.enable {
|
|
||||||
require = [
|
|
||||||
# ../upstart-jobs/default.nix # config.services.extraJobs
|
|
||||||
# ../system/user.nix # users.*
|
|
||||||
# ? # config.environment.extraPackages
|
|
||||||
options
|
|
||||||
];
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
extraPackages = [dbus.daemon dbus.tools];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
users = {
|
|
||||||
extraUsers = [user];
|
|
||||||
};
|
|
||||||
|
|
||||||
services = {
|
|
||||||
extraJobs = [job];
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user