importFlake
import { importFlake } from "https://garn.io/ts/v0.0.20/mod.ts";
Gets apps, checks, dev-shells, and packages from an existing flake file by adding it as a flake input to your project.
This is most useful for bringing in flake files from the internet. The hash
of the flake file and its referenced sources will be included in your
project's flake.lock
. If you want to import a flake file within your
current project, consider using callFlake
instead which does not update
the hash in your flake.lock.
See https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html
for information on how to format flakeUrl
. You may also want to use
importFromGithub
, importFromGitlab
or importFromSourcehut
helpers
instead which provide a more ergonomic API when importing from these
services.
Example:
const myFlake = importFlake("git+https://example.com/some-repo.git?ref=main");
const myProject = getGarnProjectSomehow()
.add(() => ({
format: myFlake.getApp("format"),
env: myFlake.getDevShell("default"),
bundle: myFlake.getPackage("bundle"),
allChecks: myFlake.allChecks,
}));