Grid5000
On the Grid5000 testbed experiment platform there is no first class support for Nix (as of now).
NixOS-Compose relies at least on the presence of the Nix store on the
frontend commands that are not init and build and access to the Nix package
manager for those two. To have it, we need to use some workarounds.
Except for the init and build commands (see details here),
that will requiere a local installation of Nix followed by a chroot, the
rest of the commands are only relying on Python. That means that for building
your distributed environments you will need the reservation of resource.
Nix installation on frontend
We are going to use the script nix-user-chroot.sh.
This script provides Nix without root permissions on the frontend. At its
first call it will install the Nix package manager and create all required
folders in your home folder (e.g. ~/.nix/store/) then change the apparent root
directory so that the nix command works as expected. All subsequent call to
this script will only do the second part followed by the activation of the
nixcommand.
curl -L -O https://raw.githubusercontent.com/oar-team/nix-user-chroot-companion/master/nix-user-chroot.sh
chmod +x nix-user-chroot.sh
On a interactive session on a node (using oarsub -I)
login@dahu-17:~$ ./nix-user-chroot.sh
...
Activate Nix
login@dahu-17:~$
Tip
The call
nix-user-chroot.shcan be done either on the frontend or on a node.Doing it on the frontend would be the easy-route when you want to use the Nix store for small things (e.g. when using nix shells) but we advise to avoid building phases overall on the frontend (any commands that will populate the Nix store) to prevent performance issues for other users of the frontend.
Installation of NixOS-Compose
The three following sections describe alternative approaches to install NixOS-Compose.
Local installation with pip
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)
Local installation with a poetry env
Install poetry locally in your home
curl -sSL https://install.python-poetry.org | python3 -
Clone NixOS-Compose project then install all python dependencies thanks to Poetry. Finally enter the env.
git clone https://gitlab.inria.fr/nixos-compose/nixos-compose.git
git checkout 26.05 # Or any branch you'd like to target
cd nixos-compose
poetry env activate
poetry install
source "$( poetry env list --full-path | grep nixos-compose | cut -d' ' -f1 )/bin/activate"
For further use only
source "$( poetry env list --full-path | grep nixos-compose | cut -d' ' -f1 )/bin/activate"
is needed.
Nix chroot on frontal with nix develop
Note
This method prevents the use of all OAR tooling (
oarsub).
Warning
Running a nix build on a Grid5000 frontend is discouraged, you can use a node or remote builder for doing so (
oarsub -I)
As seen in the local installation it is preferable to use the same nxc version
that the one used in the project. The downside of this method is that you are
loosing access to the specific commands of the platform (e.g. oarsub command
is not acessible in a nix-shell) so you need either do your reservation of
ressources before entering those commands or use multiple terminal or a terminal
multiplxer (for instance tmux).
./nix-user-chroot.sh #activate Nix
nix develop .#nxcShellLite