1
0
Fork 0
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:
Rosario Pulella 2025-05-15 13:59:12 -04:00 committed by GitHub
parent 954615c510
commit ad1e8bb782
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 62 additions and 0 deletions

36
modules/dbus.nix Normal file
View 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";
};
};
};
}

View file

@ -490,6 +490,7 @@ let
./services/xsuspender.nix
./services/yubikey-agent.nix
./systemd.nix
./dbus.nix
./targets/darwin
./targets/generic-linux.nix
./wayland.nix

View file

@ -502,6 +502,7 @@ import nmtSrc {
./modules/services/yubikey-agent
./modules/systemd
./modules/targets-linux
./modules/dbus
]
);
}

View file

@ -0,0 +1,3 @@
{
dbus-packages = ./packages.nix;
}

View 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"}"
'';
}