Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a fuel.nix mdbook #61

Merged
merged 20 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ecb4916
Add a `fuel.nix` mdbook
mitchmindtree May 23, 2023
df12db4
Remove old layout stub files
mitchmindtree May 24, 2023
bf2a732
Begin work on the Contributing/Internals chapter
mitchmindtree May 29, 2023
ff2eea9
Add internals chapter with sections on manifests, packages, milestones
mitchmindtree May 30, 2023
715bf1f
Complete the Adding Packages and Updating Packages chapters
mitchmindtree May 30, 2023
fd3b8a4
Update the adding-packages section with more links
mitchmindtree May 30, 2023
0d2b0f3
Update the README to link to the book and the Quick Start
mitchmindtree May 30, 2023
1446115
Update the nix profile note with latest info on issue
mitchmindtree May 30, 2023
a377bb8
Add a book-dev devShell providing mdbook. Check book build in CI.
mitchmindtree May 30, 2023
c96b21c
Update CI workflow name to ci
mitchmindtree May 30, 2023
2ef445e
Add a publish-book workflow that publishes the book on master commits
mitchmindtree May 30, 2023
ffead96
Tweaks to the README formatting, links
mitchmindtree May 30, 2023
290d9ed
Add a note about milestone builds under CI
mitchmindtree May 30, 2023
f89fac3
Fix vscode plugin link
mitchmindtree May 30, 2023
87d7263
Fix version demonstration command in packages chapter
mitchmindtree May 30, 2023
2ed4c02
Don't fail fast on error so we can see all errors
mitchmindtree May 30, 2023
28d0b85
Move devshells, overlays and editor-plugins into new power-users chapter
mitchmindtree May 31, 2023
cdc8ee0
Add a tip on selecting commits for new milestones
mitchmindtree May 31, 2023
97ca174
Add a chapter on updating flake inputs
mitchmindtree May 31, 2023
0883c00
Add a tip about checking upstream CI when adding new package patches
mitchmindtree May 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "fuel"
name: ci

on:
pull_request:
Expand Down Expand Up @@ -26,6 +26,7 @@ jobs:

nix-build:
strategy:
fail-fast: false
matrix:
package: [fuel, fuel-beta-1, fuel-beta-2, fuel-beta-3, fuel-nightly, sway-vim]
os: [ubuntu-latest, macos-latest]
Expand Down Expand Up @@ -57,3 +58,16 @@ jobs:
name: fuellabs
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix develop --print-build-logs --no-update-lock-file .#fuel-dev

nix-build-book:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: fuellabs
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix develop --print-build-logs --no-update-lock-file .#book-dev --command mdbook build book
21 changes: 21 additions & 0 deletions .github/workflows/publish-book.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: publish-book

on:
push:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: build
run: nix develop --print-build-logs --no-update-lock-file .#book-dev --command mdbook build book
- name: deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/book
destination_dir: ./
cname: nix.fuel.network
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Voxelot do you know what we might need to do with the fuel.network hosting to get this cname to work like we have for rust.fuel.network?

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
book/book
result
202 changes: 5 additions & 197 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,205 +1,13 @@
# fuel.nix

A Nix flake for the Fuel Labs ecosystem. https://fuel.network/
A Nix flake for the Fuel Labs ecosystem. **https://fuel.network**

Each night at midnight (UTC) this repo is automatically updated with the latest
stable and nightly releases of all fuel packages. Builds are tested and cached
for both `x86_64-linux` and `x86_64-darwin` systems.

## System Requirements
See the [**Quick Start**][fuel-nix-quick-start] guide from
[**the book**][fuel-nix-book] to get started.

Requires a recent version of [Nix][nix-manual] with [the "flakes"
feature][nix-flakes] enabled.

We also recommend enabling the Fuel Labs Nix cache hosted by
[cachix][fuellabs-cachix]. Otherwise, upon first use Nix will try to build all
of the packages from scratch which can take a long time!

On **NixOS**, we can enable the necessary features and our cache within our
NixOS configuration (i.e. `/etc/nixos/configuration.nix`) like so:

```nix
{
nix = {
settings = {
experimental-features = ["nix-command" "flakes"];
substituters = ["https://fuellabs.cachix.org"];
trusted-public-keys = [
"fuellabs.cachix.org-1:3gOmll82VDbT7EggylzOVJ6dr0jgPVU/KMN6+Kf8qx8="
];
};
};
}
```

On **non-NixOS** systems, you may add the following to your Nix configuration
file (e.g. `/etc/nix/nix.conf`):

```conf
experimental-features = nix-command flakes
substituters = https://cache.nixos.org/ https://fuellabs.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= fuellabs.cachix.org-1:3gOmll82VDbT7EggylzOVJ6dr0jgPVU/KMN6+Kf8qx8=
```

On non-NixOS Linux systems, be sure to make sure that your user is part of the
`nixbld` group. Only this group has permissions to access the caches. You can
check if your user is a part of the group with the `groups` command. You can add
your user to the `nixbld` group with the following, replacing `user` with your
username:

```
$ sudo usermod -a -G nixbld user
```

## Packages

Includes the following packages:

| Package | Description |
| --- | --- |
| [`fuel-core`][fuel-core-repo] | The Fuel VM node client. |
| [`fuel-core-client`][fuel-core-repo] | A Fuel VM transaction client. |
| [`forc`][sway-repo] | The Fuel Orchestrator. Compiler, packaging and plugin support. |
| [`forc-client`][sway-repo] | Provides the `forc deploy` and `forc run` commands. |
| [`forc-doc`][sway-repo] | Sway API documentation generator. |
| [`forc-explore`][sway-repo] | Runs the Fuel Explorer. |
| [`forc-fmt`][sway-repo] | The Sway code formatter. |
| [`forc-index`][fuel-indexer-repo] | A forc plugin for working with the indexer. |
| [`forc-lsp`][sway-repo] | The Sway Language Server Protocol implementation. |
| [`forc-tx`][sway-repo] | Construct transactions with a CLI. |
| [`forc-wallet`][forc-wallet-repo] | A Fuel Wallet CLI implementation. |
| [`fuel-indexer`][fuel-indexer-repo] | An indexer for the Fuel blockchain. |
| [`sway-vim`][sway-vim-repo] | The Sway Vim plugin. |
| `fuel` | All of the above tools under a single package. |

If you have Nix installed with the "flakes" feature enabled, you can run any of
the above programs like so:

```
nix run github:fuellabs/fuel.nix#fuel-core
```

To run the latest nightly for a package, add `-nightly` to the end, e.g.

```
nix run github:fuellabs/fuel.nix#forc-nightly
```

Similarly, run the version of a package from a milestone with `-<milestone>`, e.g.

```
nix run github:fuellabs/fuel.nix#forc-lsp-beta-3
```
```
nix run github:fuellabs/fuel.nix#forc-wallet-beta-1
```

To enter a temporary shell with all of the fuel packages available on `$PATH`,
you can use the following:

```
nix shell github:fuellabs/fuel.nix#fuel
```

When you `exit` the shell the tools will no longer be on the `PATH`.

The `nix shell` command is useful for maintaining isolated, temporary
environments and to avoid endlessly polluting your `PATH` with different
versions. E.g. in the following, we trivially switch between a stable fuel
toolchain and nightly toolchain:

```sh
$ nix shell github:fuellabs/fuel.nix#fuel

# All latest stable `fuel` packages on `PATH`.

$ exit

# No fuel packages on `PATH`

$ nix shell github:fuellabs/fuel.nix#fuel-nightly

# All latest nightly `fuel` packages on `PATH`.

$ exit

# No fuel packages on `PATH`

$ nix shell github:fuellabs/fuel.nix#fuel-beta-3

# All beta-3 milestone `fuel` packages on `PATH`.
```


To specify a specific version, append the semver or nightly date to the end:

