mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
docs: use lib.extend instead of patching nixpkgs
This speeds up evaluation and removes IFD. Additionally, this makes it easier to maintain these library changes, as we don't have to maintain static patches. Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
04671a049a
commit
aa4afbeac2
3 changed files with 36 additions and 63 deletions
|
@ -4,19 +4,37 @@
|
|||
pkgs,
|
||||
}:
|
||||
let
|
||||
pkgsDoc =
|
||||
import
|
||||
(pkgs.applyPatches {
|
||||
name = "nixpkgs-nixvim-doc";
|
||||
src = pkgs.path;
|
||||
patches = [ ./either_recursive.patch ];
|
||||
})
|
||||
{
|
||||
inherit (pkgs) system;
|
||||
config.allowUnfree = true;
|
||||
# Extend nixpkg's lib, so that we can handle recursive leaf types such as `either`
|
||||
lib = pkgs.lib.extend (
|
||||
final: prev: {
|
||||
types = prev.types // {
|
||||
either =
|
||||
t1: t2:
|
||||
(prev.types.either t1 t2)
|
||||
// {
|
||||
getSubOptions = prefix: (t1.getSubOptions prefix) // (t2.getSubOptions prefix);
|
||||
};
|
||||
|
||||
inherit (pkgsDoc) lib;
|
||||
eitherRecursive = t1: t2: (final.types.either t1 t2) // { getSubOptions = _: { }; };
|
||||
|
||||
oneOfRecursive =
|
||||
ts:
|
||||
let
|
||||
head' =
|
||||
if ts == [ ] then
|
||||
throw "types.oneOfRecursive needs to get at least one type in its argument"
|
||||
else
|
||||
builtins.head ts;
|
||||
tail' = builtins.tail ts;
|
||||
in
|
||||
builtins.foldl' final.types.eitherRecursive head' tail';
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
pkgsDoc = pkgs // {
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
nixvimPath = toString ./..;
|
||||
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
commit e067eb1f6da7994150f10854e5fd635ca8bd0e92
|
||||
Author: traxys <quentin+dev@familleboyer.net>
|
||||
Date: Sun Jan 14 17:54:55 2024 +0100
|
||||
|
||||
lib.types: Include the suboptions of both types for either
|
||||
|
||||
This allows to correctly gather the sub options for types of the form
|
||||
`either <type> (submodule {...})`.
|
||||
|
||||
This requires adding two new types: `eitherRecursive` and
|
||||
`oneOfRecursive` that avoid infinite recursions for types like
|
||||
configuration types that are often of the form `oneOf [atom (listOf
|
||||
configType)]`
|
||||
|
||||
diff --git a/lib/types.nix b/lib/types.nix
|
||||
index cea63c598321..d26982db6cc0 100644
|
||||
--- a/lib/types.nix
|
||||
+++ b/lib/types.nix
|
||||
@@ -906,10 +906,16 @@ rec {
|
||||
then functor.type mt1 mt2
|
||||
else null;
|
||||
functor = (defaultFunctor name) // { wrapped = [ t1 t2 ]; };
|
||||
+ getSubOptions = prefix: (t1.getSubOptions prefix) // (t2.getSubOptions prefix);
|
||||
nestedTypes.left = t1;
|
||||
nestedTypes.right = t2;
|
||||
};
|
||||
|
||||
+ # Handle recursive leaf types, avoiding an infinite recursion
|
||||
+ eitherRecursive = t1: t2: (either t1 t2) // {
|
||||
+ getSubOptions = _: {};
|
||||
+ };
|
||||
+
|
||||
# Any of the types in the given list
|
||||
oneOf = ts:
|
||||
let
|
||||
@@ -917,6 +923,13 @@ rec {
|
||||
tail' = tail ts;
|
||||
in foldl' either head' tail';
|
||||
|
||||
+ # Handle recursive leaf types, avoiding an infinite recursion
|
||||
+ oneOfRecursive = ts:
|
||||
+ let
|
||||
+ head' = if ts == [] then throw "types.oneOfRecursive needs to get at least one type in its argument" else head ts;
|
||||
+ tail' = tail ts;
|
||||
+ in foldl' eitherRecursive head' tail';
|
||||
+
|
||||
# Either value of type `coercedType` or `finalType`, the former is
|
||||
# converted to `finalType` using `coerceFunc`.
|
||||
coercedTo = coercedType: coerceFunc: finalType:
|
|
@ -1,14 +1,18 @@
|
|||
{
|
||||
perSystem =
|
||||
{
|
||||
pkgs,
|
||||
pkgsUnfree,
|
||||
config,
|
||||
rawModules,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
{
|
||||
packages = import ../docs { inherit rawModules pkgs helpers; };
|
||||
packages = import ../docs {
|
||||
inherit rawModules helpers;
|
||||
# Building the docs evaluates each plugin's default package, some of which are unfree
|
||||
pkgs = pkgsUnfree;
|
||||
};
|
||||
|
||||
# Test that all packages build fine when running `nix flake check`.
|
||||
checks = config.packages;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue