```Maak v1.0.0 – 无限可扩展的命令运行器,Lisp 构建系统```
Maak v1.0.0 – infinitely extensible command runner, build sys in Lisp

原始链接: https://github.com/jjba23/maak

maak 是一个命令运行器,其任务列表是一个普通的 Guile Scheme 模块:每个过程都成为可运行、可组合的任务,无需学习 DSL。任务是真正的 Scheme 函数——一个任务调用另一个任务只是函数调用,参数以命令行字符串形式传入。默认情况下命令无 shell 运行(`run` 接受程序和单独的 argv 字符串),因此带空格的路径保持完整,`--plan` 显示每个命令的 argv。它支持管道、后台作业、并行(`-j`)、干运行,以及 Guix、Nix、容器、Maven、uv 等的辅助功能。当 maak 回答关于 Maak 文件的问题时,它会读取而非执行该文件,从而即使文件不完整或机器缺少库,也能生成列表、计划和调用图。文档字符串兼作文档,`maak --list` 读起来像 `apropos`。编辑器支持是一等公民——通过 maak.el 支持 Emacs,以及 Neovim、Vim、VS Code、Helix、IntelliJ、Zed 和 Sublime Text 的集成——并且 contrib/ai 中附带 AI 技能文件。maak 是 MIT 许可证下的自由软件。

黑客新闻 新 | 过去 | 评论 | 提问 | 展示 | 工作 | 提交 登录 Maak v1.0.0 – 无限可扩展的命令运行器,用 Lisp 构建的构建系统 ( github.com/jjba23 ) 10 分 由 jjba23 1 天前 | 隐藏 | 过去 | 收藏 | 1 条评论 帮助 政治 16 小时前 [–] 也许我没有充分关注长描述,但你能澄清一下"helper, not a task"是什么意思吗? 回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

https://jointhefreeworld.org/ggg/dist/scheme-guile.svg https://jointhefreeworld.org/ggg/dist/gnu-guix.svg https://jointhefreeworld.org/ggg/dist/maak.svg https://jointhefreeworld.org/ggg/dist/license-mit.svg https://jointhefreeworld.org/ggg/dist/jointhefreeworld-org.svg

logo.svg

maak is a command runner, and its task list is a Lisp file. You write maak.scm — a perfectly normal Guile module — and every procedure in it becomes a task you can name on the command line. There is no DSL to learn and no second language to keep in your head: the build is the program.

