From e7cdd3c8a464872aeb653f6d7c399040e1bf0b43 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Wed, 1 Jan 2025 10:47:42 +0100 Subject: [PATCH] blink: expose blink package --- flake/packages.nix | 7 +++++++ flake/packages/blink-cmp.nix | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 flake/packages/blink-cmp.nix diff --git a/flake/packages.nix b/flake/packages.nix index cf1f81ac..aa9d53ab 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -6,6 +6,7 @@ ... }: let docs = import ../docs {inherit pkgs inputs lib;}; + pluginVersion = input: input.shortRev or input.shortDirtyRev or "dirty"; in { packages = { inherit (docs.manual) htmlOpenTool; @@ -66,6 +67,12 @@ Volumes = {"/home/neovim/demo" = {};}; }; }; + + # Plugins that need a compile step + blink-cmp = pkgs.callPackage ./packages/blink-cmp.nix { + src = inputs.plugin-blink-cmp; + version = pluginVersion inputs.plugin-blink-cmp; + }; }; }; } diff --git a/flake/packages/blink-cmp.nix b/flake/packages/blink-cmp.nix new file mode 100644 index 00000000..ca91d0ef --- /dev/null +++ b/flake/packages/blink-cmp.nix @@ -0,0 +1,38 @@ +{ + rustPlatform, + hostPlatform, + src, + version, + vimUtils, +}: { + blink-cmp = let + inherit version src; + blink-fuzzy-lib = rustPlatform.buildRustPackage { + pname = "blink-fuzzy-lib"; + inherit version src; + + env = { + # TODO: remove this if plugin stops using nightly rust + RUSTC_BOOTSTRAP = true; + }; + cargoLock = { + lockFile = "${src}/Cargo.lock"; + outputHashes = { + "frizbee-0.1.0" = "sha256-pt6sMsRyjXrbrTK7t/YvWeen/n3nU8UUaiNYTY1LczE="; + }; + }; + }; + libExt = + if hostPlatform.isDarwin + then "dylib" + else "so"; + in + vimUtils.buildVimPlugin { + pname = "blink-cmp"; + inherit version src; + preInstall = '' + mkdir -p target/release + ln -s ${blink-fuzzy-lib}/lib/libblink_cmp_fuzzy.${libExt} target/release/libblink_cmp_fuzzy.${libExt} + ''; + }; +}