Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

conan-flake

Declarative Configuration for the Conan C/C++ Package Manager

The conan-flake module provides options used to generate a configuration for the Conan C/C++ Package Manager and defines a devShell (conan.outputs.devShell) that can be used directly, or passed in the inputsFrom option as a way to compose with other devShells.

For examples see the conan-flake README.

Installation

To use these options, add to your flake inputs:

conan-flake.url = "git+https://codeberg.org/tarcisio/conan-flake";

and inside the mkFlake:

imports = [
  inputs.conan-flake.flakeModule
];

Run nix flake lock and you’re set.

Options

perSystem.conan

Project-level Conan configuration

A wrapper based on this configuration is exposed in conan.outputs.package.wrapper.

Type: submodule

Default:

{ }

Declared by:

perSystem.conan.package

The Conan package to use.

Type: package

Default:

pkgs.conan

Declared by:

perSystem.conan.autoWire

List of configuration output types to autowire.

Using an empty list will disable autowiring entirely, enabling you to manually refer to them with config.conan.outputs.

Type: list of (one of “devShells”, “checks”, “packages”)

Default:

[
  "devShells"
  "checks"
  "packages"
]

Declared by:

perSystem.conan.checks

Use this to define checks for the configuration.

Type: lazy attribute set of (submodule)

Default:

{ }

Declared by:

perSystem.conan.checks.<name>.enable

Whether to enable this check.

Type: boolean

Default:

false

Declared by:

perSystem.conan.checks.<name>.drv

The check derivation.

Type: package

Declared by:

perSystem.conan.conanHome

Conan home. Can be an absolute (non-store) path or one relative to the root of the developer environment. Defaults to "./.conan2".

This is where Conan will keep its local cache, profiles and other settings.

Type: relative path not in the Nix store or absolute path not in the Nix store

Default:

"./.conan2"

Declared by:

perSystem.conan.configLocal

Configuration directory to be created in the developer environment.

Used to keep links pointing to the generated configuration in the store.

Type: relative path not in the Nix store

Default:

"./config"

Declared by:

perSystem.conan.configRoot

Path to the root of the configuration.

Type: null or path in the Nix store

Default:

null

Declared by:

perSystem.conan.configRootFile

Can be used to discover the root of the configuration on a developer environment. It’s a parameter of the root finding algorithm defined in rootFinding.package.

This option is a string that represents a filename which is searched for in the root directory.

Type: string

Default:

"conanfile.py"

Declared by:

perSystem.conan.configRootFiles

Can be used to discover the root of the configuration on a developer environment. It’s a parameter of the root finding algorithm defined in rootFinding.package.

This is a list of files to locate in the root directory to be used only as fallbacks when configRootFile cannot be found.

Type: list of string

Default:

[
  "flake.nix"
  ".git/config"
]

Declared by:

perSystem.conan.debug

Enable debug mode for devShell.enterShell.

Type: boolean

Default:

false

Example:

true

Declared by:

perSystem.conan.defaults.enable

Whether to enable conan-flake’s default settings for this configuration.

Type: boolean

Default:

true

Declared by:

perSystem.conan.defaults.devShell.tools

Default build tools always included in devShell.

Type: lazy attribute set of (null or package)

Default:

lib.optionalAttrs defaults.enable {
  conan = package;
  cmake = pkgs.cmake;
  "${stdenv.cc.cc.pname}" = stdenv.cc;
  inherit (outputs.packages) infoWrapper;
  inherit (outputs.packages) configHomeWrapper;
  inherit (outputs.packages) runPreConfigInstallHookWrapper;
  inherit (outputs.packages) configInstallWrapper;
  inherit (outputs.packages) conanProfileShowWrapper;
  inherit (outputs.packages) conanWrapper;
  inherit (outputs.packages) lockCreateWrapper;
  inherit (outputs.packages) lockExtendWrapper;
  inherit (outputs.packages) createLockInstallWrapper;
  inherit (outputs.packages) buildWrapper;
  inherit (outputs.packages) allWrapper;
}

Declared by:

perSystem.conan.defaults.profiles.conf

Default profile conf section properties.

Type: lazy attribute set of (null or string)

Default:

lib.optionalAttrs defaults.enable { }
  // lib.optionalAttrs (stdenv.cc.isClang && stdenv.cc.libcxx.isLLVM or false) {
  "tools.build:compiler_executables" = "{'c': '${getExe stdenv.cc}', 'cpp': '${dirOf (getExe stdenv.cc)}/clang++'}";
}
  // lib.optionalAttrs (contains "CMakeUserPresets" generators) {
  "tools.cmake.cmaketoolchain:user_presets" =
    "{{ os.path.join(os.getenv(\"CONAN_FLAKE_HOME\"), \"CMakeUserPresets.json\") }}";
}

