evalConanConfig
This example can be found in the standalone-eval-conan-config directory:
cd examples/standalone-eval-conan-configWhere the actual perSystem function — the one left out of the
schema of the previous chapter — is used to configure a
Release, C++17 profile:
{ # ... perSystem = system: let pkgs = nixpkgs.legacyPackages.${system};
configuration = conan-flake.lib.evalConanConfig pkgs (
{ pkgs, config, ... }: {
configRoot = self;
profiles.default = { settings.build_type = "Release"; settings."compiler.cppstd" = "17"; };
remotes.local = { url = "./repo"; local = true; allowedPackages = [ "hello-world/0.0.1.cci.20260428" ]; };
offline = true;
checks.example = { enable = true; drv = conan-flake.lib.runCommandWithInSimulatedShell pkgs config.stdenv config.outputs.devShell config.info.configRoot "./config" "standalone-eval-conan-config-example-conan-create" { } '' ( set -x conan create . --build=missing 2>&1 | grep -F "example/0.0.1" touch $out ) ''; # checks.example }; } ); in { devShells.default = configuration.config.outputs.devShell; checks = configuration.config.outputs.checks; }; # ...}This configuration now can be used to set a developer environment with
direnv:
direnv allow .But even a plain nix develop would suffice:
nix develop .From within this shell, the following command can be used to obtain the resulting profile:
conan profile showTo the profiles.default.settings.build_type and
profiles.default.settings."compiler.cppstd" attributes correspond,
respectively, the build_type and compiler.cppstd entries in its output:
Host profile:[settings]arch=x86_64build_type=Releasecompiler=gcccompiler.cppstd=17compiler.libcxx=libstdc++11compiler.version=15.3.0os=Linux[platform_tool_requires]cmake/4.3.4[conf]
Build profile:[settings]arch=x86_64build_type=Releasecompiler=gcccompiler.cppstd=17compiler.libcxx=libstdc++11compiler.version=15.3.0os=Linux[platform_tool_requires]cmake/4.3.4[conf]In the
standalone-eval-conan-config
directory, the
conanfile.py
recipe file defines a C++ package — example/0.0.1 — it’s possible
to call conan create on it, and export this package into the local Conan
cache:
conan create . --build=missingThe above command is going to install the dependencies and then build the example/0.0.1 package. Then export it to the local Conan cache and test it afterwards against standalone-eval-conan-config/test_package. If everything goes well, the last lines from the previous command would be the test package’s output:
hello-world: Hello World Release! hello-world: __x86_64__ defined hello-world: _GLIBCXX_USE_CXX11_ABI 1 hello-world: __cplusplus201703 hello-world: __GNUC__15 hello-world: __GNUC_MINOR__2example/0.0.1 test_packageThere’s also a check example function defined along with each default
devShell:
checks.example = { enable = true; drv = conan-flake.lib.runCommandWithInSimulatedShell pkgs config.stdenv config.outputs.devShell config.info.configRoot "./config" "standalone-eval-conan-config-example-conan-create" { } '' ( set -x conan create . --build=missing 2>&1 | grep -F "example/0.0.1" touch $out ) ''; # checks.exampleRun the check via nix flake check:
nix flake check .