The installation and usage of NixOS-Compose differs in function of the state
at which the project you are working on is. In the case of a new project you
will want to install the nxc command line tool as it is described in
Local Installation. If the project you are
working on is already using NixOS-Compose because you are developing it or in
the case of the re-run of an experiment conducted in the past, you will prefer
to use the version of nxc link to the project. Invoking nxc in an embedded
way is described in
Linked/project embedded nxc
Requirements
- Nix package manager with flake feature activated (see NixOS website and NixOS wiki)
Note
A quick note from NixOS wiki to activate flake feature:
- Non-NixOS Edit
~/.config/nix/nix.confto add this line :experimental-features = nix-command flakes- NixOS Edit your configuration by adding the following options
{ pkgs, ... }: { nix = { package = pkgs.nixFlakes; # or versioned attributes like nixVersions.nix_2_8 extraOptions = '' experimental-features = nix-command flakes ''; }; }
Configuration requirements
On NixOS you need to enable Docker if you want to run the docker flavour.
# Docker enabled
virtualisation.docker.enable = true;
Local installation
To install the latest stable version of nixos-compose, you can run the following command:
python3 -m pip install --user --break-system-packages nixos-compose
Ensure your compositionâs flake.nix references a compatible associated branch
(as shown in the version compatibility table)
DevShell
The following commands will drop you in a shell where the nxc command is
available and all required runtime dependencies (docker, vde2, tmux, qemu_kvm).
git clone https://gitlab.inria.fr/nixos-compose/nixos-compose.git
git checkout 26.05 # or any branch you want to target
cd nixos-compose
nix develop .#nxcShell
Alternative
You can take advantage of the full potential of Nixâs flakes. The following command will drop you in the same shell without having to clone the repository.
nix develop https://gitlab.inria.fr/nixos-compose/nixos-compose.git#nxcShell
Tip
Writing the full url is not really practical, an âaliasâ can be used.
nix registry add nxc git+https://gitlab.inria.fr/nixos-compose/nixos-compose.gitThe command becomes :
nix develop nxc#nxcShell
Project embedded nxc
A project that is already using NixOS-Compose in its experiments process
provides an easy access to a shell that gives access to the nxc tool and its
runtime dependencies if needed. This is achieved thanks to Nix and its flakes
feature.
Start from a template
You can simply run the following to setup a template in your current directory:
nix run git+https://gitlab.inria.fr/nixos-compose/nixos-compose.git\?ref=26.05 -- init -t basic # replace `basic` with any template
You can then enter your development shell with:
nix develop
Manually add the devshell
You can have a line in your projectâs flake.nix similar to this :
devShell.${system} = nxc.devShells.${system}.nxcShell;
It exposes the shell of NixOS-Compose as in the previous section but with the
specific revision thanks to the flake.lock file. The shell is accessible with
the command nix develop. It is useful to explore what shells are available in
the project, to list them you use nix flake show. Then to access the devShell
of your choice use this command :
nix develop .#nxcShell
Note
Two shells availables :
nxcShellLite
- python app
nxcnxcShell
- python app
nxc- docker
- vde2
- tmux
- qemu_kvm