garn version v0.0.15
Release announcement for garn version v0.0.15
Today we released version v0.0.15 of Garn and the accompanying typescript library.
How to get it
If you don't have Garn installed you can follow our installation instructions. If you already have Garn installed, then follow our updating guide.
New features
It's a small release with the following additional user-facing features:
Added a --version flag
Added golang version 1.21
Simplify declaring Checks and Executables
We added simpler overloads to the functions Project.addCheck, Project.addExecutable, Project.check, Project.shell, etc. in the typescript library.
So for example a Check definition used to look like this:
import * as garn from "https://garn.io/ts/v0.0.15/mod.ts"; export const myProject = garn.javascript .mkNpmProject({ description: "my cool project", nodeVersion: "18", src: ".", }) .addCheck("no todos allowed")`! grep -r TODO src`;
That syntax in the last line with the backticks after the function call to addCheck is valid, but unusual. We designed the API like this to allow to reference packages from nixpkgs and splice them into the script snippets, for example like this:
import * as garn from "https://garn.io/ts/v0.0.15/mod.ts"; import * as pkgs from "https://garn.io/ts/v0.0.15/nixpkgs.ts"; export const myProject = garn.javascript .mkNpmProject({ description: "my cool project", nodeVersion: "18", src: ".", }) .addCheck("no todos allowed")`! ${pkgs.ripgrep}/bin/rg TODO src`;
Notice that just by splicing in pkgs.ripgrep in that script snippet, you would declare a dependency of that check on ripgrep, so Garn would automatically install ripgrep when running this check. That felt very fancy and cool, and it's also sometimes needed, but it's also much less common than we thought. So now you can just write this instead:
import * as garn from "https://garn.io/ts/v0.0.15/mod.ts"; import * as pkgs from "https://garn.io/ts/v0.0.15/nixpkgs.ts"; export const myProject = garn.javascript .mkNpmProject({ description: "my cool project", nodeVersion: "18", src: ".", }) .withDevTools([pkgs.ripgrep]) .addCheck("no todos allowed", "! rg TODO src");
The old syntax still works, in case you want to splice in packages. (Or in case you want to feel fancy and cool.)
Better handling of non-zero exit codes of spawned child processes
Consider a failing Executable like this:
import * as garn from "https://garn.io/ts/v0.0.15/mod.ts"; export const foo = garn.shell("echo some error message ; exit 23");
In version v0.0.15 garn run foo now:
- exits with exit code 23, and
- doesn't output a confusing error message about a failed child process. Instead it leaves printing error messages to the child process.
Thank to Simon Hengel for submitting a PR for this!
Remove unused flake inputs
The generated flake files now only include flake inputs that are actually used. This is more an internal detail, but it's included here, since it means that Garn should run a little faster now.
Continue Reading
We've added incremental compilation to garnix. In this blog, we discuss prior art on incremental compilation in Nix, and describe our own design.
A short note about custom typing for functions in Nix