{ config, lib, pkgs, ... }: let cfg = config.services.qseecom-supplicant; in { options.services.qseecom-supplicant = { enable = lib.mkEnableOption "the listeners for Qualcomm QSEE trusted apps, for the QSEECOM TEE driver"; package = lib.mkOption { type = lib.types.package; default = pkgs.callPackage ./package.nix { }; defaultText = lib.literalMD "qseecom-supplicant from this flake"; description = "The qseecom-supplicant package."; }; root = lib.mkOption { type = lib.types.str; default = "/var/lib/qseecom"; description = '' The directory the apps' Android paths are served from, where they keep their data. Under /var/lib, it's the service's state directory. ''; }; firmwareDirectory = lib.mkOption { type = lib.types.str; default = "/run/current-system/firmware"; description = "Where the apps to load are, as `.mdt` and its `.bNN` segments."; }; apps = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ ]; example = [ "gfp9508" ]; description = '' The apps to load and keep loaded. Apps the firmware loads itself, like keymaster64, don't go here, but are served all the same. ''; }; }; config = lib.mkIf cfg.enable { systemd.services.qseecom-supplicant = { description = "Listeners for QSEE trusted apps"; wantedBy = [ "multi-user.target" ]; # Its devices come with modules loaded as they're found, so it keeps # trying until they're all there startLimitIntervalSec = 0; serviceConfig = { ExecStart = lib.escapeShellArgs ( [ (lib.getExe cfg.package) cfg.root cfg.firmwareDirectory ] ++ cfg.apps ); StateDirectory = lib.mkIf (lib.hasPrefix "/var/lib/" cfg.root) ( lib.removePrefix "/var/lib/" cfg.root ); StateDirectoryMode = "0700"; Restart = "on-failure"; RestartSec = 5; }; }; }; }