From 469070122bde65e3e3f648ae9a1097d38feaf673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Qui=C3=B1ones?= Date: Wed, 20 Aug 2025 12:52:56 -0500 Subject: [PATCH] docs: simplify policy examples with reusable nix functions (#100) --- .github/README.md | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/README.md b/.github/README.md index 9dcf3fb..a8db091 100644 --- a/.github/README.md +++ b/.github/README.md @@ -156,12 +156,14 @@ experiment with other program options and help with further documentation. ```nix { - programs.zen-browser.policies = { - Preferences = { - "browser.tabs.warnOnClose" = { - "Value" = false; - "Status" = "locked"; - }; + programs.zen-browser.policies = let + mkLockedAttrs = builtins.mapAttrs (_: value: { + Value = value; + Status = "locked"; + }); + in { + Preferences = mkLockedAttrs { + "browser.tabs.warnOnClose" = false; # and so on... }; }; @@ -176,18 +178,17 @@ experiment with other program options and help with further documentation. ```nix { - programs.zen-browser.policies = { - ExtensionSettings = { - "wappalyzer@crunchlabz.com" = { - install_url = "https://addons.mozilla.org/firefox/downloads/latest/wappalyzer/latest.xpi"; - installation_mode = "force_installed"; - }; - "{85860b32-02a8-431a-b2b1-40fbd64c9c69}" = { - install_url = "https://addons.mozilla.org/firefox/downloads/latest/github-file-icons/latest.xpi"; - installation_mode = "force_installed"; - }; + programs.zen-browser.policies = let + mkExtensionSettings = builtins.mapAttrs (_: pluginId: { + install_url = "https://addons.mozilla.org/firefox/downloads/latest/${pluginId}/latest.xpi"; + installation_mode = "force_installed"; + }); + in { + ExtensionSettings = mkExtensionSettings { + "wappalyzer@crunchlabz.com" = "wappalyzer"; + "{85860b32-02a8-431a-b2b1-40fbd64c9c69}" = "github-file-icons"; }; - } + }; } ```