From fbd485cd86c7e9984819357398f912a2d5510845 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 12 Sep 2023 12:56:39 +0200 Subject: tv: emigrate --- tv/3modules/systemd.nix | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 tv/3modules/systemd.nix (limited to 'tv/3modules/systemd.nix') diff --git a/tv/3modules/systemd.nix b/tv/3modules/systemd.nix deleted file mode 100644 index db8a51994..000000000 --- a/tv/3modules/systemd.nix +++ /dev/null @@ -1,47 +0,0 @@ -with import ./lib; -{ config, ... }: let - normalUsers = filterAttrs (_: getAttr "isNormalUser") config.users.users; -in { - options = { - tv.systemd.services = mkOption { - type = types.attrsOf (types.submodule (self: { - options = { - operators = mkOption { - type = with types; listOf (enum (attrNames normalUsers)); - default = []; - }; - }; - })); - default = {}; - }; - }; - config = { - security.polkit.extraConfig = let - access = - mapAttrs' - (name: cfg: - nameValuePair "${name}.service" - (genAttrs cfg.operators (const true)) - ) - config.tv.systemd.services; - in optionalString (access != {}) /* js */ '' - polkit.addRule(function () { - const access = ${lib.toJSON access}; - return function (action, subject) { - if (action.id === "org.freedesktop.systemd1.manage-units") { - const unit = action.lookup("unit"); - if ( - (access[unit]||{})[subject.user] || - ( - unit.includes("@") && - (access[unit.replace(/@[^.]+/, "@")]||{})[subject.user] - ) - ) { - return polkit.Result.YES; - } - } - } - }()); - ''; - }; -} -- cgit v1.2.3