mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
flake: move packages to a by-name overlay
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a69642d9409f7d32e01a140cb62c2173b5226
This commit is contained in:
parent
33a69fae5f
commit
8dd53be910
3 changed files with 108 additions and 72 deletions
|
@ -9,29 +9,59 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
inherit (lib.customisation) makeScope;
|
||||||
|
inherit (lib.attrsets) isDerivation isAttrs concatMapAttrs;
|
||||||
|
inherit (lib.strings) concatStringsSep;
|
||||||
|
inherit (lib.filesystem) packagesFromDirectoryRecursive;
|
||||||
|
|
||||||
|
# Entrypoint for nvf documentation and relevant packages.
|
||||||
docs = import ../docs {inherit pkgs inputs lib;};
|
docs = import ../docs {inherit pkgs inputs lib;};
|
||||||
|
|
||||||
|
# Helper function for creating demo configurations for nvf
|
||||||
|
# TODO: make this more generic.
|
||||||
buildPkg = maximal:
|
buildPkg = maximal:
|
||||||
(args.config.flake.lib.nvim.neovimConfiguration {
|
(args.config.flake.lib.nvim.neovimConfiguration {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
modules = [(import ../configuration.nix maximal)];
|
modules = [(import ../configuration.nix maximal)];
|
||||||
}).neovim;
|
}).neovim;
|
||||||
in {
|
|
||||||
packages = {
|
# This constructs a by-name overlay similar to the one found in Nixpkgs.
|
||||||
blink-cmp = pkgs.callPackage ./blink {};
|
# The goal is to automatically discover and packages found in pkgs/by-name
|
||||||
avante-nvim = let
|
# as long as they have a 'package.nix' in the package directory. We also
|
||||||
pin = self.pins.avante-nvim;
|
# pass 'inputs' and 'pins' to all packages in the 'callPackage' scope, therefore
|
||||||
in
|
# they are always available in the relevant 'package.nix' files.
|
||||||
pkgs.callPackage ./avante-nvim {
|
# ---
|
||||||
version = pin.branch;
|
# The logic is borrowed from drupol/pkgs-by-name-for-flake-parts, available
|
||||||
src = pkgs.fetchFromGitHub {
|
# under the MIT license.
|
||||||
inherit (pin.repository) owner repo;
|
flattenPkgs = separator: path: value:
|
||||||
rev = pin.revision;
|
if isDerivation value
|
||||||
sha256 = pin.hash;
|
then {
|
||||||
};
|
${concatStringsSep separator path} = value;
|
||||||
pins = self.pins;
|
}
|
||||||
|
else if isAttrs value
|
||||||
|
then concatMapAttrs (name: flattenPkgs separator (path ++ [name])) value
|
||||||
|
else
|
||||||
|
# Ignore the functions which makeScope returns
|
||||||
|
{};
|
||||||
|
|
||||||
|
inputsScope = makeScope pkgs.newScope (_: {
|
||||||
|
inherit inputs;
|
||||||
|
inherit (self) pins;
|
||||||
|
});
|
||||||
|
|
||||||
|
scopeFromDirectory = directory:
|
||||||
|
packagesFromDirectoryRecursive {
|
||||||
|
inherit directory;
|
||||||
|
inherit (inputsScope) newScope callPackage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
legacyPackages = scopeFromDirectory ./pkgs/by-name;
|
||||||
|
in {
|
||||||
|
packages =
|
||||||
|
(flattenPkgs "/" [] legacyPackages)
|
||||||
|
// {
|
||||||
inherit (docs.manual) htmlOpenTool;
|
inherit (docs.manual) htmlOpenTool;
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
docs = docs.manual.html;
|
docs = docs.manual.html;
|
||||||
docs-html = docs.manual.html;
|
docs-html = docs.manual.html;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
pins,
|
||||||
openssl,
|
openssl,
|
||||||
pkg-config,
|
pkg-config,
|
||||||
rustPlatform,
|
rustPlatform,
|
||||||
|
@ -6,11 +7,17 @@
|
||||||
vimUtils,
|
vimUtils,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
pkgs,
|
pkgs,
|
||||||
version,
|
|
||||||
src,
|
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit version src;
|
# From npins
|
||||||
|
pin = pins.avante-nvim;
|
||||||
|
version = pin.branch;
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
inherit (pin.repository) owner repo;
|
||||||
|
rev = pin.revision;
|
||||||
|
sha256 = pin.hash;
|
||||||
|
};
|
||||||
|
|
||||||
avante-nvim-lib = rustPlatform.buildRustPackage {
|
avante-nvim-lib = rustPlatform.buildRustPackage {
|
||||||
pname = "avante-nvim-lib";
|
pname = "avante-nvim-lib";
|
||||||
inherit version src;
|
inherit version src;
|
||||||
|
@ -48,10 +55,9 @@ in
|
||||||
ext = stdenv.hostPlatform.extensions.sharedLibrary;
|
ext = stdenv.hostPlatform.extensions.sharedLibrary;
|
||||||
in ''
|
in ''
|
||||||
mkdir -p $out/build
|
mkdir -p $out/build
|
||||||
ln -s ${avante-nvim-lib}/lib/libavante_repo_map${ext} $out/build/avante_repo_map${ext}
|
for lib in avante_repo_map avante_templates avante_tokenizers avante_html2md; do
|
||||||
ln -s ${avante-nvim-lib}/lib/libavante_templates${ext} $out/build/avante_templates${ext}
|
ln -s ${avante-nvim-lib}/lib/lib$lib${ext} $out/build/$$lib${ext}
|
||||||
ln -s ${avante-nvim-lib}/lib/libavante_tokenizers${ext} $out/build/avante_tokenizers${ext}
|
done
|
||||||
ln -s ${avante-nvim-lib}/lib/libavante_html2md${ext} $out/build/avante_html2md${ext}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nvimSkipModules = [
|
nvimSkipModules = [
|
Loading…
Add table
Add a link
Reference in a new issue