nixos/system/home/browser/nyxt.nix

79 lines
3.6 KiB
Nix
Raw Normal View History

{ config, pkgs, ... }:
2024-07-30 15:06:34 +01:00
{
home.packages = [ pkgs.nyxt ];
xdg = {
configFile = {
2024-07-30 15:06:34 +01:00
"nyxt/config.lisp".text =
let
inherit (config.lib.stylix.scheme) variant;
fonts = config.stylix.fonts;
scheme = config.lib.stylix.scheme.withHashtag;
accent = scheme.base0E;
2024-07-30 15:06:34 +01:00
in
''
;; Import custom configuration
(nyxt::load-lisp "${./config.lisp}")
;; Set theme variant from GTK_THEME if available
(setf (uiop/os:getenv "GTK_THEME") "Adwaita:${variant}")
2024-07-30 15:06:34 +01:00
;; Define custom theme
(define-configuration browser
((theme (make-instance 'theme:theme
:dark-p ${if variant == "light" then "nil" else "t"}
2024-07-30 15:06:34 +01:00
:font-family "${fonts.sansSerif.name}"
:monospace-font-family "${fonts.monospace.name}"
:text-color "${scheme.base05}"
:contrast-text-color "${scheme.base01}"
:background-color "${scheme.base00}"
:primary-color "${scheme.base02}"
:secondary-color "${scheme.base03}"
:tertiary-color "${scheme.base04}"
:quaternary-color "${scheme.base04}"
:accent-color "${scheme.base0E}"
:action-color "${scheme.cyan}"
:success-color "${scheme.green}"
:warning-color "${scheme.yellow}"
:highlight-color "${scheme.base01}"
:codeblock-color "${scheme.base01}"
;; :on-background-color "${scheme.base05}"
;; :on-primary-color "${scheme.base05}"
;; :on-secondary-color "${scheme.base05}"
;; :on-tertiary-color "${scheme.base05}"
;; :on-quaternary-color "${scheme.base05}"
;; :on-accent-color "${scheme.base01}"
;; :on-action-color "${scheme.base01}"
;; :on-success-color "${scheme.base01}"
;; :on-warning-color "${scheme.base01}"
;; :on-highlight-color "${scheme.base01}"
;; :on-codeblock-color "${scheme.base05}"
))))
2024-07-30 15:06:34 +01:00
'';
};
2024-07-30 15:06:34 +01:00
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)
))
+ ")"
);
};
}