Skip to content

Instantly share code, notes, and snippets.

@afreakk
Last active January 13, 2022 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afreakk/1df21c564be3250579b8ed27dda10ad7 to your computer and use it in GitHub Desktop.
Save afreakk/1df21c564be3250579b8ed27dda10ad7 to your computer and use it in GitHub Desktop.
{ config, pkgs, ... }:
let
busName = "nvidia.powerd.server";
userName = "messagebus";
nvidiaBlackHole = pkgs.writeTextFile {
name = "nvidiaBlackHole";
destination = "/etc/dbus-1/system.d/nvidia-fake-powerd.conf";
text = ''
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="${userName}">
<allow own="${busName}"/>
</policy>
<policy context="default">
<allow send_destination="${busName}"/>
<allow receive_sender="${busName}"/>
</policy>
</busconfig>
'';};
in
{
services.dbus.packages = [nvidiaBlackHole];
systemd.services.nvidiaBlackHole = {
wantedBy = [ "default.target" ];
aliases = ["dbus-nvidia.fake-powerd.service"];
serviceConfig = {
Type = "dbus";
BusName = busName;
ExecStart = "${pkgs.dbus}/bin/dbus-test-tool black-hole --system --name=${busName}";
User = userName;
Group = userName;
LimitNPROC=2;
ProtectHome=true;
ProtectSystem="full";
};
};
}
@danyeet
Copy link

danyeet commented Jan 13, 2022

Ah I see - well I misunderstood the assignment haha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment