Local builds
How to run the CI checks on your computer before you push, and how to build this documentation site.
You can run the CI checks on your computer. They find your errors before you push your changes, and before you send a merge request. The build system uses Nix Flakes.
For GNU/Linux Operating Systems
-
Install Nix. The Nix installation page gives the instructions. This command is enough on most systems:
sh <(curl -L https://nixos.org/nix/install) --no-daemon -
Enable Flakes. Add this line to
~/.config/nix/nix.conf:extra-experimental-features = nix-command flakes -
Install direnv. This step is optional.
direnvprepares the development environment when you go into the repository.nix profile install nixpkgs#direnvThen add the hook to your shell. For bash, add this line to
~/.bashrc:eval "$(direnv hook bash)"Then run
direnv allowin the repository. After that,direnvprepares the development environment for you.
Running local checks (Nix Flakes)
Nix Flakes runs most of the checks. Run this command from the root folder of the repository:
nix run .#<job-name>These are three examples:
nix run .#lint-git-mailmap
nix run .#test-commit-msg
nix run .#test-basic-formatThis command shows all the available jobs:
nix flake showNOTE: Commit your changes before you run a local build. A local build does not read the changes that are only in the staging area.
If all the checks pass, send your merge request.
Running the app locally
The commands of this section build and lint the site. You need them only when your merge request changes the site. A solution needs the checks of the section above, and no command of this one.
Next.js renders the full site. It renders the rankings at the root, this
documentation under /docs, and the JSON payload of each user. The build is a
static export. Thus your local result and the deployed site are the same.
The repository has one toolchain. Each command below is a Nix flake app, so you do not have to install a tool first.
# Build everything for deployment (outputs the public/ directory)
nix run .#app-build
# Development server with hot reload
# The site is served at http://localhost:3000
nix run .#app-dev
# Lint the Next.js app (Prettier + ESLint + Stylelint + tsc)
nix run .#app-lint
# Run a single linter
nix run .#app-lint -- tsc
# Rewrite files with Prettier
nix run .#app-lint -- fixFor Windows and macOS
Nix operates on macOS and on Linux. Thus all the Nix Flakes checks and all the
nix run .#... commands operate on both systems.
For Windows, Fluid Attacks recommends WSL2 with a Linux distribution such as Ubuntu. Then do the Linux steps above.