Declared by:

perSystem.conan.defaults.profiles.platformToolRequires

Default profile platform tool requires.

Type: lazy attribute set of (null or string)

Default:

lib.optionalAttrs defaults.enable { }
  // lib.optionalAttrs ((final.devShell.tools.cmake or null) != null) {
  cmake = final.devShell.tools.cmake.version;
}

Declared by:

perSystem.conan.defaults.profiles.settings._

Default profile settings section properties (other than compiler).

Type: lazy attribute set of (null or string)

Default:

lib.optionalAttrs defaults.enable {
  arch = parseSystemArch { throwImpl = (_: null); } stdenv.system;
  build_type = "Release";
  os = parseSystemOs { throwImpl = (_: null); } stdenv.system;
}

Declared by:

perSystem.conan.defaults.profiles.settings.compiler

Default profile settings section compiler properties.

Type: lazy attribute set of (null or string)

Default:

lib.optionalAttrs defaults.enable {
  "compiler" = stdenv.cc.cc.pname;
  "compiler.cppstd" = "20";
  "compiler.libcxx" =
    if (stdenv.cc.isClang && stdenv.cc.libcxx.isLLVM or false)
    then "libc++"
    else "libstdc++11";
  "compiler.version" = stdenv.cc.version;
}

Declared by:

perSystem.conan.defaults.settings.compiler

Default Conan user settings compiler properties (compiler section in settings_user.yml).

Type: attribute set

Default:

lib.optionalAttrs defaults.enable infuse
  (infuse
    {
      "${stdenv.cc.cc.pname}".version = [
        stdenv.cc.cc.version
      ];
    }
    {
      "${pkgs.gccStdenv.cc.cc.pname}".version.__append = [
        pkgs.gccStdenv.cc.version
      ];
      "${pkgs.llvmPackages.libcxxStdenv.cc.cc.pname}".version.__append = [
        pkgs.llvmPackages.libcxxStdenv.cc.version
      ];
    })
  {
    "${pkgs.cudaPackages.backendStdenv.cc.cc.pname}".version.__append = [
      pkgs.cudaPackages.backendStdenv.cc.cc.version
    ];
  }

Declared by:

perSystem.conan.devShell

Development shell configuration.

Type: submodule

Default:

{ }

Declared by:

perSystem.conan.devShell.enterShell

Bash code to execute when entering the shell.

Type: strings concatenated with “\n”

Default:

""

Declared by:

perSystem.conan.devShell.env

Environment variables to be exposed inside the developer environment.

Type: open submodule of lazy attribute set of anything

Default:

{ }

Declared by:

perSystem.conan.devShell.inputsFrom

A list of derivations whose build inputs will be merged into the shell environment.

Type: list of package

Default:

[ ]

Example:

[
  pkgs.hello
  (pkgs.python3.withPackages (ps: [ ps.numpy ps.pandas ]))
]

Declared by:

perSystem.conan.devShell.name

Name of the project.

Type: null or string

Default:

"conan-shell"

Declared by:

perSystem.conan.devShell.stdenv

The stdenv to use for the developer environment.

Type: package

Default:

stdenv

Declared by:

perSystem.conan.devShell.tools

Build tools to expose inside the developer environment.

These tools are merged with the conan-flake defaults defined in the defaults.devShell.tools option. Set the value to null to remove that default tool.

Type: lazy attribute set of (null or package)

Default:

{ }

Declared by:

perSystem.conan.final.devShell.tools

Final configuration of the build tools to expose inside the developer environment.

Type: lazy attribute set of package (read only)

Default:

{ }

Declared by:

perSystem.conan.final.profiles.conf

Final configuration of profile [conf] section properties.

Type: lazy attribute set of string (read only)

Default:

{ }

Declared by:

perSystem.conan.final.profiles.platformToolRequires

Final configuration of profile [platform_tool_requires] section properties.

Type: lazy attribute set of string (read only)

Default:

{ }

Declared by:

perSystem.conan.final.profiles.settings._

Final configuration of profile [settings] section properties.

Type: lazy attribute set of string (read only)

Default:

{ }

Declared by:

perSystem.conan.final.profiles.settings.compiler

Final configuration of profile [settings] section compiler properties.

Type: lazy attribute set of string (read only)

Default:

{ }

Declared by:

perSystem.conan.final.settings.compiler

