diff --git a/home/default.nix b/home/default.nix index ee2f997..96fd263 100755 --- a/home/default.nix +++ b/home/default.nix @@ -41,7 +41,6 @@ # kde and kde theming kde-rounded-corners kdePackages.partitionmanager - pkgs.catppuccin-cursors.mochaPeach adwaita-icon-theme morewaita-icon-theme diff --git a/options.nix b/options.nix index 910e25f..68396e5 100644 --- a/options.nix +++ b/options.nix @@ -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,32 +100,36 @@ default = pkgs.noto-fonts-color-emoji; }; }; - cursor = - let - attrName = "mocha" + "Peach"; - in - { - name = lib.mkOption { - type = lib.types.str; - readOnly = true; - default = "catppuccin-mocha-peach-cursors"; - }; - package = lib.mkOption { - type = lib.types.package; - readOnly = true; - default = pkgs.catppuccin-cursors.${attrName}; - }; - size = lib.mkOption { - type = lib.types.int; - readOnly = true; - default = 24; - }; - path = lib.mkOption { - type = lib.types.str; - readOnly = true; - default = "${pkgs.catppuccin-cursors.${attrName}}/share/icons"; - }; + cursor = { + name = lib.mkOption { + type = lib.types.str; + readOnly = true; + default = config.colors.scheme; }; + package = lib.mkOption { + type = lib.types.package; + readOnly = true; + 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; + readOnly = true; + default = 24; + }; + path = lib.mkOption { + type = lib.types.str; + readOnly = true; + default = "${config.userOptions.cursor.package}/share/icons/${config.colors.scheme}"; + }; + }; # isDark = lib.mkOption { # type = lib.types.bool; # readOnly = true; diff --git a/packages/bibata-cursor/default.nix b/packages/bibata-cursor/default.nix new file mode 100644 index 0000000..6811afc --- /dev/null +++ b/packages/bibata-cursor/default.nix @@ -0,0 +1,103 @@ +{ + pkgs ? import { }, + 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; + }; +} diff --git a/packages/overlay.nix b/packages/overlay.nix index 44daa1d..5346aea 100644 --- a/packages/overlay.nix +++ b/packages/overlay.nix @@ -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";