(define-module (maak)
  #:declarative? #t
  #:use-module (maak maak))

;; A task is a λ: (define (build) ...) is (define build (lambda () ...)).
(define (build)
  "Compile every page in ./pages into ./build."
  (let ((out "build"))
    (mkdir-p out)
    (for-each (lambda (page)
                (run (list "pandoc" (~ "pages/~a.md" page)
                           "-o" (~ "~a/~a.html" out page))))
              '("index" "about"))
    (when (file-exists? "static/style.css")
      (cp "static/style.css" (~ "~a/style.css" out)))))

;; Two programs, one pipe, and a failure that names the stage that failed.
(define (check)
  "Lint every tracked page."
  (run-pipeline (list (list "git" "ls-files" "pages")
                      (list "xargs" "markdownlint"))))

;; Its arguments arrive as the strings typed on the command line.
(define (deploy host)
  "Ship ./build to HOST, replacing what is there."
  (unless (file-exists? "build/index.html")
    (task-error "nothing to deploy"
                #:hint "Run `maak build' first."))
  (run (list "rsync" "-av" "--delete" "build/" (~ "~a:/srv/www/" host))))

;; Procedures are values, so tasks compose like any other function.
(define (ci host)
  "Check, build and ship in one go."
  (check)
  (build)
  (deploy host))

The loop and the conditional expand into four commands, and --plan shows each one as the argv it is — no shell to re-parse, no quote to guess at:

$ maak --plan build
maak plan
  [1] build  mkdir -pv build
              cwd: /home/me/site
  [2] build  pandoc pages/index.md -o build/index.html
              cwd: /home/me/site
  [3] build  pandoc pages/about.md -o build/about.html
              cwd: /home/me/site
  [4] build  cp -r -v static/style.css build/style.css
              cwd: /home/me/site

Most build tools invent their own limited domain-specific language. Maak embraces the powerful λ Lisp and the amazing Guile Scheme programming language.

This also means your code is flexible, robust and reliable (+declarative) for at least the next 50 years.

  • Why it matters. Tasks are real Scheme functions: composable, testable, declarative, dry-runnable, parallelisable, and reproducible.
  • The entire language, not a DSL. Define functions, use lists and hash tables, write macros, import libraries. If you can write it in Guile, you can write it in a task.
  • Lambdas compose. A task calls another task with a function call, and a list of tasks is a list — no subprocess, no re-parsing a file to find out what to run.
  • Your editor already knows the language. Docstrings are the task list, the REPL is the development loop, and maak --list reads like apropos.
  • Guix and Nix are values too. A pin is a store path a task can decide on, not a string another tool has to interpret.
  • Shell-free by default. run takes a program and its arguments as separate strings, so a path with a space in it stays one argument.
  • Errors that read like sentences. task-error prints one line and a hint, exits non-zero, and keeps the backtrace behind --debug.

See the full list pipelines, background jobs, -j, guix, nix, containers, niri, downloads, gettext, maven, uv, python in Features.

A Maak file is read, not run, when maak answers a question about it: a top-level define, define* or a name bound to a lambda is a task, the #:export list decides which of them are visible, the docstring is the documentation and the lambda list is the argument grammar. That is what lets a listing, a plan and the call graph be answered for a file somebody is halfway through writing, on a machine that does not have its libraries.

resources/diagrams/task-description.svg

resources/maak-demo.gif

Start with the quick start, or open the whole documentation index.

PageWhat it covers
Quick startYour first Maak file: eight steps from a module to a dry run.
TasksHow a function becomes a task, what exports hide, how arguments arrive.
The command lineEvery option, the grammar of tasks and arguments, --list output.
ConfigurationEnvironment variables, and the parameters behind dry-run and quiet.
The built-in toolkitrun, pipelines, jobs, file helpers, task-error, gettext.
Rust and CargoCargo and rustup helpers, the structured command line, metadata as a value, artefact paths.
Python, uv and pyprojectuv helpers, the version and name a release reads, and the four CI checks.
Frontend projectsnpm, pnpm and yarn behind one set of procedures, and the package.json a release reads.
Task files in JSON, TOML and YAMLA task list without the language: the schema, the formats, their limits.
Maven, Gradle and the JVMThe Maven lifecycle and Gradle tasks as argv, wrapper detection, and the JVM reports.
Emacs Lisp packagesByte-compiling, ERT and checkdoc in batch, and the packaging conventions.
Guix, Nix and reproducibilityThe helpers that build the command line, and the ones that return values.
On StabilityWhat the versions mean, and the promises of stability
Why maak, and why LispWhat Make cannot do, and the table of Make flags that did carry over.
Editors, shells and the REPLmaak.el and the seven integrations, the shell completions, the REPL workflow.
Maak files and AI assistantsWhat to ask maak instead of guessing, the rules a Maak file is reviewed against, and a block for a project’s agents file.

The manual page is installed with the program (man maak, or maak man in a checkout), the technical Guile API documentation is published at https://jointhefreeworld.org/api-docs/maak/index.html, and every release is recorded in NEWS.org.

Emacs is the first-class citizen. maak.el is maak’s canonical front end: pick a task, prompt for its arguments, watch the output and jump to the definition, from inside Emacs, from the same maak.scm the command line runs.

The other editors are also served. Neovim, Vim, VS Code, Helix, IntelliJ, Zed and Sublime Text each have an integration in contrib/ .

Editors, shells and the REPL has the details, and every integration has a README of its own.

An assistant is served the same way: contrib/ai ships a skill file — the Maak file’s rules, its vocabulary and the loop that checks the work, as one context file — and Maak files and AI assistants says what to ask maak instead of guessing.

Guix, Nix, Homebrew, the container image, the RPM and the Debian package are all in Installing maak. From a checkout, the launcher runs this tree’s own sources:

guix shell -m manifest.scm -- ./scripts/maak --list

Bug reports, patches, the AI policy and the code of conduct are in Community, contributing and conduct. If you like this work, you can buy me a cup of coffee ☕ so I can keep going with a lot of motivation.

maak, and all of its source code, build files and documentation — this document included — are free software, licensed under the MIT License (MIT).

https://opensource.org/license/mit

The full text is in the LICENSE file shipped with the source.

In short: use it, study it, change it, share it — and keep the copyright notice and the permission notice with the copies you pass on.


Happy hacking! ✨

maak runs the build, release and site automation of many projects, see a list in Who uses maak.

Using maak in your project? Send a link and it can be listed there.

联系我们 contact @ memedata.com