Conan2 on NixOS is a disaster

Hi!

I’ve been using NixOS for more than a year now, happy with how all works, and recently got into deploying NixOS on Digital Ocean using flakes and deploy-rs.

Started a project in C++, I’m relatively inexperience with C++. Heard about conan and wanted to use it to make it easy for me to download and compile dependencies for my project and so far is a pain:

  • joltphysics/3.0.1 insists on fetching CMake 3.30.5 despite my default profile specifying conan must use my installed CMake (granted, it is version 3.29.2, but still) making the build fail because the “NixOS cannot run dynamically linked executables intended for generic linux environments out of the box” thing.
  • wayland/1.22.0 finds my CMake, but insists on using a conan-provided pkg-config despite my system offering one already and regardless of what my default profile says.

This is my default profile:

[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=13
os=Linux

[platform_tool_requires]
cmake/*
pkgconf/*

This is my project’s conanfile.txt

[requires]
eastl/3.21.12
diligent-core/api.252009
joltphysics/3.0.1

[generators]
CMakeDeps
CMakeToolchain

[layout]
cmake_layout

The packages attribute of my flake.nix default shell:

    pkgs.mkShell {
            # Pinned packages available in the environment
            packages =
              with pkgs;
              [
                cmake
                cmake-format
                cmake-language-server
                headache
                just
                nil
                unstablepkgs.conan # get's me the latest conan

                gcc14Stdenv
                libGL.dev
                libuuid.dev
                pkg-config
                xcb-util-cursor.dev
                xkeyboard_config
                xorg.libICE.dev
                xorg.libSM.dev
                xorg.libX11.dev
                xorg.libXScrnSaver
                xorg.libXau.dev
                xorg.libXaw.dev
                xorg.libXcomposite.dev
                xorg.libXcursor.dev
                xorg.libXdamage.dev
                xorg.libXdmcp.dev
                xorg.libXext.dev
                xorg.libXi.dev
                xorg.libXinerama.dev
                xorg.libXpm.dev
                xorg.libXrandr.dev
                xorg.libXres.dev
                xorg.libXtst
                xorg.libXv.dev
                xorg.libXxf86vm.dev
                xorg.libfontenc
                xorg.libxkbfile.dev
                xorg.xcbutil.dev
                xorg.xcbutilimage.dev
                xorg.xcbutilkeysyms.dev
                xorg.xcbutilrenderutil.dev
                xorg.xcbutilwm.dev
              ]

Install the dependencies with conan install conanfile.txt --build=missing

I don’t understand the point of having tools like conan if they aren’t well-supported to be used on NixOS or if they aren’t willing to fail if a setting is not respected.

1 Like

None of these are in nixpkgs at the moment, so I see why you’d just use conan instead. Mixing package managers does however create kind of a franken-environment where issues can be hard to track down.

I think the long-term better option for you is too package those 3 in your flake and avoid conan, but short term you might be able to use one of the techniques described here to get conan-provided binaries to work.

3 Likes

You could go the other way and do all conan in flake devShell if you are in a pinch, and then try to package them all as time permits.

Usually with C++ it’s not too hard to package for Nixos though

1 Like

Thank God I’m not, this is for a side project and I’m just trying to get the barebones of it to have something I can publish to develop in the open

1 Like

I fear that this is the way to go. I might package them or I may make them submodules of my project and use CMake for the magic :magic_wand:, I’m reading about CMake and I can feel my confidence increasing

1 Like