This repository has been archived on 2024-07-03. You can view files and clone it, but cannot push or open issues or pull requests.
home-manager/programs/browser/nyxt.nix
Evie Litherland-Smith a9c96b8a06 Add NYXT bookmark converter, renable NYXT browser
Add converter to read bookmarks.json and convert to lisp format
expected by NYXT

Enable NYXT again (as well as firefox) now that bookmarks are
available

Swap accent and alt accent (with each other)
2024-06-28 08:40:56 +01:00

67 lines
2.7 KiB
Nix

{
config,
pkgs,
fonts,
accentColourName,
altAccentColourName,
...
}: {
home.packages = [pkgs.nyxt];
xdg = {
configFile = {
"nyxt/config.lisp".text = let
sc = config.scheme.withHashtag;
in ''
;; Import custom configuration
(nyxt::load-lisp "${./config.lisp}")
;; Define custom theme
(define-configuration browser
((theme (make-instance 'theme:theme
:dark-p t
:font-family "${fonts.sansSerif.name}"
:monospace-font-family "${fonts.monospace.name}"
:background-color "${sc.base00}"
:on-background-color "${sc.base05}"
:primary-color "${sc.${accentColourName}}"
:on-primary-color "${sc.base01}"
:secondary-color "${sc.base03}"
:on-secondary-color "${sc.base05}"
:accent-color "${sc.${altAccentColourName}}"
:on-accent-color "${sc.base01}"
:action-color "${sc.cyan}"
:on-action-color "${sc.base01}"
:success-color "${sc.green}"
:on-success-color "${sc.base01}"
:highlight-color "${sc.magenta}"
:on-highlight-color "${sc.base01}"
:warning-color "${sc.yellow}"
:on-warning-color "${sc.base01}"
:codeblock-color "${sc.base02}"
:on-codeblock-color "${sc.base05}"))))
'';
};
dataFile."nyxt/bookmarks.lisp".text = let
# Make a string of lisp-style list of strings, from nix-style
# list
convertTags = tags: "(" + (builtins.foldl' (x: y: x + " \"" + y + "\"") "" tags) + " )";
# Take bookmarks as returned from JSON file and convert to NYXT
# expected format
convertBookmark = {
name,
tags,
url,
}: "(:url \"${url}\" :title \"${name}\" :tags ${convertTags tags})\n";
in (
# Fold all entries in bookmarks.json into single string of NYXT
# format bookmarks, each entry on a new line and with 2 space
# indentation, just for visual clarity if reading the outputted
# file
"(\n"
+ (builtins.foldl'
(x: y: x + " " + convertBookmark y) ""
(builtins.fromJSON (builtins.readFile ./bookmarks.json)))
+ ")"
);
};
}