nixos/system/home/browser/nyxt.nix

76 lines
3.7 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) colors;
inherit (config.stylix) fonts;
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:${colors.variant}")
2024-07-30 15:06:34 +01:00
;; Define custom theme
(define-configuration browser
((theme (make-instance 'theme:theme
:font-family "${fonts.sansSerif.name}"
:monospace-font-family "${fonts.monospace.name}"
:text-color "${colors.withHashtag.base05}"
:contrast-text-color "${colors.withHashtag.base01}"
:background-color "${colors.withHashtag.base00}"
:primary-color "${colors.withHashtag.base04}"
:secondary-color "${colors.withHashtag.base03}"
:tertiary-color "${colors.withHashtag.base02}"
:quaternary-color "${colors.withHashtag.base02}"
:accent-color "${colors.withHashtag.magenta}"
:action-color "${colors.withHashtag.cyan}"
:success-color "${colors.withHashtag.green}"
:warning-color "${colors.withHashtag.yellow}"
:highlight-color "${colors.withHashtag.base04}"
:codeblock-color "${colors.withHashtag.base01}"
:on-background-color "${colors.withHashtag.base05}"
:on-primary-color "${colors.withHashtag.base00}"
:on-secondary-color "${colors.withHashtag.base01}"
:on-tertiary-color "${colors.withHashtag.base04}"
:on-quaternary-color "${colors.withHashtag.base04}"
:on-accent-color "${colors.withHashtag.base01}"
:on-action-color "${colors.withHashtag.base01}"
:on-success-color "${colors.withHashtag.base01}"
:on-warning-color "${colors.withHashtag.base01}"
:on-highlight-color "${colors.withHashtag.base01}"
:on-codeblock-color "${colors.withHashtag.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) + " )";
2025-01-27 11:20:48 +00:00
# Take bookmarks as returned from JSON file and convert to
# NYXT expected format
2024-07-30 15:06:34 +01:00
convertBookmark =
{
name,
tags,
url,
}:
"(:url \"${url}\" :title \"${name}\" :tags ${convertTags tags})\n";
in
(
2025-01-27 11:20:48 +00:00
# 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
2024-07-30 15:06:34 +01:00
"(\n"
+ (builtins.foldl' (x: y: x + " " + convertBookmark y) "" (
builtins.fromJSON (builtins.readFile ./bookmarks.json)
))
+ ")"
);
};
}