```
nix run github:fuellabs/fuel.nix#forc-fmt-0.24.1
```
```
nix run github:fuellabs/fuel.nix#forc-fmt-0-24-3-nightly-2022-09-14
```

## Dev Shells

This flake also features a few `devShell`s that make it easy to drop into a
development shell for working on the fuel packages. They allow you to drop into
a temporary shell with all the tools and environment variables required to build
the various fuel projects yourself.

| Dev Shell | Description |
| --- | --- |
| `fuel-core-dev` | A shell for working on the `fuel-core` repo. |
| `sway-dev` | A shell for working on the `sway` repo. |
| `fuel-indexer-dev` | A shell for working on the `fuel-indexer` repo. |
| `fuel-dev` | A shell ready for working with on any Fuel repo. |

You can enter a temporary dev shell like so:

```
nix develop github:fuellabs/fuel.nix#fuel-dev
```

Note that you can also enter a dev shell for individual packages. E.g. the
following enters a dev shell with the required environment for working on the
Sway language server implementation

```
nix develop github:fuellabs/fuel.nix#forc-lsp
```

Note that currently the vim plugin still needs to be installed separately. See
the "Overlay" section below and the [Nix Vim wiki](https://nixos.wiki/wiki/Vim)
for more details.

## Overlay

Two nixpkgs overlays are provided (`fuel` and `fuel-nightly`) that allow for
"merging" the set of packages provided by this flake with nixpkgs.

Note that this makes the `sway-vim` plugin accessible via the `vimPlugins` set
following the nixpkgs convention, e.g. `nixpkgs.vimPlugins.sway-vim`.

## Editor plugins

Currently this flake and its overlay only provide the `sway-vim` Vim plugin.

Contributions adding support for other editors/IDE plugins are more than
welcome.

## Packaging Sway Applications

*TODO: Provide a `forcPlatform` wrapper around `forc` and related plugins
inspired by nixpkgs' `rustPlatform`.*


[cachix-docs]: https://docs.cachix.org/
[forc-wallet-repo]: https://github.com/fuellabs/forc-wallet
[fuel-core-repo]: https://github.com/fuellabs/fuel-core
[fuel-indexer-repo]: https://github.com/fuellabs/fuel-indexer
[fuellabs-cachix]: https://app.cachix.org/cache/fuellabs
[nix-flakes]: https://nixos.wiki/wiki/Flakes
[nix-manual]: https://nixos.org/manual/nix/stable/
[rust-overlay-repo]: https://github.com/oxalica/rust-overlay
[sway-repo]: https://github.com/fuellabs/sway
[sway-vim-repo]: https://github.com/fuellabs/sway.vim
[fuel-nix-book]: https://nix.fuel.network
[fuel-nix-quick-start]: https://nix.fuel.network/quick-start
6 changes: 6 additions & 0 deletions book/book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[book]
authors = ["mitchmindtree"]
language = "en"
multilingual = false
src = "src"
title = "fuel.nix"
18 changes: 18 additions & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Summary

- [Welcome](./welcome.md)
- [Quick Start](./quick-start.md)
- [Nix Setup](./nix-setup.md)
- [Packages](./packages.md)
- [Nix Power Users](./nix-power-users.md)
- [Dev Shells](./nix-power-users/dev-shells.md)
- [Overlays](./nix-power-users/overlays.md)
- [Editor Plugins](./nix-power-users/editor-plugins.md)
- [Contributing](./contributing.md)
- [Internals](./contributing/internals.md)
- [Generating Manifests](./contributing/internals/generating-manifests.md)
- [Providing Packages](./contributing/internals/providing-packages.md)
- [Providing Milestones](./contributing/internals/providing-milestones.md)
- [Adding Packages](./contributing/adding-packages.md)
- [Updating Packages](./contributing/updating-packages.md)
- [Updating Flake Inputs](./contributing/updating-flake-inputs.md)
4 changes: 4 additions & 0 deletions book/src/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Contributing

This chapter will cover the internals of **fuel.nix**, how it works, and how
to contribute!
Loading