garndocumentation
discordgithub
garndocumentation →

Documentation

menu
Getting StartedTutorialConceptsTypescript API

Getting Startedshare

Installationshare

The easiest way to install Garn is with the following command:

sh <(curl --proto '=https' --tlsv1.2 -sSf https://garn.io/install.sh)

Garn works on the following platforms:

  • Arm Linux
  • Intel Linux
  • Intel Macs
    ?
  • M1/M2 Macs

You can look at the contents of the script here.

Garn requires Nix. If you don't have Nix, the above command will install it for you.

Once you have Garn installed you can head over to the tutorial to learn how to use it.

Uninstallingshare

To uninstall both nix and garn you can run:

/nix/nix-installer uninstall

Updating garnshare

To update garn to a new version you can run:

nix profile list
# Find the index number of the entry where 'Original flake URL' starts with `github:garnix-io/garn`.
nix profile remove <garn index number>
nix profile install github:garnix-io/garn/v0.0.20

Manual installationshare

If you prefer, you can also manually do the steps that the above install script automates. Those are:

  1. Install Nix. To install Nix, follow the instructions here.
  2. Configure Nix to use the Garnix cache. You can do that by adding the lines:
extra-substituters = https://cache.garnix.io
extra-trusted-public-keys = cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=

To /etc/nix/nix.conf (note that you'll need sudo).

  1. Restart the Nix daemon. (Only necessary for multi-user installations, which are the default.) On Linux, that is:
sudo systemctl restart nix-daemon.service

And on Macs, it is:

sudo launchctl kickstart -k system/org.nixos.nix-daemon

(You can run nix-shell -p nix-info --run "nix-info -m" to double-check whether you have a multi-user installation.)

  1. Install Garn. You can do that with:
nix --extra-experimental-features 'nix-command flakes' profile install -L github:garnix-io/garn
  1. Check that everything worked. Run garn --help to confirm that Garn is installed.

Deno LSP (optional)share

garn.ts files are powered by Deno. A lot of the convenience and power for editing your garn.ts files comes from having a working Deno LSP. There are two ways of setting up LSP for editing garn.ts files: using garn edit, or setting up your editor yourself.

garn editshare

Garn provides an edit command that downloads and starts a VSCodium configured with Deno LSP. It is started with it's own configuration and data directories, so as to not clobber any VSCodium or VSCode configuration you may already have.

Installing the Deno LSP and configuring your editorshare

Alternatively you can install deno (including the Deno LSP) with Garn itself:

export const deno = garn.mkProject(
  {
    description: "garn configuration environment",
    defaultEnvironment: garn.emptyEnvironment.withDevTools([pkgs.deno]),
  },
  {}
);

garn enter deno will then drop you in a shell where deno is available.

For configuring your editor to use Deno's LSP refer to Deno's environment setup documentation.

Shell autocompletionsshare

Garn ships with autocompletions for some popular shells. See below for instructions on installing them:

Bashshare

Add the following line to your .bashrc:

source <(garn --bash-completion-script `which garn`)

Zshshare

If you have oh-my-zsh installed, you likely already have a completion directory (~/.cache/oh-my-zsh/completions or ~/.oh-my-zsh/completions). In that case, use:

garn --zsh-completion-script `which garn` > ~/.cache/oh-my-zsh/completions/_garn

Otherwise, check your $fpath variable to see if it already includes a directory for user-defined completions. If it does, use:

garn --zsh-completion-script `which garn` > $DIRECTORY_IN_YOUR_FPATH/_garn

If it does not, please refer to zshs documentation about how to set up user-defined completions.

Fishshare

Assuming ~/.config/fish/completions exists and is in your $fish_completion_path (it should be), run:

garn --fish-completion-script (which garn) > ~/.config/fish/completions/garn.fish

Further readingshare