···11+# keep-sorted start
12.direnv
23.rumdl_cache
34result*
55+# keep-sorted end
+81-56
README.md
···11<div align="center">
22+ <img src="./assets/nix-logo.png" alt="Nix logo" width="112" />
33+ <img src="./assets/screenshot.png" alt="nix-userstyles preview" width="560" />
2433-# nix-userstyles
55+ # nix-userstyles
4655-This module generates CSS from the upstream Catppuccin userstyles and remaps
66-the Catppuccin Mocha palette to your own Base16-compatible palette.
77+ Small flake library for generating Firefox userstyles from the upstream Catppuccin themes, then remapping them to any Base16-compatible palette.
7888-[](https://github.com/adam01110/fzfish/actions/workflows/ci.yml)
99+ [](https://github.com/adam01110/nix-userstyles/actions/workflows/ci.yml)
1010+ [](https://github.com/adam01110/nix-userstyles)
1111+ <br />
1212+ [](https://nixos.wiki/wiki/Flakes)
1313+ [](https://github.com/catppuccin/userstyles)
1414+ [](https://support.mozilla.org/en-US/kb/contributors-guide-firefox-advanced-customization)
9151616+ [Overview](#overview) - [Usage](#usage) - [Library](#library) - [Development](#development) - [Notes](#notes)
1017</div>
11181212-
1919+This repository packages the upstream [`catppuccin/userstyles`](https://github.com/catppuccin/userstyles) themes, compiles them with Nix, and swaps the Catppuccin Mocha palette for your own Base16 palette. It also includes bundled support for the Catppuccin Discord theme.
13201414-## What it provides
2121+## Overview
15221616-- `lib.mkUserStyles`: build the generated upstream CSS as a derivation
1717-- `lib.withExtraCss`: append your own CSS to an existing stylesheet derivation
1818-- `lib.mkUserContent`: build Firefox-ready `userContent.css` in one step
1919-- bundled support for Catppuccin's Discord theme in addition to the main
2020- `catppuccin/userstyles` repository
2323+- Exposes three library helpers: `mkUserStyles`, `withExtraCss`, and `mkUserContent`.
2424+- Builds upstream LESS and SCSS sources into a single stylesheet derivation.
2525+- Replaces Catppuccin tokens with Base16 and derived Base24-style color slots.
2626+- Marks generated declarations as `!important` so they win against site styles more reliably.
2727+- Ships example package outputs for plain styles, Firefox-ready `userContent.css`, and appended custom CSS.
21282222-## How it works
2929+## Usage
23302424-`nix-userstyles` compiles upstream LESS and SCSS sources, then replaces the
2525-Catppuccin color tokens with values from your palette.
3131+Add the flake as an input and use one of the exported helpers from `nix-userstyles.lib`.
26322727-The input palette must provide the standard Base16 keys:
2828-2929-`base00` `base01` `base02` `base03` `base04` `base05` `base06` `base07`
3030-`base08` `base09` `base0A` `base0B` `base0C` `base0D` `base0E` `base0F`
3131-3232-Additional Base24-style slots used internally are derived automatically.
3333-3434-## Usage
3333+```nix
3434+{
3535+ inputs = {
3636+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
3737+ nix-userstyles.url = "github:adam01110/nix-userstyles";
3838+ nix-colors.url = "github:misterio77/nix-colors";
3939+ };
4040+}
4141+```
35423643### Build Firefox `userContent.css`
3744···4350}:
4451let
4552 nix-colors = builtins.getFlake "github:misterio77/nix-colors";
4646- palette = nix-colors.outputs.colorSchemes.dracula.palette;
5353+ palette = nix-colors.outputs.colorSchemes.gruvbox-dark-medium.palette;
4754 system = pkgs.stdenv.hostPlatform.system;
4848-in
4949-{
5555+in {
5056 home.file.".mozilla/firefox/default/chrome/userContent.css".source =
5157 nix-userstyles.lib.mkUserContent system {
5258 inherit palette;
···5460 "github"
5561 "reddit"
5662 "youtube"
5757- "discord"
5863 ];
5964 };
6065}
6166```
62676363-### Add your own CSS
6464-6565-`mkUserContent` accepts an `extraCss` string that is appended after the generated
6666-userstyles.
6868+### Append your own CSS
67696870```nix
6971{
···7577 nix-colors = builtins.getFlake "github:misterio77/nix-colors";
7678 palette = nix-colors.outputs.colorSchemes.dracula.palette;
7779 system = pkgs.stdenv.hostPlatform.system;
7878-in
7979-{
8080+in {
8081 home.file.".mozilla/firefox/default/chrome/userContent.css".source =
8182 nix-userstyles.lib.mkUserContent system {
8283 inherit palette;
···102103{
103104 config,
104105 lib,
105105- pkgs,
106106 nix-userstyles,
107107+ pkgs,
107108 ...
108109}:
109110let
···111112112113 palette = filterAttrs (name: _: hasPrefix "base0" name) config.lib.stylix.colors;
113114 system = pkgs.stdenv.hostPlatform.system;
114114-in
115115-{
115115+in {
116116 home.file.".mozilla/firefox/default/chrome/userContent.css".source =
117117 nix-userstyles.lib.mkUserContent system {
118118 inherit palette;
119119 userStyles = [
120120- "brave-search"
121121- "bsky"
122122- "cinny"
123123- "duckduckgo"
124120 "github"
125125- "google"
126126- "hacker-news"
127127- "lobste.rs"
128128- "npm"
129121 "reddit"
130130- "spotify-web"
131131- "stack-overflow"
132132- "whatsapp-web"
133133- "wikipedia"
134122 "youtube"
135135- "discord"
136123 ];
137137- extraCss = ''
138138- @-moz-document domain("example.com") {
139139- body {
140140- outline: 1px solid red !important;
141141- }
142142- }
143143- '';
144124 };
145125}
146126```
147127128128+> [!NOTE]
129129+> The palette must provide the standard Base16 keys: `base00` through `base0F`. Additional slots used internally for Catppuccin's palette mapping are derived automatically.
130130+131131+## Library
132132+133133+| Export | Role |
134134+| --- | --- |
135135+| `lib.mkUserStyles` | Build generated upstream CSS as a derivation |
136136+| `lib.withExtraCss` | Append additional CSS to an existing stylesheet derivation |
137137+| `lib.mkUserContent` | Build Firefox-ready `userContent.css` in one step |
138138+139139+The repository also exposes a few package outputs on each supported system:
140140+141141+| Output | Role |
142142+| --- | --- |
143143+| `packages.default` | Generated stylesheet using the bundled test style list |
144144+| `packages.user-content` | Firefox-ready `userContent.css` |
145145+| `packages.with-extra-css` | Generated stylesheet with appended custom CSS |
146146+| `packages.test` | Same build used by CI checks |
147147+148148+## Development
149149+150150+From the repository root:
151151+152152+```bash
153153+# Inspect flake outputs
154154+nix flake show --all-systems
155155+156156+# Run CI-equivalent checks
157157+nix flake check
158158+159159+# Format the repository
160160+nix fmt
161161+162162+# Enter the dev shell
163163+nix develop
164164+```
165165+166166+Formatting is configured through `treefmt`.
167167+168168+## Notes
169169+170170+- Style names come from the upstream Catppuccin repositories. The bundled test list in `lib/testUserStyles.nix` is a good reference for known working names.
171171+- `discord` is handled separately from the main `catppuccin/userstyles` tree and is compiled from the upstream SCSS theme.
172172+- The generated CSS is post-processed so every declaration becomes `!important`.
173173+148174## Credits
149175150176- [Original project (`knoopx/nix-userstyles`)](https://github.com/knoopx/nix-userstyles)
151177- [Catppuccin userstyles](https://github.com/catppuccin/userstyles)
152178- [Catppuccin Discord theme](https://github.com/catppuccin/discord)
153179- [nix-colors](https://github.com/misterio77/nix-colors)
154154-- [tinted-theming/schemes](https://github.com/tinted-theming/schemes)