add tinted bibata cursors

This commit is contained in:
Sean Kovacs 2026-03-03 20:40:48 -05:00
commit 7f8a4c443f
Signed by: sckova
GPG key ID: 00F325187C68651A
4 changed files with 133 additions and 42 deletions

View file

@ -41,7 +41,6 @@
# kde and kde theming
kde-rounded-corners
kdePackages.partitionmanager
pkgs.catppuccin-cursors.mochaPeach
adwaita-icon-theme
morewaita-icon-theme

View file

@ -16,22 +16,6 @@
default = "base09";
};
};
# catppuccinUpper = {
# accent = lib.mkOption {
# type = lib.types.str;
# readOnly = true;
# default =
# builtins.substring 0 1 (lib.toUpper config.catppuccin.accent)
# + builtins.substring 1 (-1) config.catppuccin.accent;
# };
# flavor = lib.mkOption {
# type = lib.types.str;
# readOnly = true;
# default =
# builtins.substring 0 1 (lib.toUpper config.catppuccin.flavor)
# + builtins.substring 1 (-1) config.catppuccin.flavor;
# };
# };
userOptions = {
name = lib.mkOption {
type = lib.types.str;
@ -116,20 +100,24 @@
default = pkgs.noto-fonts-color-emoji;
};
};
cursor =
let
attrName = "mocha" + "Peach";
in
{
cursor = {
name = lib.mkOption {
type = lib.types.str;
readOnly = true;
default = "catppuccin-mocha-peach-cursors";
default = config.colors.scheme;
};
package = lib.mkOption {
type = lib.types.package;
readOnly = true;
default = pkgs.catppuccin-cursors.${attrName};
default =
with config.scheme;
(pkgs.bibata-cursor.override {
themeName = config.colors.scheme;
baseColor = withHashtag.${config.colors.accent};
outlineColor = withHashtag.base00;
watchBackgroundColor = withHashtag.base11;
cursorSizes = "16 20 22 24 28 32 40 48 56 64 72 80 88 96";
});
};
size = lib.mkOption {
type = lib.types.int;
@ -139,7 +127,7 @@
path = lib.mkOption {
type = lib.types.str;
readOnly = true;
default = "${pkgs.catppuccin-cursors.${attrName}}/share/icons";
default = "${config.userOptions.cursor.package}/share/icons/${config.colors.scheme}";
};
};
# isDark = lib.mkOption {

View file

@ -0,0 +1,103 @@
{
pkgs ? import <nixpkgs> { },
themeName ? "bibata",
baseColor ? "#000000",
outlineColor ? "#FFFFFF",
watchBackgroundColor ? "",
cursorSizes ? "24",
}:
let
version = "2.0.7";
src = pkgs.fetchFromGitHub {
owner = "ful1e5";
repo = "Bibata_Cursor";
rev = "v${version}";
hash = "sha256-kIKidw1vditpuxO1gVuZeUPdWBzkiksO/q2R/+DUdEc=";
};
yarnOfflineCache = pkgs.fetchYarnDeps {
yarnLock = "${src}/yarn.lock";
hash = "sha256-EpWIGoFFokmzRML2r/dCM+TImOCtii8mifLgnLKdUMY=";
};
in
pkgs.stdenv.mkDerivation {
pname = "bibata-${themeName}-cursor";
inherit version src;
nativeBuildInputs = with pkgs; [
yarn
nodejs
fixup-yarn-lock
python3Packages.clickgen
autoPatchelfHook
];
buildInputs = with pkgs; [
# Required to satisfy dynamic linking for prebuilt JS native modules (like resvg-js)
stdenv.cc.cc.lib
];
configurePhase = ''
runHook preConfigure
export HOME=$(mktemp -d)
echo "1. Setup offline yarn cache"
yarn config --offline set yarn-offline-mirror ${yarnOfflineCache}
fixup-yarn-lock yarn.lock
echo "2. Install node_modules offline"
yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules/
rm -rf node_modules/@resvg/resvg-js-linux-*-musl
echo "3. Patch prebuilt node binaries (like resvg) so they can run in the Nix sandbox"
autoPatchelf node_modules/
# https://github.com/ful1e5/cbmp/issues/4
echo "4. Patch 'ora' library to prevent Nix sandbox hangs"
sed -i 's/this.#isEnabled = .*/this.#isEnabled = false;/g' node_modules/ora/index.js
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
echo "Splitting SVGs to render across $NIX_BUILD_CORES cores..."
echo "1. Distribute SVGs evenly into chunk directories"
if [ -n "${watchBackgroundColor}" ]; then
./node_modules/.bin/cbmp -d "svg" -o "bitmaps/${themeName}" -bc "${baseColor}" -oc "${outlineColor}" -wc "${watchBackgroundColor}"
else
./node_modules/.bin/cbmp -d "svg" -o "bitmaps/${themeName}" -bc "${baseColor}" -oc "${outlineColor}"
fi
echo "Rendering complete. Building XCursor theme..."
echo "4. Build the final cursors"
ctgen configs/right/x.build.toml -s ${cursorSizes} -p x11 -d "bitmaps/${themeName}" -n "${themeName}" -c "${themeName} cursors"
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/share/icons
cp -r themes/${themeName} $out/share/icons/
runHook postInstall
'';
meta = with pkgs.lib; {
description = "Custom colored Bibata Cursor theme built from source";
homepage = "https://github.com/ful1e5/Bibata_Cursor";
license = licenses.gpl3;
platforms = platforms.linux;
};
}

View file

@ -1,5 +1,6 @@
final: prev: {
spotify-webapp = final.callPackage ./spotify-webapp { };
bibata-cursor = final.callPackage ./bibata-cursor { };
openmw-unstable = prev.openmw.overrideAttrs (oldAttrs: {
pname = "openmw";