2023-07-16 20:06:56 -06:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib)
|
|
|
|
mkIf
|
|
|
|
mkOption
|
|
|
|
types
|
|
|
|
;
|
|
|
|
cfg = config.jovian.decky-loader;
|
2024-06-27 12:24:50 +03:00
|
|
|
|
|
|
|
package = cfg.package.overridePythonAttrs(old: {
|
2024-10-01 02:33:44 +02:00
|
|
|
dependencies = old.dependencies ++ (cfg.extraPythonPackages old.passthru.python.pkgs);
|
2024-06-27 12:24:50 +03:00
|
|
|
});
|
2023-07-16 20:06:56 -06:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
jovian = {
|
|
|
|
decky-loader = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-17 08:52:14 +03:00
|
|
|
description = ''
|
2023-07-16 20:06:56 -06:00
|
|
|
Whether to enable the Steam Deck Plugin Loader.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-07-23 14:34:15 -06:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.decky-loader;
|
2023-07-23 14:34:15 -06:00
|
|
|
defaultText = lib.literalExpression "pkgs.decky-loader";
|
2024-04-17 08:52:14 +03:00
|
|
|
description = ''
|
2023-07-23 14:34:15 -06:00
|
|
|
The loader package to use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-07-16 20:06:56 -06:00
|
|
|
extraPackages = mkOption {
|
|
|
|
type = types.listOf types.package;
|
|
|
|
example = lib.literalExpression "[ pkgs.curl pkgs.unzip ]";
|
|
|
|
default = [];
|
2024-04-17 08:52:14 +03:00
|
|
|
description = ''
|
2023-07-16 20:06:56 -06:00
|
|
|
Extra packages to add to the service PATH.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-07-23 14:34:15 -06:00
|
|
|
extraPythonPackages = mkOption {
|
|
|
|
type = types.functionTo (types.listOf types.package);
|
|
|
|
example = lib.literalExpression "pythonPackages: with pythonPackages; [ hid ]";
|
2024-02-03 13:05:34 +03:00
|
|
|
default = _: [];
|
|
|
|
defaultText = lib.literalExpression "pythonPackages: []";
|
2024-04-17 08:52:14 +03:00
|
|
|
description = ''
|
2023-07-23 14:34:15 -06:00
|
|
|
Extra Python packages to add to the PYTHONPATH of the loader.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-07-16 20:06:56 -06:00
|
|
|
stateDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/decky-loader";
|
2024-04-17 08:52:14 +03:00
|
|
|
description = ''
|
2023-07-16 20:06:56 -06:00
|
|
|
Directory to store plugins and data.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "decky";
|
2024-04-17 08:52:14 +03:00
|
|
|
description = ''
|
2023-07-16 20:06:56 -06:00
|
|
|
The user Decky Loader should run plugins as.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable (lib.mkMerge [
|
|
|
|
(lib.mkIf (cfg.user == "decky") {
|
|
|
|
users.users.decky = {
|
|
|
|
group = "decky";
|
|
|
|
home = cfg.stateDir;
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
users.groups.decky = {};
|
|
|
|
})
|
|
|
|
{
|
|
|
|
# As of 2023/07/16, the Decky Loader needs to run as root, even if you never
|
|
|
|
# use plugins that require it. It setuid's to the unprivileged user to
|
|
|
|
# run plugins. Running as non-root is unsupported and currently breaks:
|
|
|
|
#
|
|
|
|
# <https://github.com/SteamDeckHomebrew/decky-loader/issues/446#issuecomment-1637177368>
|
|
|
|
systemd.services.decky-loader = {
|
|
|
|
description = "Steam Deck Plugin Loader";
|
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2024-06-27 12:24:50 +03:00
|
|
|
after = [ "network.target" ];
|
2023-07-16 20:06:56 -06:00
|
|
|
|
2024-06-27 12:24:50 +03:00
|
|
|
environment = {
|
2023-07-16 20:06:56 -06:00
|
|
|
UNPRIVILEGED_USER = cfg.user;
|
|
|
|
UNPRIVILEGED_PATH = cfg.stateDir;
|
|
|
|
PLUGIN_PATH = "${cfg.stateDir}/plugins";
|
|
|
|
};
|
|
|
|
|
2024-06-27 12:24:50 +03:00
|
|
|
path = cfg.extraPackages;
|
2023-07-16 20:06:56 -06:00
|
|
|
|
|
|
|
preStart = ''
|
|
|
|
mkdir -p "${cfg.stateDir}"
|
|
|
|
chown -R "${cfg.user}:" "${cfg.stateDir}"
|
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
2024-06-27 12:24:50 +03:00
|
|
|
ExecStart = "${package}/bin/decky-loader";
|
|
|
|
KillMode = "process";
|
|
|
|
TimeoutStopSec = 45;
|
2023-07-16 20:06:56 -06:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
}
|