From 27a254a27df47cac88ce8053b4efe575cf9c481e Mon Sep 17 00:00:00 2001 From: Soispha Date: Sat, 21 Oct 2023 22:30:59 +0200 Subject: feat(hm/conf/firefox): Use the policy.json file for configs --- .../conf/firefox/config/bookmarks/default.nix | 46 ++++++++++++-------- hm/soispha/conf/firefox/config/bookmarks/lib.nix | 49 ++++++++++++++++++++++ 2 files changed, 77 insertions(+), 18 deletions(-) create mode 100644 hm/soispha/conf/firefox/config/bookmarks/lib.nix (limited to 'hm/soispha/conf/firefox/config/bookmarks') diff --git a/hm/soispha/conf/firefox/config/bookmarks/default.nix b/hm/soispha/conf/firefox/config/bookmarks/default.nix index 8315cffd..c612bf4d 100644 --- a/hm/soispha/conf/firefox/config/bookmarks/default.nix +++ b/hm/soispha/conf/firefox/config/bookmarks/default.nix @@ -1,21 +1,31 @@ -[ - { - name = "Feed - Piped"; - url = "https://piped.video/feed"; - } +{ + lib, + pkgs, + ... +}: let + bookmarks = [ + { + name = "Feed - Piped"; + url = "https://piped.video/feed"; + } - { - name = "DeepL Translate"; - url = "https://www.deepl.com/translator"; - } + { + name = "DeepL Translate"; + url = "https://www.deepl.com/translator"; + } - { - name = "Nix lib"; - url = "https://teu5us.github.io/nix-lib.html"; - } + { + name = "Nix lib"; + url = "https://teu5us.github.io/nix-lib.html"; + } - { - name = "Nixpkgs manual"; - url = "https://ryantm.github.io/nixpkgs/"; - } -] + { + name = "Nixpkgs manual"; + url = "https://ryantm.github.io/nixpkgs/"; + } + ]; + + mkBookmarksFile = (import ./lib.nix) {inherit lib pkgs;}; + bookmarks_file = mkBookmarksFile bookmarks; +in + bookmarks_file diff --git a/hm/soispha/conf/firefox/config/bookmarks/lib.nix b/hm/soispha/conf/firefox/config/bookmarks/lib.nix new file mode 100644 index 00000000..d1d89dd2 --- /dev/null +++ b/hm/soispha/conf/firefox/config/bookmarks/lib.nix @@ -0,0 +1,49 @@ +{ + lib, + pkgs, +}: bookmarks: let + indent = level: + lib.concatStringsSep "" (map (lib.const " ") (lib.range 1 level)); + + bookmarkToHTML = indentLevel: bookmark: '' + ${indent indentLevel}
${lib.escapeXML bookmark.name}''; + + directoryToHTML = indentLevel: directory: '' + ${indent indentLevel}
${ + if directory.toolbar + then ''

Bookmarks Toolbar'' + else "

${lib.escapeXML directory.name}" + }

+ ${indent indentLevel}

+ ${allItemsToHTML (indentLevel + 1) directory.bookmarks} + ${indent indentLevel}

''; + + itemToHTMLOrRecurse = indentLevel: item: + if item ? "url" + then bookmarkToHTML indentLevel item + else directoryToHTML indentLevel item; + + allItemsToHTML = indentLevel: bookmarks: + lib.concatStringsSep "\n" + (map (itemToHTMLOrRecurse indentLevel) bookmarks); + + bookmarkEntries = allItemsToHTML 1 bookmarks; +in + pkgs.writeText "firefox-bookmarks.html" '' + + + + Bookmarks +

Bookmarks Menu

+ +

+

Bookmarks Toolbar

+

+ ${bookmarkEntries} +

+

+ '' -- cgit 1.4.1