Small flake library for generating Firefox userstyles from the upstream Catppuccin themes, then remapping them to any Base16-compatible palette.
Overview - Usage - Library - Development - Notes
This repository packages the upstream 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.
- Exposes three library helpers:
mkUserStyles,withExtraCss, andmkUserContent. - Builds upstream LESS and SCSS sources into a single stylesheet derivation.
- Replaces Catppuccin tokens with Base16 and derived Base24-style color slots.
- Marks generated declarations as
!importantso they win against site styles more reliably. - Ships example package outputs for plain styles, Firefox-ready
userContent.css, and appended custom CSS.
Add the flake as an input and use one of the exported helpers from nix-userstyles.lib.
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-userstyles.url = "github:adam01110/nix-userstyles";
nix-colors.url = "github:misterio77/nix-colors";
};
}{
nix-userstyles,
pkgs,
...
}:
let
nix-colors = builtins.getFlake "github:misterio77/nix-colors";
palette = nix-colors.outputs.colorSchemes.gruvbox-dark-medium.palette;
system = pkgs.stdenv.hostPlatform.system;
in {
home.file.".mozilla/firefox/default/chrome/userContent.css".source =
nix-userstyles.lib.mkUserContent system {
inherit palette;
userStyles = [
"github"
"reddit"
"youtube"
];
};
}{
nix-userstyles,
pkgs,
...
}:
let
nix-colors = builtins.getFlake "github:misterio77/nix-colors";
palette = nix-colors.outputs.colorSchemes.dracula.palette;
system = pkgs.stdenv.hostPlatform.system;
in {
home.file.".mozilla/firefox/default/chrome/userContent.css".source =
nix-userstyles.lib.mkUserContent system {
inherit palette;
userStyles = [
"github"
"reddit"
"youtube"
];
extraCss = ''
@-moz-document domain("example.com") {
body {
outline: 1px solid red !important;
}
}
'';
};
}{
config,
lib,
nix-userstyles,
pkgs,
...
}:
let
inherit (lib) filterAttrs hasPrefix;
palette = filterAttrs (name: _: hasPrefix "base0" name) config.lib.stylix.colors;
system = pkgs.stdenv.hostPlatform.system;
in {
home.file.".mozilla/firefox/default/chrome/userContent.css".source =
nix-userstyles.lib.mkUserContent system {
inherit palette;
userStyles = [
"github"
"reddit"
"youtube"
];
};
}Note
The palette must provide the standard Base16 keys: base00 through base0F. Additional slots used internally for Catppuccin's palette mapping are derived automatically.
| Export | Role |
|---|---|
lib.mkUserStyles |
Build generated upstream CSS as a derivation |
lib.withExtraCss |
Append additional CSS to an existing stylesheet derivation |
lib.mkUserContent |
Build Firefox-ready userContent.css in one step |
The repository also exposes a few package outputs on each supported system:
| Output | Role |
|---|---|
packages.default |
Generated stylesheet using the bundled test style list |
packages.user-content |
Firefox-ready userContent.css |
packages.with-extra-css |
Generated stylesheet with appended custom CSS |
packages.test |
Same build used by CI checks |
From the repository root:
# Inspect flake outputs
nix flake show --all-systems
# Run CI-equivalent checks
nix flake check
# Format the repository
nix fmt
# Enter the dev shell
nix developFormatting is configured through treefmt.
- Style names come from the upstream Catppuccin repositories. The bundled test list in
lib/testUserStyles.nixis a good reference for known working names. discordis handled separately from the maincatppuccin/userstylestree and is compiled from the upstream SCSS theme.- The generated CSS is post-processed so every declaration becomes
!important.
