mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
docs: refactor serve-docs
; add nix run .#docs
Refactor `serve-docs` using `makeWrapper`, make it available as a `serve-docs` package and as the `docs` "app". This means `nix build .#docs` will build the docs while `nix run .#docs` will run the server.
This commit is contained in:
parent
5c49988a7c
commit
f3342bdbd4
5 changed files with 28 additions and 8 deletions
|
@ -132,5 +132,9 @@ lib.fix (
|
||||||
inherit evaledModules transformOptions;
|
inherit evaledModules transformOptions;
|
||||||
inherit (self) search lib-docs;
|
inherit (self) search lib-docs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
serve-docs = pkgs.callPackage ./server {
|
||||||
|
inherit (self) docs;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
19
docs/server/default.nix
Normal file
19
docs/server/default.nix
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
runCommand,
|
||||||
|
makeBinaryWrapper,
|
||||||
|
python3,
|
||||||
|
docs,
|
||||||
|
}:
|
||||||
|
runCommand "serve-docs"
|
||||||
|
{
|
||||||
|
nativeBuildInputs = [ makeBinaryWrapper ];
|
||||||
|
meta.mainProgram = "server";
|
||||||
|
}
|
||||||
|
''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
makeWrapper ${lib.getExe python3} \
|
||||||
|
$out/bin/server \
|
||||||
|
--add-flags ${./server.py} \
|
||||||
|
--chdir ${docs}
|
||||||
|
''
|
|
@ -101,14 +101,7 @@
|
||||||
help = "Build and serve documentation locally";
|
help = "Build and serve documentation locally";
|
||||||
command = ''
|
command = ''
|
||||||
echo -e "=> Building nixvim documentation...\n"
|
echo -e "=> Building nixvim documentation...\n"
|
||||||
|
nix run .#docs
|
||||||
doc_derivation=$(${nix} build .#docs --no-link --print-out-paths)
|
|
||||||
|
|
||||||
echo -e "\n=> Documentation successfully built ('$doc_derivation')"
|
|
||||||
|
|
||||||
echo -e "\n=> You can then open your browser to view the doc\n"
|
|
||||||
|
|
||||||
(cd "$doc_derivation"/share/doc && ${pkgs.lib.getExe pkgs.python3} ${./server.py})
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,11 +7,15 @@
|
||||||
{
|
{
|
||||||
perSystem =
|
perSystem =
|
||||||
{
|
{
|
||||||
|
config,
|
||||||
inputs',
|
inputs',
|
||||||
system,
|
system,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
# Run the docs server when using `nix run .#docs`
|
||||||
|
apps.docs.program = config.packages.serve-docs;
|
||||||
|
|
||||||
packages = import ../docs {
|
packages = import ../docs {
|
||||||
nixvim = self;
|
nixvim = self;
|
||||||
inherit helpers;
|
inherit helpers;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue