8000 GitHub - nixcloud/tour_of_nix: Sourcecode to the https://nixcloud.io/tour/ 'a tour of nix' · GitHub
[go: up one dir, main page]

Skip to content

About

Sourcecode to the https://nixcloud.io/tour/ 'a tour of nix'

Resources

Stars

142 stars

Watchers

7 watching

Forks

Repository files navigation

introduction

this repository contains 'a tour of nix', an interactive programming guide dedicated to the nix programming language.

https://nixcloud.io/tour/

happy learning!

meerkats FTW

building & running

the tour runs a real, current nix in the browser: unkernel, a linux kernel compiled to webassembly, runs the aarch64 nix-instantiate from nixpkgs off a read-only disk image. the pieces are pinned like in trynix. vm/README.md has the details.

nix build                      # the static site in ./result
nix run .#serve                # serve it on http://127.0.0.1:8137/

result/ is a plain static site, any web server will do, for example:

python3 -m http.server -d result

note: opening index.html from file:// does not work; it needs a web server. the browser needs JSPI (webassembly's javascript promise integration): chrome 137, firefox 153 or safari 27.

the build also evaluates every solution in questions.json with nix and fails if one does not evaluate (nix build .#expected).

the 2014 version used nix 1.9 compiled with emscripten (nix-instantiate.js):

https://lastlog.de/blog/tour_of_nix.html

collaboration

every question is one markdown file, questions/<path>.md, where <path> is its id in the tour's url (?id=functions/minmax). questions/order.txt lists their files in order (functions/minmax.md). a file looks like this:

---
topic: Strings
youtube: https://www.youtube.com/watch?v=...
---

the question's text, in markdown.

```nix code
the code the reader starts from
```

```nix solution
the solution
```

edit them, run nix build and reload the 'tour' in your browser. the build turns them into questions.json (tools/build-questions.mjs) and fails, saying why, when a file is not in this form, not listed in order.txt, or its solution does not evaluate. the last question of the tour, https://nixcloud.io/tour/?id=end, has a guide on editing questions in the browser:

ctrl+, - loads markdown into the editor
ctrl+. - compiles markdown2html into the right side
ctrl+s - saves the question as its markdown file into your downloads directory

license

the questions.json file is licensed as:

   GNU LESSER GENERAL PUBLIC LICENSE
       Version 2.1, February 1999

exactly as the original nix codebase.

third party

we bundled many different tools:

see COPYING.md for details on their license.

oh, and there is this font/ - directory. really don't have a clue what license that uses. was from google and is probably licensed 'world domination with no privacy' or something... not sure...

nix in the browser

nothing of it is in this repository: nix build fetches it, pinned by hash in flake.nix and flake.lock:

  • nix and its runtime closure (aarch64-linux, from cache.nixos.org): LGPL-2.1 and the licenses of its dependencies
  • the library of nixpkgs (lib): MIT
  • unkernel: MIT and GPL-2.0-only (the kernel)
  • ghostty-web: MIT

the built site carries their license files next to them (vm/vendor/).

authors

thanks

  • Farid Zakaria for trynix, which runs real nix programs in the browser on unkernel: it showed how this tour could run a real, current nix, and its pins, its xz decoder fix and its headers are what the tour builds on
  • Pooya Parsa for unkernel, the linux compiled to webassembly that nix runs on here

meerkats FTW

About

Sourcecode to the https://nixcloud.io/tour/ 'a tour of nix'

Resources

Stars

142 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0