Skip to content

Standalone

Although conan-flake is presented as a flake-parts module, there is a subset of its options that can be imported independently, directly into any Nix code. This use case is supported by two helper functions, exposed in the lib namespace of the flake defined by this repository: evalConanConfig and submoduleWith.

To use these functions, add conan-flake to your flake inputs:

{
inputs = {
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
# Add this:
conan-flake.url = "git+https://codeberg.org/tarcisio/conan-flake";
};
# ...
}

Now conan-flake.lib.evalConanConfig can be used to configure, for each system supported, a Conan configuration and output a devShell and a check command. With this schema in place:

{
# ...
outputs = { self, nixpkgs, conan-flake, ... }:
let
eachSystem = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
# See below for the actual `perSystem` function definition:
perSystem = system:
let
# ...
configuration = conan-flake.lib.evalConanConfig pkgs (
# ...
);
in
{
devShells = {
# ...
};
checks = {
# ...
};
};
systemOutputs = eachSystem perSystem;
in
{
devShells = nixpkgs.lib.mapAttrs (_: s: s.devShells) systemOutputs;
checks = nixpkgs.lib.mapAttrs (_: s: s.checks) systemOutputs;
};
}

The two chapters that follow fill in the perSystem function, one with each helper:

The options accepted by both helpers are the ones documented in the option reference (the perSystem.conan.* entries, minus their perSystem.conan prefix).

  1. Or even of conanfile.txt, for that matter.