nixos/mirakurun: add polkit rule for smart card access (#122066)
Fixes #122039
This commit is contained in:
parent
92a2e684bc
commit
6567031111
|
@ -8,6 +8,18 @@ let
|
||||||
username = config.users.users.mirakurun.name;
|
username = config.users.users.mirakurun.name;
|
||||||
groupname = config.users.users.mirakurun.group;
|
groupname = config.users.users.mirakurun.group;
|
||||||
settingsFmt = pkgs.formats.yaml {};
|
settingsFmt = pkgs.formats.yaml {};
|
||||||
|
|
||||||
|
polkitRule = pkgs.writeTextDir "share/polkit-1/rules.d/10-mirakurun.rules" ''
|
||||||
|
polkit.addRule(function (action, subject) {
|
||||||
|
if (
|
||||||
|
(action.id == "org.debian.pcsc-lite.access_pcsc" ||
|
||||||
|
action.id == "org.debian.pcsc-lite.access_card") &&
|
||||||
|
subject.user == "${username}"
|
||||||
|
) {
|
||||||
|
return polkit.Result.YES;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
@ -48,6 +60,15 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
allowSmartCardAccess = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Install polkit rules to allow Mirakurun to access smart card readers
|
||||||
|
which is commonly used along with tuner devices.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
serverSettings = mkOption {
|
serverSettings = mkOption {
|
||||||
type = settingsFmt.type;
|
type = settingsFmt.type;
|
||||||
default = {};
|
default = {};
|
||||||
|
@ -110,7 +131,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
environment.systemPackages = [ mirakurun ];
|
environment.systemPackages = [ mirakurun ] ++ optional cfg.allowSmartCardAccess polkitRule;
|
||||||
environment.etc = {
|
environment.etc = {
|
||||||
"mirakurun/server.yml".source = settingsFmt.generate "server.yml" cfg.serverSettings;
|
"mirakurun/server.yml".source = settingsFmt.generate "server.yml" cfg.serverSettings;
|
||||||
"mirakurun/tuners.yml" = mkIf (cfg.tunerSettings != null) {
|
"mirakurun/tuners.yml" = mkIf (cfg.tunerSettings != null) {
|
||||||
|
|
Loading…
Reference in a new issue