nix: implement new dbus options in nixos module
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
parent
cdc08817a7
commit
3a46f032ca
40
nixos.nix
40
nixos.nix
|
@ -63,6 +63,35 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dbus = {
|
||||||
|
config = mkOption {
|
||||||
|
type = nullOr anything;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
D-Bus custom configuration.
|
||||||
|
Setting this to null will enable built-in defaults.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
id = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
D-Bus application id.
|
||||||
|
Setting this to null will disable own path in defaults.
|
||||||
|
Has no effect if custom configuration is set.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
mpris = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether to enable MPRIS in D-Bus defaults.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
capability = {
|
capability = {
|
||||||
wayland = mkOption {
|
wayland = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
|
@ -82,7 +111,7 @@ in
|
||||||
|
|
||||||
dbus = mkOption {
|
dbus = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = false;
|
default = true;
|
||||||
description = ''
|
description = ''
|
||||||
Whether to proxy D-Bus.
|
Whether to proxy D-Bus.
|
||||||
'';
|
'';
|
||||||
|
@ -193,15 +222,20 @@ in
|
||||||
with launcher.capability;
|
with launcher.capability;
|
||||||
let
|
let
|
||||||
command = if launcher.command == null then name else launcher.command;
|
command = if launcher.command == null then name else launcher.command;
|
||||||
|
dbusConfig = pkgs.writeText "${name}-dbus.json" (builtins.toJSON dbus.config);
|
||||||
|
inherit (launcher) dbus method;
|
||||||
capArgs =
|
capArgs =
|
||||||
(if wayland then " -wayland" else "")
|
(if wayland then " -wayland" else "")
|
||||||
+ (if x11 then " -X" else "")
|
+ (if x11 then " -X" else "")
|
||||||
+ (if dbus then " -dbus" else "")
|
+ (if dbus then " -dbus" else "")
|
||||||
+ (if pulse then " -pulse" else "")
|
+ (if pulse then " -pulse" else "")
|
||||||
+ (if launcher.method == "fortify-sudo" then " -sudo" else "");
|
+ (if dbus.mpris then " -mpris" else "")
|
||||||
|
+ (if dbus.id != null then " -dbus-id ${dbus.id}" else "")
|
||||||
|
+ (if dbus.config != null then " -dbus-config ${dbusConfig}" else "")
|
||||||
|
+ (if method == "fortify-sudo" then " -sudo" else "");
|
||||||
in
|
in
|
||||||
pkgs.writeShellScriptBin name (
|
pkgs.writeShellScriptBin name (
|
||||||
if launcher.method == "sudo" then
|
if method == "sudo" then
|
||||||
''
|
''
|
||||||
exec sudo -u ${user} -i ${command} $@
|
exec sudo -u ${user} -i ${command} $@
|
||||||
''
|
''
|
||||||
|
|
Loading…
Reference in New Issue