garn is an effort to give a Typescript-based alternative to Nix, and an easier CLI interface. It’s been discussed before, but development is happening very quickly, so I thought I’d create a devlog thread here. If you don’t want to hear more about it, you can mute it, and if you do, you can follow it.
Version 0.0.18 has been released.
Highlights:
-
A new
editcommand. A lot of the power of garn, where it almost feels likegarn.tsfiles write themselves, comes from IDE integration. Because we use Deno instead of the more traditional Node, a lot of people don’t have their editors set up fully yet. We previously had a garnExecutable,editGarnConfig, that you could expose for users. But that had problems, such as being less discoverable, and breaking if yourgarn.tsfile was broken. Now, we made editing a built-in. This means you can just rungarn editand you’ll opengarn.tson an editor configured with autocompletion and other features. Currently the only editor option is VSCodium, but we’re very open to PRs - see this file. -
garn no longer ignores untracked files. Previously you’d get confusing errors about files missing if you hadn’t yet
git added them. This was because (controversially) Nix behaved similarly. We submitted a patch to Nix, and made garn already use that patch. - Multiple executables in Haskell projects. Previously you needed exactly one executable, which was quite arbitrary and confusing. Now any number of executables, including none, is supported.
-
Make
garn initadd executables to Haskell projects based on the executables listed in the cabal file. - Overriding Haskell dependency versions. Now you can write, for example:
export const project = haskell.mkHaskellProject({
description: "",
compiler: "ghc94",
src: ".",
executables: ["foo"],
// This is new
overrideDependencies: {
"string-conversions": "0.3.0.3",
},
})
And you get the correponding version from Hackage, rather than the default one from the package set. This is as easy as Stack, but with the power of Nix.
-
garn entertop-levelEnvironments. PreviouslyEnvironments, unlike everything else, didn’t really work at the top-level, and instead had to be part of aProject.
And a new release, with the ability to easily import local and remote flakes. E.g.:
const flake = garn.importFromGithub({
repo: "martinvonz/jj",
revOrRef: "v0.11.0",
});
export const devEnv = garn.emptyEnvironment.withDevTools([
flake.getPackage("default"),
]);
This should help incrementally moving over if that’s your thing.
Full blog post: garnix | the nix CI
Seems interesting. The CLI is written in TS, yes? How do you like TS for CLI work?
It’s actually written in Haskell! The CLI has to be a different program than the garn.ts file users write (since, among other reasons, otherwise syntax errors in the file would leave you with a completely unusable garn; and things like garn init wouldn’t be available). Mostly for reasons of familiarity, we wrote it in Haskell. But it kind of really is just the CLI - all the more substantive logic is in TS.