mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 14:54:29 +01:00
* 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
7 changed files with 209 additions and 188 deletions
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.
|
||||
{pkgs, config, ...}:
|
||||
|
||||
###### interface
|
||||
with pkgs.lib;
|
||||
|
||||
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 = {
|
||||
services = {
|
||||
hal = {
|
||||
|
||||
services.hal = {
|
||||
|
||||
enable = mkOption {
|
||||
default = true;
|
||||
description = "
|
||||
|
@ -22,98 +43,62 @@ let
|
|||
Extend HAL daemon configuration with additionnal paths.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
|
||||
###### implementation
|
||||
let
|
||||
cfg = config.services.hal;
|
||||
inherit (pkgs.lib) mkIf;
|
||||
|
||||
inherit (pkgs) hal;
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
user = {
|
||||
name = "haldaemon";
|
||||
environment.systemPackages = [hal];
|
||||
|
||||
users.extraUsers = singleton
|
||||
{ name = "haldaemon";
|
||||
uid = config.ids.uids.haldaemon;
|
||||
description = "HAL daemon user";
|
||||
};
|
||||
|
||||
group = {
|
||||
name = "haldaemon";
|
||||
users.extraGroups = singleton
|
||||
{ name = "haldaemon";
|
||||
gid = config.ids.gids.haldaemon;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
jobs = singleton
|
||||
{ name = "hal";
|
||||
|
||||
job = {
|
||||
name = "hal";
|
||||
|
||||
job = ''
|
||||
description "HAL daemon"
|
||||
description = "HAL daemon";
|
||||
|
||||
# !!! TODO: make sure that HAL starts after acpid,
|
||||
# otherwise hald-addon-acpi will grab /proc/acpi/event.
|
||||
start on ${if config.powerManagement.enable then "acpid" else "dbus"}
|
||||
stop on shutdown
|
||||
startOn = if config.powerManagement.enable then "acpid" else "dbus";
|
||||
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
|
||||
|
||||
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 {
|
||||
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];
|
||||
exec = "${hal}/sbin/hald --daemon=no";
|
||||
};
|
||||
|
||||
users = {
|
||||
extraUsers = [user];
|
||||
extraGroups = [group];
|
||||
services.udev.addUdevPkgs = [hal];
|
||||
|
||||
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 = {
|
||||
enable = true;
|
||||
services = [pkgs.disnix];
|
||||
packages = [pkgs.disnix];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ mkIf cfg.enable {
|
|||
|
||||
dbus = {
|
||||
enable = true;
|
||||
services = [avahi];
|
||||
packages = [avahi];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -68,7 +68,12 @@ in
|
|||
) 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.
|
||||
${iptables} -A INPUT -j LOG --log-level info --log-prefix "firewall: "
|
||||
${iptables} -A INPUT -j DROP
|
||||
'';
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ mkIf cfg.enable {
|
|||
|
||||
dbus = {
|
||||
enable = true;
|
||||
services = [ConsoleKit];
|
||||
packages = [ConsoleKit];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,76 +1,87 @@
|
|||
# D-Bus system-wide daemon.
|
||||
{pkgs, config, ...}:
|
||||
|
||||
###### interface
|
||||
with pkgs.lib;
|
||||
|
||||
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;
|
||||
services = cfg.services;
|
||||
inherit (pkgs.lib) mkIf;
|
||||
|
||||
inherit (pkgs) stdenv dbus;
|
||||
inherit (pkgs) dbus;
|
||||
|
||||
homeDir = "/var/run/dbus";
|
||||
|
||||
# Take the standard system configuration file, except that we don't
|
||||
# want to fork (Upstart will monitor the daemon).
|
||||
configFile = stdenv.mkDerivation {
|
||||
configFile = pkgs.stdenv.mkDerivation {
|
||||
name = "dbus-conf";
|
||||
buildCommand = "
|
||||
buildCommand = ''
|
||||
ensureDir $out
|
||||
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
|
||||
for i in ${toString services}; do
|
||||
for i in ${toString cfg.packages}; do
|
||||
ln -s $i/etc/dbus-1/system.d/* $out/system.d/
|
||||
done
|
||||
";
|
||||
''; # */
|
||||
};
|
||||
|
||||
user = {
|
||||
name = "messagebus";
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
###### 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;
|
||||
description = "D-Bus system message bus daemon user";
|
||||
home = homeDir;
|
||||
};
|
||||
|
||||
job = {
|
||||
name = "dbus";
|
||||
jobs = singleton
|
||||
{ name = "dbus";
|
||||
|
||||
job = ''
|
||||
description "D-Bus system message bus daemon"
|
||||
|
||||
start on startup
|
||||
stop on shutdown
|
||||
|
||||
start script
|
||||
startOn = "startup";
|
||||
stopOn = "shutdown";
|
||||
|
||||
preStart =
|
||||
''
|
||||
mkdir -m 0755 -p ${homeDir}
|
||||
chown messagebus ${homeDir}
|
||||
|
||||
|
@ -78,39 +89,21 @@ let
|
|||
${dbus.tools}/bin/dbus-uuidgen --ensure
|
||||
|
||||
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
|
||||
end script
|
||||
'';
|
||||
|
||||
respawn sleep 1000000
|
||||
|
||||
stop script
|
||||
postStop =
|
||||
''
|
||||
pid=$(cat ${homeDir}/pid)
|
||||
if test -n "$pid"; then
|
||||
kill -9 $pid
|
||||
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…
Reference in a new issue