summary refs log tree commit diff
diff options
context:
space:
mode:
authormidchildan <git@midchildan.org>2021-05-13 02:57:49 +0900
committerGitHub <noreply@github.com>2021-05-12 13:57:49 -0400
commit65670311112f09f8e36b5ec714de0c222e61a09f (patch)
tree11b50891719f5db7046c3626adc837d88a9abb19
parent92a2e684bc30f713651d1caca51f307dcdfc37d1 (diff)
downloadnixpkgs-65670311112f09f8e36b5ec714de0c222e61a09f.tar
nixpkgs-65670311112f09f8e36b5ec714de0c222e61a09f.tar.gz
nixpkgs-65670311112f09f8e36b5ec714de0c222e61a09f.tar.bz2
nixpkgs-65670311112f09f8e36b5ec714de0c222e61a09f.tar.lz
nixpkgs-65670311112f09f8e36b5ec714de0c222e61a09f.tar.xz
nixpkgs-65670311112f09f8e36b5ec714de0c222e61a09f.tar.zst
nixpkgs-65670311112f09f8e36b5ec714de0c222e61a09f.zip
nixos/mirakurun: add polkit rule for smart card access (#122066)
Fixes #122039
-rw-r--r--nixos/modules/services/video/mirakurun.nix23
1 files changed, 22 insertions, 1 deletions
diff --git a/nixos/modules/services/video/mirakurun.nix b/nixos/modules/services/video/mirakurun.nix
index ce1dabe6bfa..6ea73fa5c67 100644
--- a/nixos/modules/services/video/mirakurun.nix
+++ b/nixos/modules/services/video/mirakurun.nix
@@ -8,6 +8,18 @@ let
   username = config.users.users.mirakurun.name;
   groupname = config.users.users.mirakurun.group;
   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
   {
     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 {
           type = settingsFmt.type;
           default = {};
@@ -110,7 +131,7 @@ in
     };
 
     config = mkIf cfg.enable {
-      environment.systemPackages = [ mirakurun ];
+      environment.systemPackages = [ mirakurun ] ++ optional cfg.allowSmartCardAccess polkitRule;
       environment.etc = {
         "mirakurun/server.yml".source = settingsFmt.generate "server.yml" cfg.serverSettings;
         "mirakurun/tuners.yml" = mkIf (cfg.tunerSettings != null) {