Skip to content

Commit 68d96bd

Browse files
authored
Add service demo instructions (#1013)
* overview: add Nix installation instructions for Linux distros Closes: #942 * overview: add service demo instructions for older Nix versions Closes: #943 * overview: add service demo instructions for adding binary substituters Closes: #944
1 parent 4e4d1e3 commit 68d96bd

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

overview/default.nix

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ let
228228
<article class="page-width">
229229
${heading 1 null name}
230230
${render.metadata.one project.metadata}
231+
${render.options.many (pick.options project)}
232+
${render.examples.many (pick.examples project)}
231233
${optionalString (project.nixos.examples ? demo) (
232234
render.serviceDemo.one project.nixos.modules.services project.nixos.examples.demo
233235
)}
234-
${render.options.many (pick.options project)}
235-
${render.examples.many (pick.examples project)}
236236
</article>
237237
'';
238238

@@ -298,30 +298,49 @@ let
298298
servicePort = (builtins.head openPorts);
299299
in
300300
''
301-
${heading 2 "demo" "Run a demo deployment locally"}
301+
${heading 2 "demo" "Demo"}
302+
<details>
303+
<summary>Run service in a VM</summary>
302304
303305
<ol>
304-
<li><strong>Install Nix on your platform.</strong></li>
305306
<li>
306-
<strong>Download this Nix file to your computer.</strong>
307-
It obtains the NGIpkgs source code and declares a basic service configuration
308-
to be run in a virtual machine.
309-
${render.codeSnippet.one {
310-
filename = "default.nix";
311-
relative = true;
312-
downloadable = true;
313-
}}
307+
<strong>Install Nix</strong>
308+
<ul>
309+
<li>Arch Linux</li>
310+
<pre><code>pacman --sync --refresh --noconfirm curl git jq nix</code></pre>
311+
<li>Debian/Ubuntu</li>
312+
<pre><code>apt install --yes curl git jq nix</code></pre>
313+
</ul>
314+
</li>
315+
<li>
316+
<strong>Download a configuration file</strong>
317+
${render.codeSnippet.one {
318+
filename = "default.nix";
319+
relative = true;
320+
downloadable = true;
321+
}}
322+
</li>
323+
<li>
324+
<strong>Enable binary substituters</strong>
325+
<pre><code>NIX_CONFIG='substituters = https://cache.nixos.org/ https://ngi.cachix.org/'$'\n'''trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw='</code></pre>
326+
<pre><code>export NIX_CONFIG</code></pre>
314327
</li>
315328
<li>
316-
<strong>Build the virtual machine</strong> defined in <code>default.nix</code> and run it:
317-
<pre><code>nix-build && ./result</code></pre>
318-
Building <strong>will</strong> take a while.
329+
<strong>Build and run a virtual machine</strong>
330+
<ul>
331+
<li>Arch Linux, Debian Sid and Ubuntu 25.04</li>
332+
<pre><code>nix-build ./default.nix && ./result</code></pre>
333+
<li>Debian 12 and Ubuntu 24.04/24.10</li>
334+
<pre><code>rev=$(nix-instantiate --eval --attr sources.nixpkgs.rev https://github.com/ngi-nix/ngipkgs/archive/master.tar.gz | jq --raw-output)</code></pre>
335+
<pre><code>nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/$rev.tar.gz --packages nix --run "nix-build ./default.nix && ./result"</code></pre>
336+
</ul>
319337
</li>
320338
<li>
321-
<strong>Access the service</strong> with a web browser:
322-
<a href="http://localhost:${toString servicePort}">http://localhost:${toString servicePort}</a>
339+
<strong>Access the service</strong><br />
340+
Open a web browser at <a href="http://localhost:${toString servicePort}">http://localhost:${toString servicePort}</a> .
323341
</li>
324342
</ol>
343+
</details>
325344
'';
326345
};
327346

0 commit comments

Comments
 (0)