Nix flake for mc-rtc and related project
July 20, 2026 ยท View on GitHub
๐ง Welcome to mc-rtc's nixpkgs flake
๐ง This repository is an ongoing effort of packaging the mc-rtc ecosystem under Nix
๐ง Flake API and overlay structure may change without notice
Current status:
- Default devShell:
mc-rtc-superbuildAllows to build mc-rtc and configure its runtime dependencies (robots,controllers,observers,plugins) - Run
MCFrankaControlwith real Panda robots -
mc-rtc-magnumsupport (with olderglfw/imgui/implotas submodules, as done inmc-rtc-superbuild) - Robots - all most commonly used robots are supported:
- JVRC1
- HRP-2Kai
- HRP-4
- HRP-5P
- H1
- Panda*
- PandaLIRMM*
- RHPS1
- UR
- UR5e
- UR10
- Controllers
- Rolkneematics
panda-prosthesis(through downstream flake inpanda-prosthesisrepository) - Hugo's polytopeController
- Rolkneematics
-
mc-mujoco: building and running but some HiDPI scaling issues on Wayland with glfw 3.4 - magnum packaging
- magnum
- SDL2Application: works
- GlfwApplication:
- [ ]HiDPI scaling issue on Wayland with GlfW 3.4, works otherwise
- magnum-plugins (only those needed by
mc-rtc-magnum/mc-mujoco - magnum-integration
- magnum
Usage
Locally
- Install Nix on your system
- Install cachix
- Enable the cachix cache (some user configuration)
- Clone this repository
- Navigate to the cloned folder
- Run
nix develop
Options
Options are provided through flakeModule to downstream packages
Override the shell's environment for local development
To override the default shell environment to use your own local version of a controller, you can do
mkdir -p nix-workspace/install nix-workspace/devel
now create a .direnv file with the following content
# Do not auto-update the flake, do so manually through nix-direnv-reload
# This avoids triggering potentially long compilations upon entering a shell
nix_direnv_manual_reload
# Use this flake
use flake https://github.com/mc-rtc/nixpkgs
# or use a local copy for development
# export MC_RTC_WITH_ROS=1
# export MC_RTC_USE_LOCAL=1
# use flake nixpkgs --impure # if you cloned it locally in ./nixpkgs
# Override LD_LIBRARY_PATH and PATH to use the local install folder for your custom controller
export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$PWD/install/lib64:$LD_LIBRARY_PATH
export PATH=$PWD/install/bin:$PATH
# convenient cmake alias to ensure that the controller is installed in the expected local path
alias cmake_local="cmake -DCMAKE_PREFIX_PATH=$PWD/install -DMC_RTC_HONOR_INSTALL_PREFIX=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja"
Then run direnv allow. Upon entering the nix-workspace folder, this will setup the environment for you.
Now if you wish to install a custom controller/...
cd nix-workspace/devel
git clone <your_controller>
cd <your_controller>
Create a .envrc file here
source_up
export MC_RTC_CONTROLLER_CONFIG="$PWD/../install/lib64/mc_controller/etc/mc_rtc.yaml:MC_RTC_CONTROLLER_CONFIG"
Then run direnv allow again. This will add your controller to the MC_RTC_CONTROLLER_CONFIG variable. To build:
mkdir build
cd build
cmake_local ..
Define your own superbuild
mc-rtc-superbuild now uses a typed schema with named reusable presets:
mc-rtc-superbuild =
{ pkgs, ... }:
{
enable = true; # enables the mc-rtc-superbuild module
project.pname = "your-project"; # prefix shell names
configurations = { # adds configurations for your controller
your-controller-minimal = {
extends = [ "minimal" ]; # adds a configuration based on the "minimal" preset
runtime = { # define runtime dependencies installed by nix
robots = [
pkgs.mc-panda-lirmm
pkgs.mc-panda
];
apps = [
pkgs.mc-rtc-magnum
];
config = "lib/mc_controller/etc/your-controller/mc_rtc.yaml";
};
# define devel dependencies:
# - In devel shells, these are not built by Nix, you must build them from source.
# - In release shells, they are merged wiith the runtime configuration
# mc_rtc.yaml is configured to use them
devel = {
config = "lib64/mc_controller/etc/your-controller/mc_rtc.yaml";
controllers = [ pkgs.your-controller ];
plugins = [ pkgs.your-controller ];
robots = [ pkgs.your-controller ];
};
};
# define another configuration merging the "default" preset and the preset you just created
your-controller-full = {
extends = [
"default"
"your-controller-minimal"
];
runtime = {
apps = [
pkgs.mc-franka # adds mc-franka app on top of all other apps
];
};
};
};
shells = {
defaultShells.release = false; # don't generate the default release devshells (default = false)
defaultShells.devel = false; # don't generate the default devel devshells (default = false)
autoShells.release = true; # generate this project's release devshells in `configurations` (default = true)
autoShells.devel = true; # generate this project's devel devshells in `configurations` (default = true)
# define additionalShells, can be ommited
additionalShells = {
panda-prosthesis-custom = {
mode = "release";
configuration = "panda-prosthesis-minimal";
};
};
};
};
Built-in presets are:
minimaldefaultall-public-robotsfull
Presets are extensible with extends and merge with these semantics:
- list fields append (
apps,robots,controllers,observers,plugins,extraConfigFiles) - scalar fields override (
config)
runtime vs devel:
runtime: Nix runtime components always installed in the shell runtime closuredevel: local/source-oriented components- release shell: devel components are also built and added to runtime paths
- devel shell: devel components are added as
inputsFromand expected in.superbuild/install
Conditional defaults:
- ROS defaults (e.g.
mc-rtc-rviz) are only added whenmc-rtc-nix.with-ros = true - private robots are only added to
fullwhenmc-rtc-nix.overlays.private = true
Additional config fragments can be provided with extraConfigFiles (instead of overloading config).
Run a default mc-rtc-superbuild environment
To simply execute one of the provided mc-rtc-superbuild development shells, use
# if cachix is setup correctly this should just pull binary dependencies. Otherwise
# it will build everything specified in the `mc-rtc-superbuild` derivation (and their depencencies)
nix develop .#mc-rtc-superbuild-<variant>
# Run the gui in the background
(mc-rtc-magnum &)
# By default mc_rtc_ticker will use the configuration provided by `MC_RTC_CONTROLLER_CONFIG` env variable
# This is set by the mc-rtc-superbuild derivation and devShell to contain all needed runtime depencencies
# and optionally a default controller's configuration
mc_rtc_ticker