mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
dbus: Create with pacakges options (#7064)
This adds a module for dbus with only one option, `packages`. The `dbus.packages` options allows users to specify packages to have their dbus service files (from `/share/dbus-1/services`) linked to the users dbus services directory (`$XDG_DATA_HOME/dbus-1/services/`), effectively enabling the services.
This commit is contained in:
parent
954615c510
commit
ad1e8bb782
5 changed files with 62 additions and 0 deletions
36
modules/dbus.nix
Normal file
36
modules/dbus.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.dbus;
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.hm.maintainers.rosuavio ];
|
||||
|
||||
options.dbus = {
|
||||
packages = lib.mkOption {
|
||||
type = with lib.types; types.listOf types.package;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Packages whose D-Bus configuration files should be included in
|
||||
the configuration of the D-Bus session-wide message bus. Specifically,
|
||||
files in «pkg»/share/dbus-1/services will be included in the user's
|
||||
$XDG_DATA_HOME/dbus-1/services directory.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
xdg.dataFile."dbus-1/services" = {
|
||||
recursive = true;
|
||||
source = pkgs.symlinkJoin {
|
||||
name = "user-dbus-services";
|
||||
paths = cfg.packages;
|
||||
stripPrefix = "/share/dbus-1/services";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -490,6 +490,7 @@ let
|
|||
./services/xsuspender.nix
|
||||
./services/yubikey-agent.nix
|
||||
./systemd.nix
|
||||
./dbus.nix
|
||||
./targets/darwin
|
||||
./targets/generic-linux.nix
|
||||
./wayland.nix
|
||||
|
|
|
|||
|
|
@ -502,6 +502,7 @@ import nmtSrc {
|
|||
./modules/services/yubikey-agent
|
||||
./modules/systemd
|
||||
./modules/targets-linux
|
||||
./modules/dbus
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
3
tests/modules/dbus/default.nix
Normal file
3
tests/modules/dbus/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
dbus-packages = ./packages.nix;
|
||||
}
|
||||
21
tests/modules/dbus/packages.nix
Normal file
21
tests/modules/dbus/packages.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{ pkgs, config, ... }:
|
||||
let
|
||||
inherit (config.lib.test) mkStubPackage;
|
||||
in
|
||||
{
|
||||
dbus.packages = [
|
||||
(mkStubPackage {
|
||||
name = "test";
|
||||
buildScript = ''
|
||||
mkdir -p $out/share/dbus-1/services
|
||||
printf '%s' test > $out/share/dbus-1/services/test.service
|
||||
'';
|
||||
})
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
serviceFile=home-files/.local/share/dbus-1/services/test.service
|
||||
assertFileExists $serviceFile
|
||||
assertFileContent $serviceFile "${pkgs.writeText "expected" "test"}"
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue