mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 17:46:29 +09:00
incus: build and expose documentation
This commit is contained in:
parent
923ae17528
commit
21197daa39
4 changed files with 70 additions and 6 deletions
|
@ -129,6 +129,7 @@ let
|
||||||
|
|
||||||
environment = lib.mkMerge [
|
environment = lib.mkMerge [
|
||||||
{
|
{
|
||||||
|
INCUS_DOCUMENTATION = "${cfg.package.doc}/html";
|
||||||
INCUS_EDK2_PATH = ovmf;
|
INCUS_EDK2_PATH = ovmf;
|
||||||
INCUS_LXC_HOOK = "${cfg.lxcPackage}/share/lxc/hooks";
|
INCUS_LXC_HOOK = "${cfg.lxcPackage}/share/lxc/hooks";
|
||||||
INCUS_LXC_TEMPLATE_CONFIG = "${pkgs.lxcfs}/share/lxc/config";
|
INCUS_LXC_TEMPLATE_CONFIG = "${pkgs.lxcfs}/share/lxc/config";
|
||||||
|
|
|
@ -66,6 +66,7 @@ import ../make-test-python.nix (
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
machine.wait_for_unit("incus.service")
|
machine.wait_for_unit("incus.service")
|
||||||
|
machine.wait_for_unit("incus-preseed.service")
|
||||||
|
|
||||||
# Check that the INCUS_UI environment variable is populated in the systemd unit
|
# Check that the INCUS_UI environment variable is populated in the systemd unit
|
||||||
machine.succeed("systemctl cat incus.service | grep 'INCUS_UI'")
|
machine.succeed("systemctl cat incus.service | grep 'INCUS_UI'")
|
||||||
|
@ -73,6 +74,9 @@ import ../make-test-python.nix (
|
||||||
# Ensure the endpoint returns an HTML page with 'Incus UI' in the title
|
# Ensure the endpoint returns an HTML page with 'Incus UI' in the title
|
||||||
machine.succeed("curl -kLs https://localhost:8443/ui | grep '<title>Incus UI</title>'")
|
machine.succeed("curl -kLs https://localhost:8443/ui | grep '<title>Incus UI</title>'")
|
||||||
|
|
||||||
|
# Ensure the documentation is rendering correctly
|
||||||
|
machine.succeed("curl -kLs https://localhost:8443/documentation/ | grep '<title>Incus documentation</title>'")
|
||||||
|
|
||||||
# Ensure the application is actually rendered by the Javascript
|
# Ensure the application is actually rendered by the Javascript
|
||||||
machine.succeed("PYTHONUNBUFFERED=1 selenium-script")
|
machine.succeed("PYTHONUNBUFFERED=1 selenium-script")
|
||||||
'';
|
'';
|
||||||
|
|
26
pkgs/by-name/in/incus/docs.patch
Normal file
26
pkgs/by-name/in/incus/docs.patch
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
diff --git i/doc/conf.py w/doc/conf.py
|
||||||
|
index 8d042818b..b4f0572bd 100644
|
||||||
|
--- i/doc/conf.py
|
||||||
|
+++ w/doc/conf.py
|
||||||
|
@@ -8,10 +8,6 @@ import yaml
|
||||||
|
from git import Repo
|
||||||
|
import filecmp
|
||||||
|
|
||||||
|
-# Download and link swagger-ui files
|
||||||
|
-if not os.path.isdir('.sphinx/deps/swagger-ui'):
|
||||||
|
- Repo.clone_from('https://github.com/swagger-api/swagger-ui', '.sphinx/deps/swagger-ui', depth=1)
|
||||||
|
-
|
||||||
|
os.makedirs('.sphinx/_static/swagger-ui/', exist_ok=True)
|
||||||
|
|
||||||
|
if not os.path.islink('.sphinx/_static/swagger-ui/swagger-ui-bundle.js'):
|
||||||
|
@@ -151,10 +147,6 @@ if os.path.exists("./related_topics.yaml"):
|
||||||
|
with open("./related_topics.yaml", "r") as fd:
|
||||||
|
myst_substitutions.update(yaml.safe_load(fd.read()))
|
||||||
|
|
||||||
|
-intersphinx_mapping = {
|
||||||
|
- 'cloud-init': ('https://cloudinit.readthedocs.io/en/latest/', None)
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
if ("LOCAL_SPHINX_BUILD" in os.environ) and (os.environ["LOCAL_SPHINX_BUILD"] == "True"):
|
||||||
|
swagger_url_scheme = "/api/#{{path}}"
|
||||||
|
else:
|
|
@ -13,6 +13,7 @@
|
||||||
buildGoModule,
|
buildGoModule,
|
||||||
fetchFromGitHub,
|
fetchFromGitHub,
|
||||||
acl,
|
acl,
|
||||||
|
buildPackages,
|
||||||
cowsql,
|
cowsql,
|
||||||
incus-ui-canonical,
|
incus-ui-canonical,
|
||||||
libcap,
|
libcap,
|
||||||
|
@ -27,11 +28,30 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
pname = "incus${lib.optionalString lts "-lts"}";
|
pname = "incus${lib.optionalString lts "-lts"}";
|
||||||
|
docsPython = buildPackages.python3.withPackages (
|
||||||
|
py: with py; [
|
||||||
|
furo
|
||||||
|
gitpython
|
||||||
|
linkify-it-py
|
||||||
|
canonical-sphinx-extensions
|
||||||
|
myst-parser
|
||||||
|
pyspelling
|
||||||
|
sphinx
|
||||||
|
sphinx-autobuild
|
||||||
|
sphinx-copybutton
|
||||||
|
sphinx-design
|
||||||
|
sphinx-notfound-page
|
||||||
|
sphinx-remove-toctrees
|
||||||
|
sphinx-reredirects
|
||||||
|
sphinx-tabs
|
||||||
|
sphinxcontrib-jquery
|
||||||
|
sphinxext-opengraph
|
||||||
|
]
|
||||||
|
);
|
||||||
in
|
in
|
||||||
|
|
||||||
buildGoModule rec {
|
buildGoModule (finalAttrs: {
|
||||||
inherit
|
inherit
|
||||||
patches
|
|
||||||
pname
|
pname
|
||||||
vendorHash
|
vendorHash
|
||||||
version
|
version
|
||||||
|
@ -40,15 +60,18 @@ buildGoModule rec {
|
||||||
outputs = [
|
outputs = [
|
||||||
"out"
|
"out"
|
||||||
"agent_loader"
|
"agent_loader"
|
||||||
|
"doc"
|
||||||
];
|
];
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "lxc";
|
owner = "lxc";
|
||||||
repo = "incus";
|
repo = "incus";
|
||||||
rev = "refs/tags/v${version}";
|
tag = "v${version}";
|
||||||
inherit hash;
|
inherit hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
patches = [ ./docs.patch ] ++ patches;
|
||||||
|
|
||||||
excludedPackages = [
|
excludedPackages = [
|
||||||
# statically compile these
|
# statically compile these
|
||||||
"cmd/incus-agent"
|
"cmd/incus-agent"
|
||||||
|
@ -61,6 +84,7 @@ buildGoModule rec {
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
installShellFiles
|
installShellFiles
|
||||||
pkg-config
|
pkg-config
|
||||||
|
docsPython
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
@ -82,6 +106,13 @@ buildGoModule rec {
|
||||||
CGO_LDFLAGS_ALLOW = "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)";
|
CGO_LDFLAGS_ALLOW = "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)";
|
||||||
|
|
||||||
postBuild = ''
|
postBuild = ''
|
||||||
|
# build docs
|
||||||
|
mkdir -p .sphinx/deps
|
||||||
|
ln -s ${buildPackages.python3.pkgs.swagger-ui-bundle.src} .sphinx/deps/swagger-ui
|
||||||
|
substituteInPlace Makefile --replace-fail '. $(SPHINXENV) ; ' ""
|
||||||
|
make doc-incremental
|
||||||
|
|
||||||
|
# build some static executables
|
||||||
make incus-agent incus-migrate
|
make incus-agent incus-migrate
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -111,18 +142,20 @@ buildGoModule rec {
|
||||||
cp internal/server/instance/drivers/agent-loader/systemd/incus-agent.service $agent_loader/etc/systemd/system/
|
cp internal/server/instance/drivers/agent-loader/systemd/incus-agent.service $agent_loader/etc/systemd/system/
|
||||||
cp internal/server/instance/drivers/agent-loader/systemd/incus-agent.rules $agent_loader/lib/udev/rules.d/99-incus-agent.rules
|
cp internal/server/instance/drivers/agent-loader/systemd/incus-agent.rules $agent_loader/lib/udev/rules.d/99-incus-agent.rules
|
||||||
substituteInPlace $agent_loader/etc/systemd/system/incus-agent.service --replace-fail 'TARGET/systemd' "$agent_loader/bin"
|
substituteInPlace $agent_loader/etc/systemd/system/incus-agent.service --replace-fail 'TARGET/systemd' "$agent_loader/bin"
|
||||||
|
|
||||||
|
mkdir $doc
|
||||||
|
cp -R doc/html $doc/
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
client = callPackage ./client.nix {
|
client = callPackage ./client.nix {
|
||||||
inherit
|
inherit
|
||||||
lts
|
lts
|
||||||
meta
|
|
||||||
patches
|
patches
|
||||||
src
|
|
||||||
vendorHash
|
vendorHash
|
||||||
version
|
version
|
||||||
;
|
;
|
||||||
|
inherit (finalAttrs) meta src;
|
||||||
};
|
};
|
||||||
|
|
||||||
tests = if lts then nixosTests.incus-lts.all else nixosTests.incus.all;
|
tests = if lts then nixosTests.incus-lts.all else nixosTests.incus.all;
|
||||||
|
@ -143,4 +176,4 @@ buildGoModule rec {
|
||||||
platforms = lib.platforms.linux;
|
platforms = lib.platforms.linux;
|
||||||
mainProgram = "incus";
|
mainProgram = "incus";
|
||||||
};
|
};
|
||||||
}
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue