incus: build and expose documentation

+70 -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 + })