Skip to content

Commit 85f8c77

Browse files
authored
docs: use nuscht search for options (#390)
1 parent becc648 commit 85f8c77

10 files changed

+237
-131
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

+78-46
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_1 = {
25+
url = "https://flakehub.com/f/catppuccin/nix/1.1.*.tar.gz";
26+
};
27+
628
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
729

830
home-manager = {
@@ -19,12 +41,16 @@
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
53+
inherit (nixpkgs) lib;
2854
systems = [
2955
"x86_64-linux"
3056
"aarch64-linux"
@@ -38,31 +64,38 @@
3864
});
3965

4066
forAllSystems = nixpkgs.lib.genAttrs systems;
67+
68+
# Versions of the modules we want to index in our search
69+
searchVersions =
70+
map
71+
(versionName: {
72+
inherit versionName;
73+
catppuccin = inputs."catppuccin-${lib.replaceStrings [ "." ] [ "_" ] versionName}";
74+
})
75+
[
76+
"v1.1"
77+
"rolling"
78+
];
4179
in
80+
4281
{
43-
apps = forAllSystems (
44-
system:
45-
let
46-
pkgs = nixpkgsFor.${system}.unstable;
47-
inherit (pkgs) lib;
48-
in
49-
{
50-
serve = {
51-
type = "app";
52-
program = lib.getExe self.packages.${system}.site.serve;
53-
};
54-
}
55-
);
82+
apps = forAllSystems (system: {
83+
serve = {
84+
type = "app";
85+
program = lib.getExe self.packages.${system}.site.serve;
86+
};
87+
});
5688

5789
checks = forAllSystems (
5890
system:
91+
5992
let
6093
pkgs = nixpkgsFor.${system};
61-
inherit (pkgs.unstable) lib;
6294

6395
callUnstable = lib.flip pkgs.unstable.callPackage { inherit home-manager; };
6496
callStable = lib.flip pkgs.stable.callPackage { home-manager = home-manager-stable; };
6597
in
98+
6699
lib.optionalAttrs pkgs.unstable.stdenv.hostPlatform.isDarwin {
67100
darwin-test-unstable = callUnstable ../tests/darwin.nix;
68101
darwin-test-stable = callStable ../tests/darwin.nix;
@@ -77,43 +110,42 @@
77110

78111
packages = forAllSystems (
79112
system:
113+
80114
let
81115
pkgs = nixpkgsFor.${system}.unstable;
82-
inherit (pkgs) lib;
83116

84-
version = self.shortRev or self.dirtyShortRev or "unknown";
85-
mkOptionDoc = pkgs.callPackage ../docs/options-doc.nix { };
86117
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;
118+
mkSearchInstance = pkgs.callPackage ../docs/mk-search.nix {
119+
inherit (nuscht-search.packages.${system}) mkMultiSearch;
93120
};
94121

95-
home-manager-doc = mkOptionDoc {
96-
inherit version;
97-
moduleRoot = ../modules/home-manager;
98-
};
122+
search-instances = lib.listToAttrs (
123+
map (
124+
{ catppuccin, versionName }:
125+
{
126+
name = "search-${versionName}";
127+
value = mkSearchInstance { inherit catppuccin versionName; };
128+
}
129+
) searchVersions
130+
);
131+
in
132+
133+
search-instances
134+
// {
135+
site = mkSite {
136+
pname = "catppuccin-nix-site";
137+
version = self.shortRev or self.dirtyShortRev or "unknown";
138+
139+
src = ../docs;
140+
141+
postPatch = "ln -sf ${inputs.catppuccin-rolling + "/CHANGELOG.md"} src/NEWS.md";
99142

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;
143+
postInstall = lib.concatLines (
144+
[ "mkdir -p $out/search" ]
145+
++ lib.mapAttrsToList (
146+
name: value: "ln -s ${value.outPath} $out/${lib.replaceStrings [ "-" ] [ "/" ] name}"
147+
) search-instances
148+
);
117149
};
118150

119151
add-source =
@@ -133,7 +165,7 @@
133165
chmod 755 $out/bin/add-source
134166
'';
135167

136-
default = packages'.site;
168+
default = self.packages.${system}.site;
137169
}
138170
);
139171
};

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)