Dec 7, 2023Alex David

garn v0.0.19: Bringing existing flake files into your garn project

Release announcement for garn version v0.0.19, which includes the ability to import Nix flakes from the internet and from your repository.

Today we're releasing Garn v0.0.19, which includes the ability to import existing flake files into your Garn project.

This is useful for depending on flakes hosted online, for example on GitHub. But it can also help with migrating existing Nix flake projects over to Garn.

Importing flakes from online sourcesshare

You can pull in flake files from git repositories using importFromGithub, importFromGitlab, and importFromSourcehut.

For example the following Garn file creates an environment with Jujutsu installed (an alternative CLI tool for git repos):

const flake = garn.importFromGithub({
  repo: "martinvonz/jj",
  revOrRef: "v0.11.0",

export const devEnv = garn.emptyEnvironment.withDevTools([

You can enter the Environment with garn enter devEnv. Inside there, you will have access to the jj executable. And wherever you run this it will be the same version everywhere.

If you want to import a repo that's not on GitHub, GitLab or SourceHut, you can use the lower-level importFlake.

Importing flakes from within your reposhare

You can use callFlake to import an existing flake file that is checked into the same repo as your Garn file. This is mostly useful for migrating existing nixified repos to Garn.

Working with imported flakesshare

These imported flakes can be combined with your existing Garn project using the ImportedFlake helpers.

You can convert apps, checks, dev-shells, and packages from your flake file into Garn Executables, Checks, Environments, and Packages, respectively.

Here is an example for what a Garn file could look like that imports an existing flake file from ./legacy/flake.nix:

const flake = callFlake("./legacy");

export const main = mkNpmProject({
  description: "some project",
  src: ".",
  nodeVersion: "18",
  .add(() => ({
    // expose the formatter from the imported flake file
    format: flake.getApp("format"),

    // run all checks from the imported flake file.
    allChecks: flake.allChecks,

    // build all packages from the imported flake file.
    allPackages: flake.allPackages,

We hope this will make it easier to get started with Garn.

Full v0.0.19 changelogshare

  • Add garn.javascript.prettier plugin to automatically format and check javascript formatting using prettier.
  • Add garn.callFlake helper to allow importing flake files by local path.
  • Add garn.importFlake helper to allow importing flake files by url, e.g. from GitHub.

Continue Reading

May 14, 2024Sönke Hahn, Alex David, Julian Arni

A simpler, more composable Haskell process library

Mar 14, 2024Julian K. Arni

What happens if we make URLs immutable? A somewhat unusual idea that can substantially improve and simplify deployments.

Dec 19, 2023Alex David

Microsoft's LSP is great for text-editor diversity, but it is severely lacking in flexibility for project-specific configuration.

View Archive
black globe

Say hi, ask questions, give feedback