From 13364f124a83832edc4abb259f03e5d264f70a68 Mon Sep 17 00:00:00 2001 From: Herwig Hochleitner Date: Mon, 9 Oct 2023 00:28:33 +0200 Subject: [PATCH] cdemu: fix service setup closes https://github.com/NixOS/nixpkgs/issues/154613 --- nixos/modules/programs/cdemu.nix | 13 +++++++++++++ pkgs/applications/emulators/cdemu/daemon.nix | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/nixos/modules/programs/cdemu.nix b/nixos/modules/programs/cdemu.nix index d43f009f2f92..7eba4d29d83b 100644 --- a/nixos/modules/programs/cdemu.nix +++ b/nixos/modules/programs/cdemu.nix @@ -53,6 +53,19 @@ in { dbus.packages = [ pkgs.cdemu-daemon ]; }; + users.groups.${config.programs.cdemu.group} = {}; + + # Systemd User service + # manually adapted from example in source package: + # https://sourceforge.net/p/cdemu/code/ci/master/tree/cdemu-daemon/service-example/cdemu-daemon.service + systemd.user.services.cdemu-daemon.description = "CDEmu daemon"; + systemd.user.services.cdemu-daemon.serviceConfig = { + Type = "dbus"; + BusName = "net.sf.cdemu.CDEmuDaemon"; + ExecStart = "${pkgs.cdemu-daemon}/bin/cdemu-daemon --config-file \"%h/.config/cdemu-daemon\""; + Restart = "no"; + }; + environment.systemPackages = [ pkgs.cdemu-daemon pkgs.cdemu-client ] ++ optional cfg.gui pkgs.gcdemu diff --git a/pkgs/applications/emulators/cdemu/daemon.nix b/pkgs/applications/emulators/cdemu/daemon.nix index 5d376955ea66..359b2f26a573 100644 --- a/pkgs/applications/emulators/cdemu/daemon.nix +++ b/pkgs/applications/emulators/cdemu/daemon.nix @@ -1,4 +1,4 @@ -{ callPackage, glib, libao, intltool, libmirage }: +{ callPackage, glib, libao, intltool, libmirage, coreutils }: let pkg = import ./base.nix { version = "3.2.5"; pname = "cdemu-daemon"; @@ -7,4 +7,12 @@ let pkg = import ./base.nix { in callPackage pkg { nativeBuildInputs = [ intltool ]; buildInputs = [ glib libao libmirage ]; + drvParams.postInstall = '' + mkdir -p $out/share/dbus-1/services + cp -R ../$pname-$version/service-example $out/share/cdemu + substitute \ + $out/share/cdemu/net.sf.cdemu.CDEmuDaemon.service \ + $out/share/dbus-1/services/net.sf.cdemu.CDEmuDaemon.service \ + --replace /bin/true ${coreutils}/bin/true + ''; }