Initial commit

This commit is contained in:
puck 2024-10-03 23:57:22 +00:00
commit 55a1efa08f
60 changed files with 5485 additions and 0 deletions

4
docs/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
/build
/node_modules
/modules/generated/pages/*
!/modules/generated/pages/.gitkeep

14
docs/antora-playbook.yml Normal file
View file

@ -0,0 +1,14 @@
site:
title: Zilch
start_page: zilch::index.adoc
content:
sources:
- url: ./..
start_path: docs
ui:
bundle:
url: https://gitlab.com/antora/antora-ui-default/-/jobs/artifacts/HEAD/raw/build/ui-bundle.zip?job=bundle-stable
snapshot: true
supplemental_files: ./supplemental

4
docs/antora.yml Normal file
View file

@ -0,0 +1,4 @@
name: zilch
version: '0.1'
nav:
- modules/ROOT/nav.adoc

10
docs/docread/default.nix Normal file
View file

@ -0,0 +1,10 @@
{ pkgs, eggDerivation, chickenPackages }:
eggDerivation {
name = "docread";
src = ./.;
buildInputs = with chickenPackages.chickenEggs; [
r7rs
(pkgs.callPackage ../../core {})
];
}

9
docs/docread/docread.egg Normal file
View file

@ -0,0 +1,9 @@
((version "0.0.1")
(synopsis "read doc comments")
(author "puck")
(dependencies r7rs zilch)
(component-options
(csc-options "-X" "r7rs" "-R" "r7rs" "-optimize-level" "3"))
(components
(program docread
(source "docread.scm"))))

88
docs/docread/docread.scm Normal file
View file

@ -0,0 +1,88 @@
(import (scheme base) (scheme file) (scheme write) (chicken read-syntax) (chicken process-context) (chicken irregex) (chicken format) (chicken process) (chicken file) (zilch zexpr))
;; Return a string version of the passed-in val, but properly quoted as s-expression.
(define (quotify val)
(call-with-port (open-output-string) (lambda (port) (write val port) (get-output-string port))))
;; Read a file, and rewrite all doc comments (comments starting with ";;") with comment s-expressions.
(define (read-file-with-rewritten-comments f)
(define port (open-input-file f))
(define str-out (open-output-string))
(write-string "(\n" str-out)
(do ((buf (string) (read-string 2048 port))) ((eof-object? buf) #f) (write-string buf str-out))
(close-input-port port)
(write-string "\n)" str-out)
(define comments-fixed
(irregex-replace/all
; Written weirdly to avoid the regexp catching itself.
; TODO(puck): only apply at the start of lines?
(string->irregex ";{2,} *([^\\n]*)" 'm)
(get-output-string str-out)
;; TODO: do we need the space here? this could also be a reader macro instead.
(lambda (m) (string-append " " (quotify (list 'comment (irregex-match-substring m 1)))))))
(call-with-port (open-input-string comments-fixed) (lambda (port) (read port))))
;; Iterate over the contents of a define-library, and collect comments on certain defines.
(define (parse-library-contents contents lib-comments)
(define comments '())
(define defines '())
(define imports '())
(define exports '())
(for-each (lambda (j)
(cond
;; Track imports and exports respectively.
((eq? (car j) 'import) (set! imports (append (cdr j) imports)))
((eq? (car j) 'export) (set! exports (append (cdr j) exports)))
((eq? (car j) 'begin)
; For each top-level object in the (begin) block...
(for-each (lambda (i)
(cond
; If we see a preprocessed comment, collect it
((and (list? i) (eq? (car i) 'comment)) (set! comments (cons (cadr i) comments)))
; If we then see either a define or a define-record-type, emit the comments.
((and (list? i) (or (eq? (car i) 'define) (eq? (car i) 'define-record-type)))
(if (list? (cadr i))
; TODO(puck): bad code
(set! defines (cons (cons (car (cadr i)) (cons (cadr i) (reverse comments))) defines))
(set! defines (cons (cons (cadr i) (cons (cadr i) (reverse comments))) defines)))
(set! comments '()))))
(cdr j)))))
contents)
(define out-path (string-append root "/docs/modules/generated/pages"))
(define first #t)
(for-each (lambda (l) (set! out-path (string-append out-path (if first "/" ".") (symbol->string l))) (set! first #f)) (car contents))
(set! out-path (string-append out-path ".adoc"))
(define out-file (open-output-file out-path))
; Print out the comments
(fprintf out-file "= `~S`\n" (car contents))
(for-each (lambda (l) (fprintf out-file "~A\n" l)) lib-comments)
(fprintf out-file "\n:toc:\n\n")
(for-each (lambda (i)
(define val (assoc i defines))
(unless (eq? val #f)
(fprintf out-file "== `+~S+`\n" (cadr val))
(for-each (lambda (l) (fprintf out-file "~A\n" l)) (cddr val))
(fprintf out-file "\n")))
exports)
(close-output-port out-file))
(define root (call-with-input-pipe "git rev-parse --show-toplevel" (lambda (p) (define path (read-string 9999999 p)) (string-copy path 0 (- (string-length path) 1)))))
(define (parse-file contents)
(define comments '())
(for-each (lambda (j)
(cond ((eq? (car j) 'define-library) (parse-library-contents (cdr j) (reverse comments)))
((eq? (car j) 'comment) (set! comments (cons (cadr j) comments))))) contents))
(define (process-file fname _)
(parse-file (read-file-with-rewritten-comments fname)))
(find-files root #:test ".*\\.(sld|scm)" #:action process-file)

View file

@ -0,0 +1,32 @@
* xref:index.adoc[]
* xref:nixexpr.adoc[]
* xref:zexp.adoc[]
* ++(zilch)++
** xref:generated:zilch.file.adoc[++(zilch file)++]
** xref:generated:zilch.magic.adoc[++(zilch magic)++]
** xref:generated:zilch.nixpkgs.adoc[++(zilch nixpkgs)++]
** xref:generated:zilch.statusbar.adoc[++(zilch statusbar)++]
** xref:generated:zilch.zexpr.adoc[++(zilch zexpr)++]
* ++(zilch lang go)++
** xref:generated:zilch.lang.go.adoc[++(zilch lang go)++]
** xref:generated:zilch.lang.go.core.adoc[++(zilch lang go core)++]
** xref:generated:zilch.lang.go.fetch.adoc[++(zilch lang go fetch)++]
** xref:generated:zilch.lang.go.mod.adoc[++(zilch lang go mod)++]
** xref:generated:zilch.lang.go.package.adoc[++(zilch lang go package)++]
** xref:generated:zilch.lang.go.stdlib.adoc[++(zilch lang go stdlib)++]
** xref:generated:zilch.lang.go.sum.adoc[++(zilch lang go sum)++]
** xref:generated:zilch.lang.go.version.adoc[++(zilch lang go version)++]
** xref:generated:zilch.lang.go.vfs.adoc[++(zilch lang go vfs)++]
* ++(zilch lib)++
** xref:generated:zilch.lib.getopt.adoc[++(zilch lib getopt)++]
** xref:generated:zilch.lib.hash.adoc[++(zilch lib hash)++]
** ++(zilch nix)++
*** xref:generated:zilch.nix.binproto.adoc[++(zilch nix binproto)++]
*** xref:generated:zilch.nix.daemon.adoc[++(zilch nix daemon)++]
*** xref:generated:zilch.nix.drv.adoc[++(zilch nix drv)++]
*** xref:generated:zilch.nix.hash.adoc[++(zilch nix hash)++]
*** xref:generated:zilch.nix.path.adoc[++(zilch nix path)++]
* xref:architecture.adoc[]

View file

@ -0,0 +1,11 @@
= Architecture
`(zilch nix binproto)` contains an implementation of the binary protocol used both
to talk to the daemon and to build NAR files.
On top of that is `(zilch nix daemon)`, which implements a version (which?) of
the Nix worker protocol.
`(zilch nix drv)` allows reading and writing .drv objects.
`(zilch nix path)` contains the helpers for building store paths of various types.

View file

@ -0,0 +1,22 @@
= Introduction
Zilch is an experimental testbed for implementing reproducible compilation
technologies, based on Nix, but steering clear of most of the parts of Nix
built on top of the derivation concept.
Like Guix, it is built on top of Scheme. However, unlike Guix, it does not
require a second, incompatible Nix-like daemon to be installed.
Features:
* Solid, reusable, Nix daemon protocol core
* Batteries included
* Intercompatible with Nixpkgs and other, arbitrary, Nix expressions.
== Current work
Current effort in Zilch is working on making "incremental", bitesize,
derivations to work. This is currently being implemented for Go.
== Contributing
Come join [.line-through]#us# me at `#zilch` on https://libera.chat[libera.chat]!

View file

@ -0,0 +1,41 @@
= Nix expression support
When `(nix reader)` is imported, it is possible to execute Nix code inline with
Scheme code. Simply wrap your Nix code in curly brackets:
[,scheme]
----
(write
(string-append
"Hello, Nix version"
{ builtins.nixVersion }))
----
The following values can be translated:
|===
| Nix | Scheme | Notes
| string | string | (Loses string context.)
| integer | number |
| float | number |
| boolean | boolean |
| lambda | procedure | (with single argument)
| list | vector or list | Depends on the status of `\*translate-list-as-vector*`
| attrset | alist |
| builtin | procedure |
| external value | symbol, other unknown objects |
|===
If a value in Nix is preceded with a comma, it is unquoted, similar to
`(unquote)` in a Scheme quasiquotation. If prefixed with a single quote, it is
`(quote)`-d.
[,scheme]
----
(define
(test-append foo)
(string-append "Hello, " foo))
(write
{ ,test-append "world!") })
----

View file

@ -0,0 +1,28 @@
= zexps
zexps, similar to g-expressions in Guix, are a way to generate
S-expressions that are taggged with store paths. But that's where
the similarity ends.
To create a zexp, you can use either the full syntax, or the reader macro:
[,scheme]
----
#~(foo bar #$baz)
; is identical to:
(zexp (foo bar (zexp-unquote baz)))
----
`(zexp-unquote VAL)` returns the value that the zexp (or any compatible record)
contains, while gathering the `zexp-unquote`d values used.
Like quasiquotation, zexps can use `unquote`, including ``zexp-unquote``d values
inside the ``unquote``d code. ``unquote``d code is evaluated when the `zexp` is evaluated.
[,scheme]
----
(define world #~,(begin (write "hello") "world"))
(define hello #~("hello" ,(string-append "very " "cute") #$world))
; When hello is used as zexp, it will also write "hello" to the output port.
----

1436
docs/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

6
docs/package.json Normal file
View file

@ -0,0 +1,6 @@
{
"dependencies": {
"@antora/cli": "^3.1.9",
"@antora/site-generator": "^3.1.9"
}
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,17 @@
<header class="header">
<nav class="navbar">
<div class="navbar-brand">
<div class="navbar-item">
zilch
</div>
<button class="navbar-burger" data-target="topbar-nav">
<span></span>
<span></span>
<span></span>
</button>
</div>
<div id="topbar-nav" class="navbar-menu">
</div>
</nav>
</header>

View file

@ -0,0 +1,10 @@
<div class="toolbar" role="navigation">
{{> nav-toggle}}
{{#with site.homeUrl}}
<a href="{{{relativize this}}}" class="home-link{{#if @root.page.home}} is-current{{/if}}"></a>
{{/with}}
{{> breadcrumbs}}
{{> page-versions}}
</div>