lol

incus: build and expose documentation (#395767)

authored by

Adam C. Stephens and committed by
GitHub
017583d6 1fb5f0f2

+274 -6
+1
nixos/modules/virtualisation/incus.nix
··· 129 129 130 130 environment = lib.mkMerge [ 131 131 { 132 + INCUS_DOCUMENTATION = "${cfg.package.doc}/html"; 132 133 INCUS_EDK2_PATH = ovmf; 133 134 INCUS_LXC_HOOK = "${cfg.lxcPackage}/share/lxc/hooks"; 134 135 INCUS_LXC_TEMPLATE_CONFIG = "${pkgs.lxcfs}/share/lxc/config";
+4
nixos/tests/incus/ui.nix
··· 66 66 67 67 testScript = '' 68 68 machine.wait_for_unit("incus.service") 69 + machine.wait_for_unit("incus-preseed.service") 69 70 70 71 # Check that the INCUS_UI environment variable is populated in the systemd unit 71 72 machine.succeed("systemctl cat incus.service | grep 'INCUS_UI'") 72 73 73 74 # Ensure the endpoint returns an HTML page with 'Incus UI' in the title 74 75 machine.succeed("curl -kLs https://localhost:8443/ui | grep '<title>Incus UI</title>'") 76 + 77 + # Ensure the documentation is rendering correctly 78 + machine.succeed("curl -kLs https://localhost:8443/documentation/ | grep '<title>Incus documentation</title>'") 75 79 76 80 # Ensure the application is actually rendered by the Javascript 77 81 machine.succeed("PYTHONUNBUFFERED=1 selenium-script")
+26
pkgs/by-name/in/incus/docs.patch
··· 1 + diff --git i/doc/conf.py w/doc/conf.py 2 + index 8d042818b..b4f0572bd 100644 3 + --- i/doc/conf.py 4 + +++ w/doc/conf.py 5 + @@ -8,10 +8,6 @@ import yaml 6 + from git import Repo 7 + import filecmp 8 + 9 + -# Download and link swagger-ui files 10 + -if not os.path.isdir('.sphinx/deps/swagger-ui'): 11 + - Repo.clone_from('https://github.com/swagger-api/swagger-ui', '.sphinx/deps/swagger-ui', depth=1) 12 + - 13 + os.makedirs('.sphinx/_static/swagger-ui/', exist_ok=True) 14 + 15 + if not os.path.islink('.sphinx/_static/swagger-ui/swagger-ui-bundle.js'): 16 + @@ -151,10 +147,6 @@ if os.path.exists("./related_topics.yaml"): 17 + with open("./related_topics.yaml", "r") as fd: 18 + myst_substitutions.update(yaml.safe_load(fd.read())) 19 + 20 + -intersphinx_mapping = { 21 + - 'cloud-init': ('https://cloudinit.readthedocs.io/en/latest/', None) 22 + -} 23 + - 24 + if ("LOCAL_SPHINX_BUILD" in os.environ) and (os.environ["LOCAL_SPHINX_BUILD"] == "True"): 25 + swagger_url_scheme = "/api/#{{path}}" 26 + else:
+39 -6
pkgs/by-name/in/incus/generic.nix
··· 13 13 buildGoModule, 14 14 fetchFromGitHub, 15 15 acl, 16 + buildPackages, 16 17 cowsql, 17 18 incus-ui-canonical, 18 19 libcap, ··· 27 28 28 29 let 29 30 pname = "incus${lib.optionalString lts "-lts"}"; 31 + docsPython = buildPackages.python3.withPackages ( 32 + py: with py; [ 33 + furo 34 + gitpython 35 + linkify-it-py 36 + canonical-sphinx-extensions 37 + myst-parser 38 + pyspelling 39 + sphinx 40 + sphinx-autobuild 41 + sphinx-copybutton 42 + sphinx-design 43 + sphinx-notfound-page 44 + sphinx-remove-toctrees 45 + sphinx-reredirects 46 + sphinx-tabs 47 + sphinxcontrib-jquery 48 + sphinxext-opengraph 49 + ] 50 + ); 30 51 in 31 52 32 - buildGoModule rec { 53 + buildGoModule (finalAttrs: { 33 54 inherit 34 - patches 35 55 pname 36 56 vendorHash 37 57 version ··· 40 60 outputs = [ 41 61 "out" 42 62 "agent_loader" 63 + "doc" 43 64 ]; 44 65 45 66 src = fetchFromGitHub { 46 67 owner = "lxc"; 47 68 repo = "incus"; 48 - rev = "refs/tags/v${version}"; 69 + tag = "v${version}"; 49 70 inherit hash; 50 71 }; 72 + 73 + patches = [ ./docs.patch ] ++ patches; 51 74 52 75 excludedPackages = [ 53 76 # statically compile these ··· 61 84 nativeBuildInputs = [ 62 85 installShellFiles 63 86 pkg-config 87 + docsPython 64 88 ]; 65 89 66 90 buildInputs = [ ··· 82 106 CGO_LDFLAGS_ALLOW = "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"; 83 107 84 108 postBuild = '' 109 + # build docs 110 + mkdir -p .sphinx/deps 111 + ln -s ${buildPackages.python3.pkgs.swagger-ui-bundle.src} .sphinx/deps/swagger-ui 112 + substituteInPlace Makefile --replace-fail '. $(SPHINXENV) ; ' "" 113 + make doc-incremental 114 + 115 + # build some static executables 85 116 make incus-agent incus-migrate 86 117 ''; 87 118 ··· 111 142 cp internal/server/instance/drivers/agent-loader/systemd/incus-agent.service $agent_loader/etc/systemd/system/ 112 143 cp internal/server/instance/drivers/agent-loader/systemd/incus-agent.rules $agent_loader/lib/udev/rules.d/99-incus-agent.rules 113 144 substituteInPlace $agent_loader/etc/systemd/system/incus-agent.service --replace-fail 'TARGET/systemd' "$agent_loader/bin" 145 + 146 + mkdir $doc 147 + cp -R doc/html $doc/ 114 148 ''; 115 149 116 150 passthru = { 117 151 client = callPackage ./client.nix { 118 152 inherit 119 153 lts 120 - meta 121 154 patches 122 - src 123 155 vendorHash 124 156 version 125 157 ; 158 + inherit (finalAttrs) meta src; 126 159 }; 127 160 128 161 tests = if lts then nixosTests.incus-lts.all else nixosTests.incus.all; ··· 143 176 platforms = lib.platforms.linux; 144 177 mainProgram = "incus"; 145 178 }; 146 - } 179 + })
+44
pkgs/development/python-modules/canonical-sphinx-extensions/default.nix
··· 1 + { 2 + lib, 3 + buildPythonPackage, 4 + fetchPypi, 5 + setuptools, 6 + beautifulsoup4, 7 + docutils, 8 + gitpython, 9 + requests, 10 + sphinx, 11 + }: 12 + 13 + buildPythonPackage rec { 14 + pname = "canonical-sphinx-extensions"; 15 + version = "0.0.27"; 16 + pyproject = true; 17 + 18 + src = fetchPypi { 19 + pname = "canonical_sphinx_extensions"; 20 + inherit version; 21 + hash = "sha256-ZorSmn+PAVS8xO7X3zk6u3W7pn3JB9w0PhFAXzv6l78="; 22 + }; 23 + 24 + build-system = [ 25 + setuptools 26 + ]; 27 + 28 + dependencies = [ 29 + beautifulsoup4 30 + docutils 31 + gitpython 32 + requests 33 + sphinx 34 + ]; 35 + 36 + doCheck = false; 37 + 38 + meta = { 39 + description = "A collection of Sphinx extensions used by Canonical documentation"; 40 + homepage = "https://pypi.org/project/canonical-sphinx-extensions"; 41 + license = lib.licenses.asl20; 42 + maintainers = with lib.maintainers; [ ]; 43 + }; 44 + }
+49
pkgs/development/python-modules/pyspelling/default.nix
··· 1 + { 2 + lib, 3 + buildPythonPackage, 4 + fetchPypi, 5 + hatchling, 6 + beautifulsoup4, 7 + html5lib, 8 + lxml, 9 + markdown, 10 + pyyaml, 11 + soupsieve, 12 + wcmatch, 13 + }: 14 + 15 + buildPythonPackage rec { 16 + pname = "pyspelling"; 17 + version = "2.10"; 18 + pyproject = true; 19 + 20 + src = fetchPypi { 21 + inherit pname version; 22 + hash = "sha256-rNZxM8G3zs1BDj1EieYfLksfC2rPGubEjCQPuyFynDc="; 23 + }; 24 + 25 + build-system = [ 26 + hatchling 27 + ]; 28 + 29 + dependencies = [ 30 + beautifulsoup4 31 + html5lib 32 + lxml 33 + markdown 34 + pyyaml 35 + soupsieve 36 + wcmatch 37 + ]; 38 + 39 + pythonImportsCheck = [ 40 + "pyspelling" 41 + ]; 42 + 43 + meta = { 44 + description = "Spell checker"; 45 + homepage = "https://pypi.org/project/pyspelling"; 46 + license = lib.licenses.mit; 47 + maintainers = with lib.maintainers; [ ]; 48 + }; 49 + }
+60
pkgs/development/python-modules/sphinx-remove-toctrees/default.nix
··· 1 + { 2 + lib, 3 + buildPythonPackage, 4 + fetchPypi, 5 + hatchling, 6 + sphinx, 7 + pre-commit, 8 + ipython, 9 + myst-parser, 10 + sphinx-book-theme, 11 + pytest, 12 + }: 13 + 14 + buildPythonPackage rec { 15 + pname = "sphinx-remove-toctrees"; 16 + version = "1.0.0.post1"; 17 + pyproject = true; 18 + 19 + src = fetchPypi { 20 + pname = "sphinx_remove_toctrees"; 21 + inherit version; 22 + hash = "sha256-SAjR7fFRwG7/bSw5Iux+vJ/Tqhdi3hsuFnSjf1rJzi0="; 23 + }; 24 + 25 + build-system = [ 26 + hatchling 27 + ]; 28 + 29 + dependencies = [ 30 + sphinx 31 + ]; 32 + 33 + optional-dependencies = { 34 + code_style = [ 35 + pre-commit 36 + ]; 37 + docs = [ 38 + ipython 39 + myst-parser 40 + sphinx-book-theme 41 + ]; 42 + tests = [ 43 + ipython 44 + myst-parser 45 + pytest 46 + sphinx-book-theme 47 + ]; 48 + }; 49 + 50 + pythonImportsCheck = [ 51 + "sphinx_remove_toctrees" 52 + ]; 53 + 54 + meta = { 55 + description = "Reduce your documentation build size by selectively removing toctrees from pages"; 56 + homepage = "https://pypi.org/project/sphinx-remove-toctrees/"; 57 + license = lib.licenses.mit; 58 + maintainers = with lib.maintainers; [ ]; 59 + }; 60 + }
+41
pkgs/development/python-modules/sphinx-reredirects/default.nix
··· 1 + { 2 + lib, 3 + buildPythonPackage, 4 + fetchPypi, 5 + setuptools, 6 + sphinx, 7 + }: 8 + 9 + buildPythonPackage rec { 10 + pname = "sphinx-reredirects"; 11 + version = "0.1.6"; 12 + pyproject = true; 13 + 14 + src = fetchPypi { 15 + pname = "sphinx_reredirects"; 16 + inherit version; 17 + hash = "sha256-xJHLpUX2e+lpdQhyeBjYYmYmNmJFrmRFb+KfN+m76mQ="; 18 + }; 19 + 20 + build-system = [ 21 + setuptools 22 + ]; 23 + 24 + dependencies = [ 25 + sphinx 26 + ]; 27 + 28 + pythonImportsCheck = [ 29 + "sphinx_reredirects" 30 + ]; 31 + 32 + meta = { 33 + description = "Handles redirects for moved pages in Sphinx documentation projects"; 34 + homepage = "https://pypi.org/project/sphinx-reredirects"; 35 + license = with lib.licenses; [ 36 + bsd3 37 + mit 38 + ]; 39 + maintainers = with lib.maintainers; [ ]; 40 + }; 41 + }
+10
pkgs/top-level/python-packages.nix
··· 2192 2192 2193 2193 canmatrix = callPackage ../development/python-modules/canmatrix { }; 2194 2194 2195 + canonical-sphinx-extensions = 2196 + callPackage ../development/python-modules/canonical-sphinx-extensions 2197 + { }; 2198 + 2195 2199 canonicaljson = callPackage ../development/python-modules/canonicaljson { }; 2196 2200 2197 2201 canopen = callPackage ../development/python-modules/canopen { }; ··· 13320 13324 13321 13325 pyspellchecker = callPackage ../development/python-modules/pyspellchecker { }; 13322 13326 13327 + pyspelling = callPackage ../development/python-modules/pyspelling { }; 13328 + 13323 13329 pyspf = callPackage ../development/python-modules/pyspf { }; 13324 13330 13325 13331 pyspice = callPackage ../development/python-modules/pyspice { }; ··· 16164 16170 sphinx-prompt = callPackage ../development/python-modules/sphinx-prompt { }; 16165 16171 16166 16172 sphinx-pytest = callPackage ../development/python-modules/sphinx-pytest { }; 16173 + 16174 + sphinx-reredirects = callPackage ../development/python-modules/sphinx-reredirects { }; 16175 + 16176 + sphinx-remove-toctrees = callPackage ../development/python-modules/sphinx-remove-toctrees { }; 16167 16177 16168 16178 sphinx-rtd-dark-mode = callPackage ../development/python-modules/sphinx-rtd-dark-mode { }; 16169 16179