Final state of Conan user settings compiler properties (compiler section in settings_user.yml).

Type: attribute set (read only)

Default:

{ }

Declared by:

perSystem.conan.generators

List of generators observed by the conan-flake configuration.

Type: list of (one of “CMakeDeps”, “CMakeToolchain”)

Default:

[
  "CMakeDeps"
]

Declared by:

perSystem.conan.hasImplicitConancenterRemote

Whether to consider the implicit conancenter remote (https://center2.conan.io) during the initial Conan setup or not.

Type: boolean

Default:

true

Declared by:

perSystem.conan.homeDirectory

Path to the developer environment relative to the initial working directory. Defaults to ".".

Type: relative path not in the Nix store

Default:

"."

Example:

"./dev"

Declared by:

perSystem.conan.homeRoot

Path to the developer environment initial working directory. Can be used to bypass any other finding logic defined in homeFinding.package to set the CONAN_FLAKE_HOME environment variable (unless it’s a non existent path). Defaults to null.

Type: null or absolute path not in the Nix store

Default:

null

Declared by:

perSystem.conan.info

Overall information on the configuration.

Type: submodule

Declared by:

perSystem.conan.info.configRoot

Information on the path to the root of the configuration directory.

Type: null or absolute path (read only)

Default:

null

Declared by:

perSystem.conan.offline

Whether to enable only local remotes.

Type: boolean

Default:

false

Declared by:

perSystem.conan.outputs

The outputs generated for this configuration.

This is an internal option, not meant to be set by the user.

Type: submodule

Declared by:

perSystem.conan.outputs.packages

Package set containing the generated Conan configuration.

Type: lazy attribute set of package

Default:

{ }

Declared by:

perSystem.conan.outputs.checks

The collected (enabled) checks for this configuration.

Type: lazy attribute set of package (read only)

Default:

{ }

Declared by:

perSystem.conan.outputs.configuration

The generated Conan configuration.

Type: lazy attribute set of (submodule)

Declared by:

perSystem.conan.outputs.configuration.<name>.package

The configuration-outputing derivation generated.

Type: package

Declared by:

perSystem.conan.outputs.configuration.<name>.kind

The kind of package, used to determine how to group packages together.

Type: one of “configuration”, “package”, “info”

Declared by:

perSystem.conan.outputs.configuration.<name>.manifest

For configuration packages, the intended relative path for the configuration file, in the case package is a file. Otherwise, a list of relative paths to the package’s output configuration files.

Type: null or relative path not in the Nix store or list of relative path not in the Nix store

Default:

null

Declared by:

perSystem.conan.outputs.devShell

The development shell derivation generated for this project.

Type: package (read only)

Declared by:

Paths to link after the configuration is generated.

Type: lazy attribute set of (submodule)

Declared by:

perSystem.conan.outputs.links.<name>.kind

The kind of links, used to determine how to group them together.

Type: one of “configuration”, “package”, “info”

Declared by:

perSystem.conan.outputs.links.<name>.relativePaths

List of relative paths to link.

Type: list of relative path not in the Nix store

Default:

[ ]

Declared by:

perSystem.conan.pkgs

Nixpkgs to use in conan-flake.

Type: lazy attribute set of raw value

Default: pkgs (module argument of perSystem)

Declared by:

perSystem.conan.profiles

Conan profiles.

Type: submodule

Declared by:

perSystem.conan.profiles.buildEnv

Profile [buildenv] section.

Type: list of (submodule)

Default:

[ ]

Declared by:

perSystem.conan.profiles.buildEnv.*.name

Name.

Type: string

Default:

""

Declared by:

perSystem.conan.profiles.buildEnv.*.op

Operation

Type: one of “=”, “+=”, “=+”, “=!”, “=(path)”, “=+(path)”, “+=(path)”

Default:

"="

Declared by:

perSystem.conan.profiles.buildEnv.*.value

Value.

Type: string

Default:

""

Declared by:

perSystem.conan.profiles.conf

Profile [conf] section properties.

These properties are merged with the conan-flake defaults defined in the defaults.profiles.conf option. Set the entry to null to remove that default.

Type: lazy attribute set of (null or string)

Default:

{ }

Declared by:

perSystem.conan.profiles.platformToolRequires

Profile [platform_tool_requires] section properties.

These properties are merged with the conan-flake defaults defined in the defaults.profiles.platformToolRequires option. Set the entry to null to remove that default “require”.

Type: lazy attribute set of (null or string)

Default:

{ }

Declared by:

perSystem.conan.profiles.runEnv

Profile [runenv] section.

Type: list of (submodule)

Default:

[ ]

Declared by:

perSystem.conan.profiles.runEnv.*.name

Name.

Type: string

Default:

""

Declared by:

perSystem.conan.profiles.runEnv.*.op

Operation

Type: one of “=”, “+=”, “=+”, “=!”, “=(path)”, “=+(path)”, “+=(path)”

Default:

"="

Declared by:

perSystem.conan.profiles.runEnv.*.value

Value.

Type: string

Default:

""

Declared by:

perSystem.conan.profiles.settings._

Profile [settings] section properties.

These properties are merged with the conan-flake defaults defined in the defaults.profiles.settings._ option. Set the entry to null to remove that default.

Type: lazy attribute set of (null or string)

Default:

{ }

Declared by:

perSystem.conan.profiles.settings.compiler

Profile [settings] section compiler properties. These are properties with names matching compiler or compiler.*.

These properties are merged with the conan-flake defaults defined in the defaults.profiles.settings.compiler option. Set the entry to null to remove that default.

Type: lazy attribute set of (null or string)

Default:

{ }

Declared by:

perSystem.conan.profiles.text

The profile-outputing derivation generated for the configuration.

Type: package (read only)

Default:

pkgs.writeText "profile" ''
  [settings]
  ${lib.strings.concatMapAttrsStringSep "\n" (
    name: value: "${name}=${value}"
  ) final.profiles.settings._}
  ${lib.strings.concatMapAttrsStringSep "\n" (
    name: value: "${name}=${value}"
  ) final.profiles.settings.compiler}

  [buildenv]
  ${lib.strings.concatMapStringSep "\n" (
    x: "${x.name}${x.op}${x.value}"
  ) profiles.buildEnv}

  [runenv]
  ${lib.strings.concatMapStringSep "\n" (
    x: "${x.name}${x.op}${x.value}"
  ) profiles.runEnv}

  [conf]
  ${lib.strings.concatMapAttrsStringSep "\n" (
    name: value: "${name}=${value}"
  ) final.profiles.conf}

  [platform_tool_requires]
  ${lib.strings.concatMapAttrsStringSep "\n" (
    name: value: "${name}/${value}"
  ) final.profiles.platformToolRequires}
''

Declared by:

perSystem.conan.remotes

Conan remote repositories.

Type: lazy attribute set of (submodule)

Default:

{ }

Declared by:

perSystem.conan.remotes.<name>.enable

Enable this remote.

Type: boolean

Default:

true

Declared by:

perSystem.conan.remotes.<name>.allowedPackages

Allowed packages.

Type: null or (list of string)

Default:

null

Declared by:

perSystem.conan.remotes.<name>.local

Whether this remote is of local-recipes-index type.

Type: boolean

Default:

false

Declared by:

perSystem.conan.remotes.<name>.name

Name of the remote.

Type: string

Default: remote’s name

Declared by:

perSystem.conan.remotes.<name>.url

Remote’s URL.

Type: relative path not in the Nix store or string

Declared by:

perSystem.conan.remotes.<name>.verifySsl

Whether to verify SSL.

Type: boolean

Default:

true

Declared by:

perSystem.conan.settings

Conan user settings (settings_user.yml).

Type: submodule

Declared by:

perSystem.conan.settings.compiler

Conan user settings compiler properties (compiler section in settings_user.yml).

Type: attribute set

Default:

{ }

Declared by:

perSystem.conan.settings.yaml

The YAML-outputing derivation generated for the user configuration.

Type: package (read only)

Default:

(pkgs.formats.yaml { }).generate "settings_user.yml" final.settings.compiler

Declared by:

perSystem.conan.stdenv

The stdenv derivation to use for the Conan environment.

Type: package

Default:

pkgs.stdenv

Example:

pkgs.llvmPackages.libcxxStdenv
pkgs.cudaPackages.backendStdenv

Declared by:

perSystem.conan.wrappers.conanFlakeLockFile

The path to the lock file to output or null to disable lock file generation. Defaults to null.

Type: null or string

Default:

null

Example:

"conan-flake.lock"

Declared by:

perSystem.conan.wrappers.conanInstall

Whether to run conan install automatically during shell activation. Defaults to false.

Type: boolean

Default:

false

Declared by:

perSystem.conan.wrappers.conanLockFile

The conan lock file to generate, or null to disable lock file generation. Defaults to null.

Type: null or string

Default:

null

Example:

"conan.lock"

Declared by:

perSystem.conan.wrappers.infoWrapperStdoutOutput

Whether to output the lock file to stdout. Defaults to true.

Type: boolean

Default:

true

Declared by: