Skip to content

Commit aa4afbe

Browse files
ScrumplexMattSturgeon
authored andcommitted
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 <[email protected]>
1 parent 04671a0 commit aa4afbe

File tree

3 files changed

+35
-62
lines changed

3 files changed

+35
-62
lines changed

docs/default.nix

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,37 @@
44
pkgs,
55
}:
66
let
7-
pkgsDoc =
8-
import
9-
(pkgs.applyPatches {
10-
name = "nixpkgs-nixvim-doc";
11-
src = pkgs.path;
12-
patches = [ ./either_recursive.patch ];
13-
})
14-
{
15-
inherit (pkgs) system;
16-
config.allowUnfree = true;
7+
# Extend nixpkg's lib, so that we can handle recursive leaf types such as `either`
8+
lib = pkgs.lib.extend (
9+
final: prev: {
10+
types = prev.types // {
11+
either =
12+
t1: t2:
13+
(prev.types.either t1 t2)
14+
// {
15+
getSubOptions = prefix: (t1.getSubOptions prefix) // (t2.getSubOptions prefix);
16+
};
17+
18+
eitherRecursive = t1: t2: (final.types.either t1 t2) // { getSubOptions = _: { }; };
19+
20+
oneOfRecursive =
21+
ts:
22+
let
23+
head' =
24+
if ts == [ ] then
25+
throw "types.oneOfRecursive needs to get at least one type in its argument"
26+
else
27+
builtins.head ts;
28+
tail' = builtins.tail ts;
29+
in
30+
builtins.foldl' final.types.eitherRecursive head' tail';
1731
};
32+
}
33+
);
1834

19-
inherit (pkgsDoc) lib;
35+
pkgsDoc = pkgs // {
36+
inherit lib;
37+
};
2038

2139
nixvimPath = toString ./..;
2240

docs/either_recursive.patch

Lines changed: 0 additions & 49 deletions
This file was deleted.

flake-modules/packages.nix

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
{
22
perSystem =
33
{
4-
pkgs,
4+
pkgsUnfree,
55
config,
66
rawModules,
77
helpers,
88
...
99
}:
1010
{
11-
packages = import ../docs { inherit rawModules pkgs helpers; };
11+
packages = import ../docs {
12+
inherit rawModules helpers;
13+
# Building the docs evaluates each plugin's default package, some of which are unfree
14+
pkgs = pkgsUnfree;
15+
};
1216

1317
# Test that all packages build fine when running `nix flake check`.
1418
checks = config.packages;

0 commit comments

Comments
 (0)