1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-31 04:04:45 +00:00
nix-darwin/modules/services/mopidy.nix
Emily 56d8208c45 launchd: move userLaunchd to system activation
I’m not *completely* certain that this handles user agents
correctly. There is a deprecated command, `launchctl asuser`, that
executes a command in the Mach bootstrap context of another user`.
<https://scriptingosx.com/2020/08/running-a-command-as-another-user/>
claims that this is required when loading and unloading user agents,
but I haven’t tested this. Our current launchd agent logic is pretty
weird and broken already anyway, so unless this actively regresses
things I’d lean towards keeping it like this until we can move
over entirely to `launchctl bootstrap`/`launchctl kickstart`, which
aren’t deprecated and can address individual users directly. Someone
should definitely test it more extensively than I have, though.
2025-03-23 11:13:48 +00:00

56 lines
1.5 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.mopidy;
in
{
options = {
services.mopidy.enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable the Mopidy Daemon.";
};
services.mopidy.package = mkOption {
type = types.path;
default = pkgs.mopidy;
defaultText = "pkgs.mopidy";
description = "This option specifies the mopidy package to use.";
};
services.mopidy.mediakeys.enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable the Mopidy OSX Media Keys support daemon.";
};
services.mopidy.mediakeys.package = mkOption {
type = types.path;
default = pkgs.pythonPackages.osxmpdkeys;
defaultText = "pkgs.pythonPackages.osxmpdkeys";
description = "This option specifies the mediakeys package to use.";
};
};
config = mkMerge [
(mkIf cfg.enable {
launchd.user.agents.mopidy = {
serviceConfig.Program = "${cfg.package}/bin/mopidy";
serviceConfig.RunAtLoad = true;
serviceConfig.KeepAlive = true;
managedBy = "services.mopidy.enable";
};
})
(mkIf cfg.mediakeys.enable {
launchd.user.agents.mopidymediakeys = {
serviceConfig.Program = "${cfg.package}/bin/mpdkeys";
serviceConfig.RunAtLoad = true;
serviceConfig.KeepAlive = true;
managedBy = "services.mopidy.mediakeys.enable";
};
})
];
}