Skip to content

Commit

Permalink
doc: refine installation
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed May 2, 2024
1 parent 6070b6f commit 8e840a9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default defineConfig({

sidebar: [
{ text: 'Quick Start', link: '/quick-start' },
{ text: 'Installation', link: '/installation' },
{ text: 'Overview', link: '/overview' },
{ text: 'Usage', link: '/usage' },
{ text: 'Formatter Specification', link: '/formatter-spec' },
Expand Down
26 changes: 16 additions & 10 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,45 @@ outline: deep

# Installation

There are two options to install `treefmt`: by downloading the latest binary, or by compiling and building the tool from source.
There are two options to install `treefmt`:

1. Downloading the latest binary
2. Compiling and building it from source.

## Installing with a binary file

You can find the list of the latest binaries [here](https://github.com/numtide/treefmt/releases).

## Building from source

There are several ways to build `treefmt` from source. Your choice will depend on whether you're a [nix](https://github.com/NixOS/nix) user.
There are several ways to build `treefmt` from source. Your choice will depend on whether you're a [nix](https://github.com/NixOS/nix) user or
not.

### Non-Nix User

To try the project without building it, run:

```
$ cargo run -- --help
$ go run main.go --help
```

The command will output the manual. You can run the tool in this manner with any other flag or option to format your project.
The command will output the manual. You can run the tool in this manner with any other flag or option to format your
project.

To build a binary, you need to have `go 1.22` installed. You can find instructions [here](https://go.dev/doc/install).

To build a binary, you need to have rust installed. You can install it with [rustup](https://rustup.rs/). Now, if you want to build the project, switch to the project root folder and run:
Now, if you want to build the project, switch to the project root folder and run:

```
$ cargo build
$ go build
```

After the successful execution of the cargo build command, you will find the `treefmt` binary in the target folder.
After the successful execution of the build command, you will find the `treefmt` binary in the project root folder.

### Nix User

[Nix](https://github.com/NixOS/nix) is a package manager foundational for NixOS. You can use it in NixOS and in any other OS equally.

If you're using both `treefmt` and `nix`, you can go for [`treefmt-nix`](https://github.com/numtide/treefmt-nix), a special tool that makes installation and configuration of `treefmt` with `nix` easier.
If you're using both `treefmt` and `nix`, you can go for [`treefmt-nix`](https://github.com/numtide/treefmt-nix), a wrapper that makes installation and
configuration of `treefmt` with `nix` easier.

**Non-flake user**

Expand Down

0 comments on commit 8e840a9

Please sign in to comment.