Getting started
Setup environment with tests, formatter, linter and executable code example for several languages
Skip most of the set-up phase to :
- do a kata / exercise
- start a project
- test something in an isolated environment
Create any project using this command :
NIX_CONFIG='extra-experimental-features = flakes nix-command' \
nix run 'gitlab:pinage404/nix-sandboxes#v2' -- init --path ./new_project
Demo
Vidéo / Asciinema
Alternative text / commands
Copy / paste the command :
NIX_CONFIG='extra-experimental-features = flakes nix-command' \
nix run 'gitlab:pinage404/nix-sandboxes#v2' -- init --path ./new_project
Choose a sandbox :
rust
Enter the directory :
cd new_project
Run some commands :
-
Run the formatter :
mask formatter -
Run the linter :
mask linter -
Run the tests :
mask test -
Run all in once with git-gamble
:
git gamble --pass
What is in the box ?
-
With a focus on reproducibility
It is possible to use it without Nix, but reproducibility cannot be guaranteed as you may have installed an incompatible version
-
Always with sample code
-
Always with tests
-
Trying to use standard tools depending on the ecosystem
-
Trying to have a formatter
-
Trying to have a linter
Usage
Automatic installation
Prefer this method for better reproducibility
Toggle instructions
Requirements
- Install Nix package manager : to install dependencies (NixOS is not required)
- Install DirEnv : to install dependencies and set environment variables
- Install Git : to init the repository and commit the changes
List sandboxes
NIX_CONFIG='extra-experimental-features = flakes nix-command' \
nix run 'gitlab:pinage404/nix-sandboxes#v2' -- list
Get one sandbox
NIX_CONFIG='extra-experimental-features = flakes nix-command' \
nix run 'gitlab:pinage404/nix-sandboxes#v2' -- init --path ./new_project
Display help
NIX_CONFIG='extra-experimental-features = flakes nix-command' \
nix run 'gitlab:pinage404/nix-sandboxes#v2' -- init --help
Dev Containers installation
Prefer this method if you want to isolate the file system
For specific instructions, visit one of the sandbox page (in the menu at the top left)
Toggle instructions
Requirements :
- Verify that your editor support Dev Containers
Steps :
-
Download one of the sandbox’s folder (in the menu at the top left)
curl "https://gitlab.com/pinage404/nix-sandboxes/-/archive/main/nix-sandboxes-main.zip?ref_type=heads&path=<SANDBOX>" --output="<SANDBOX>.zip" -
Extract the archive
unzip "<SANDBOX>.zip" -
Open the folder with your editor
cd "./nix-sandboxes-main-<SANDBOX>/<SANDBOX>" -
Follow instruction of your editor to open Dev Container
Note : this installation method will download dependencies in a container ; this is less optimal than the automatic installation which share same dependencies across projects
Manual installation
Prefer this method if you can’t use Nix and can’t use Dev Containers
You need to know how to install dependencies with compatible versions using your own package manager
For specific instructions, visit one of the sandbox page (in the menu at the top left)
Toggle instructions
It is also possible to copy files and install everything necessary manually
But reproducibility cannot be guaranteed because you might install other software versions with compatibility issues
-
Download one of the sandbox’s folder (in the menu at the top left)
curl "https://gitlab.com/pinage404/nix-sandboxes/-/archive/main/nix-sandboxes-main.zip?ref_type=heads&path=<SANDBOX>" --output="<SANDBOX>.zip" -
Extract the archive
unzip "<SANDBOX>.zip" -
Open the folder
cd "./nix-sandboxes-main-<SANDBOX>/<SANDBOX>" -
Install every dependency with your package manager (Brew, APT, Mise, Chocolatey…) from these files :
flake.nixdevbox.json
-
Install specific dependencies from the package manager
-
Run the tests
mask test
Optional steps
VSCode
If you want to use VSCode
-
Install VSCode
-
Open from the command line in the folder
code . -
Install recommended extensions
- Prefer a video ? Watch the video tutorial
Cache
To avoid rebuilding things that have already been built in the pipeline, use Cachix
-
Install Cachix
-
Use Nix’s cache
cachix use pinage404-nix-sandboxes
Baby steps
If you want to use git-gamble
:
a tool that
blends TDD (Test Driven Development) + TCR (
test && commit || revert)
to make sure to develop the right thing ,
baby step by baby step
The tool is already included right out of the box, and tests should pass
git gamble --pass