Created
November 10, 2024 01:16
-
-
Save harryaskham/15b4a13a98b12a469527e92b644589b7 to your computer and use it in GitHub Desktop.
nix-on-droid minimal dbus module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, lib, pkgs, ...}: | |
# Cut from https://raw.githubusercontent.com/NixOS/nixpkgs/refs/heads/master/nixos/modules/services/system/dbus.nix | |
let | |
cfg = config.dbus; | |
dbus-start-bin = "dbus-start"; | |
dbus-start = pkgs.writeScriptBin dbus-start-bin '' | |
#!${pkgs.runtimeShell} | |
${pkgs.dbus}/bin/dbus-daemon --session & | |
''; | |
inherit (lib) mkOption mkEnableOption mkIf mkMerge types; | |
in | |
{ | |
options.dbus = { | |
enable = mkEnableOption | |
'' | |
Whether to start the D-Bus message bus daemon, which is | |
required by many other system services and applications. | |
''; | |
packages = mkOption { | |
type = types.listOf types.path; | |
default = [ ]; | |
description = '' | |
Packages whose D-Bus configuration files should be included in | |
the configuration of the D-Bus system-wide or session-wide | |
message bus. | |
''; | |
}; | |
}; | |
config = mkIf cfg.enable (mkMerge [ | |
{ | |
environment.etc."dbus-1".source = pkgs.makeDBusConf { | |
suidHelper = "/bin/false"; | |
serviceDirectories = cfg.packages; | |
}; | |
environment.packages = [ | |
dbus-start | |
pkgs.dbus | |
]; | |
build.activationAfter.dbus = '' | |
DBUS_PID=$(${pkgs.procps}/bin/ps -a | ${pkgs.toybox}/bin/grep dbus || true) | |
if [ -z "$DBUS_PID" ]; then | |
$DRY_RUN_CMD ${dbus-start}/bin/${dbus-start-bin} | |
fi | |
''; | |
} | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment