Skip to content

Commit f1ed453

Browse files
committed
feat(docs): use nuscht search for options
1 parent becc648 commit f1ed453

10 files changed

+233
-116
lines changed

dev/flake.lock

+117-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/flake.nix

+74-31
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
33

44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
7+
# NOTE: This is only to deduplicate inputs
8+
flake-utils = {
9+
url = "github:numtide/flake-utils";
10+
};
11+
12+
nuscht-search = {
13+
url = "github:NuschtOS/search";
14+
inputs = {
15+
nixpkgs.follows = "nixpkgs";
16+
flake-utils.follows = "flake-utils";
17+
};
18+
};
19+
20+
catppuccin-rolling = {
21+
url = "github:catppuccin/nix";
22+
};
23+
24+
catppuccin-v1 = {
25+
url = "https://flakehub.com/f/catppuccin/nix/1.*.tar.gz";
26+
};
27+
628
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
729

830
home-manager = {
@@ -19,11 +41,14 @@
1941
outputs =
2042
{
2143
self,
44+
nuscht-search,
2245
nixpkgs,
2346
nixpkgs-stable,
2447
home-manager,
2548
home-manager-stable,
26-
}:
49+
...
50+
}@inputs:
51+
2752
let
2853
systems = [
2954
"x86_64-linux"
@@ -38,14 +63,30 @@
3863
});
3964

4065
forAllSystems = nixpkgs.lib.genAttrs systems;
66+
67+
# Versions of the modules we want to index in our search
68+
searchVersions = [
69+
{
70+
versionName = "v1";
71+
catppuccin = inputs.catppuccin-v1;
72+
}
73+
{
74+
versionName = "rolling";
75+
catppuccin = inputs.catppuccin-rolling;
76+
}
77+
];
78+
4179
in
80+
4281
{
4382
apps = forAllSystems (
4483
system:
84+
4585
let
4686
pkgs = nixpkgsFor.${system}.unstable;
4787
inherit (pkgs) lib;
4888
in
89+
4990
{
5091
serve = {
5192
type = "app";
@@ -56,13 +97,15 @@
5697

5798
checks = forAllSystems (
5899
system:
100+
59101
let
60102
pkgs = nixpkgsFor.${system};
61103
inherit (pkgs.unstable) lib;
62104

63105
callUnstable = lib.flip pkgs.unstable.callPackage { inherit home-manager; };
64106
callStable = lib.flip pkgs.stable.callPackage { home-manager = home-manager-stable; };
65107
in
108+
66109
lib.optionalAttrs pkgs.unstable.stdenv.hostPlatform.isDarwin {
67110
darwin-test-unstable = callUnstable ../tests/darwin.nix;
68111
darwin-test-stable = callStable ../tests/darwin.nix;
@@ -77,43 +120,43 @@
77120

78121
packages = forAllSystems (
79122
system:
123+
80124
let
81125
pkgs = nixpkgsFor.${system}.unstable;
82126
inherit (pkgs) lib;
83127

84-
version = self.shortRev or self.dirtyShortRev or "unknown";
85-
mkOptionDoc = pkgs.callPackage ../docs/options-doc.nix { };
86128
mkSite = pkgs.callPackage ../docs/mk-site.nix { };
87-
packages' = self.packages.${system};
88-
in
89-
{
90-
nixos-doc = mkOptionDoc {
91-
inherit version;
92-
moduleRoot = ../modules/nixos;
129+
mkSearchInstance = pkgs.callPackage ../docs/mk-search.nix {
130+
inherit (nuscht-search.packages.${system}) mkMultiSearch;
93131
};
94132

95-
home-manager-doc = mkOptionDoc {
96-
inherit version;
97-
moduleRoot = ../modules/home-manager;
98-
};
133+
search-instances = lib.listToAttrs (
134+
map (
135+
{ catppuccin, versionName }:
136+
{
137+
name = "search-${versionName}";
138+
value = mkSearchInstance { inherit catppuccin versionName; };
139+
}
140+
) searchVersions
141+
);
142+
in
143+
144+
search-instances
145+
// {
146+
site = mkSite {
147+
pname = "catppuccin-nix-site";
148+
version = self.shortRev or self.dirtyShortRev or "unknown";
149+
150+
src = ../docs;
151+
152+
postPatch = "ln -sf ${inputs.catppuccin-rolling + "/CHANGELOG.md"} src/NEWS.md";
99153

100-
site = mkSite rec {
101-
pname = "catppuccin-nix-website";
102-
inherit version;
103-
104-
src = lib.fileset.toSource {
105-
root = ../.;
106-
fileset = lib.fileset.unions [
107-
../CHANGELOG.md
108-
../docs/src
109-
../docs/book.toml
110-
../docs/theme
111-
];
112-
};
113-
sourceRoot = "${src.name}/docs";
114-
115-
nixosDoc = packages'.nixos-doc;
116-
homeManagerDoc = packages'.home-manager-doc;
154+
postInstall = lib.concatLines (
155+
[ "mkdir -p $out/search" ]
156+
++ lib.mapAttrsToList (
157+
name: value: "ln -s ${value.outPath} $out/${lib.replaceStrings [ "-" ] [ "/" ] name}"
158+
) search-instances
159+
);
117160
};
118161

119162
add-source =
@@ -133,7 +176,7 @@
133176
chmod 755 $out/bin/add-source
134177
'';
135178

136-
default = packages'.site;
179+
default = self.packages.${system}.site;
137180
}
138181
);
139182
};

docs/mk-search.nix

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{ mkMultiSearch }:
2+
3+
{ catppuccin, versionName }:
4+
5+
let
6+
urlPrefix = "https://github.com/catppuccin/nix/tree/${catppuccin.rev}/";
7+
in
8+
9+
mkMultiSearch {
10+
title = "catppuccin/nix Option Search";
11+
baseHref = "/search/${versionName}/";
12+
13+
scopes = [
14+
{
15+
name = "NixOS modules";
16+
modules = [ catppuccin.nixosModules.catppuccin ];
17+
inherit urlPrefix;
18+
}
19+
{
20+
name = "home-manager modules";
21+
modules = [ catppuccin.homeManagerModules.catppuccin ];
22+
inherit urlPrefix;
23+
}
24+
];
25+
}

docs/mk-site.nix

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
11
{
2+
lib,
23
stdenvNoCC,
3-
writeShellApplication,
44
mdbook,
55
python3,
6+
writeShellApplication,
67
}:
7-
{ nixosDoc, homeManagerDoc, ... }@args:
8+
9+
args:
10+
811
stdenvNoCC.mkDerivation (
912
finalAttrs:
1013
args
1114
// {
12-
nativeBuildInputs = [ mdbook ];
15+
nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [ mdbook ];
1316

14-
dontPatch = true;
1517
dontConfigure = true;
1618
doCheck = false;
1719

1820
buildPhase = ''
1921
runHook preBuild
20-
21-
ln -s ${nixosDoc} src/options/nixos-options.md
22-
ln -s ${homeManagerDoc} src/options/home-manager-options.md
2322
mdbook build
24-
2523
runHook postBuild
2624
'';
2725

2826
installPhase = ''
2927
runHook preInstall
30-
3128
mv book $out
32-
3329
runHook postInstall
3430
'';
3531

36-
passthru = {
32+
passthru = lib.recursiveUpdate (args.passthru or { }) {
3733
serve = writeShellApplication {
3834
name = "serve";
3935

0 commit comments

Comments
 (0)