跳到正文
cccskills
免费在 GitHub 公开

cmake

Package a CMake-based project for corepkgs. Use when a source tree has a CMakeLists.txt — covers the minimal derivation, cmakeEntries, cross-compilation, and diagnosing CMake configure failures.

中文简介正在准备中。当前显示原文说明。

ekala-project/corepkgs星标 94(GitHub 94 + cccskills 0)

实测评分 未实测

查看安装方法

包含的文件(1)

  • SKILL.md2.7 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

CMake Build System

Minimal Example

{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "example";
  version = "1.0.0";

  src = fetchFromGitHub {
    owner = "example";
    repo = "example";
    tag = "v${finalAttrs.version}";
    hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
  };

  nativeBuildInputs = [
    cmake
    cmake.configurePhaseHook  # Required
  ];

  meta = {
    description = "Example CMake package";
    license = lib.licenses.mit;
  };
})

Essential Requirements

Always include cmake.configurePhaseHook in nativeBuildInputs.

  • cmake alone provides the cmake binary and the setup hook (setup-hook.sh), which defines all cmakeEntries helpers (setCMakeEntry, prependCMakeEntry, concatCMakeEntryFlagsTo, etc.) and cmakeConfigurePhase.
  • cmake.configurePhaseHook replaces the default configure phase with cmakeConfigurePhase, which assembles cmakeEntries + cmakeFlags into the final cmake invocation. Without it, the configure phase is the generic autotools-style one and cmake entries/flags are ignored.

Common Patterns

With Dependencies

nativeBuildInputs = [
  cmake
  cmake.configurePhaseHook
  pkg-config
];

buildInputs = [
  zlib
  openssl
];

CMake Entries (Preferred)

Use cmakeEntries to specify CMake -D cache entries as a structured attrset. Booleans are automatically converted to ON/OFF.

cmakeEntries = {
  BUILD_SHARED_LIBS = true;
  ENABLE_TESTS = false;
  CMAKE_INSTALL_LIBDIR = "lib";
};

CMake Flags (non--D only)

cmakeFlags is reserved for non--D flags (warning suppression, generator selection, source-dir overrides, unset flags). All -D entries must use cmakeEntries.

cmakeFlags = [
  "-Wno-dev"
  "-H.."
  "-UCMAKE_INSTALL_LIBDIR"  # unset (-U), not a -D flag
];

Both can be used together. cmakeEntries entries are emitted first, then cmakeFlags / cmakeFlagsArray are appended.

Cross-Compilation

strictDeps = true;

nativeBuildInputs = [ cmake cmake.configurePhaseHook pkg-config ];
buildInputs = [ zlib ];
depsBuildBuild = [ pkg-config ];

Troubleshooting

CMake can't find dependencies:

cmakeEntries = {
  ZLIB_ROOT = "${zlib}";
  OPENSSL_ROOT_DIR = "${openssl}";
};

Library install to lib64:

cmakeEntries = {
  CMAKE_INSTALL_LIBDIR = "lib";
};

Install prefix issues:

cmakeEntries = {
  CMAKE_INSTALL_PREFIX = "${placeholder "out"}";
};

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Review a package expression for best-practices compliance. Use when reviewing PRs or auditing existing packages — checks meta completeness, build-system idioms (cmakeEntries, mesonEntries, pyproject), dependency placement, and packaging conventions.

中文简介正在准备中。当前显示原文说明。

ekala-project/corepkgs942026年10月26日 更新

Fix all broken package builds in the repository. Runs a full build of ci/packages.nix in the background while iterating on failures in the foreground until everything builds.

中文简介正在准备中。当前显示原文说明。

ekala-project/corepkgs942026年10月26日 更新

go

免费

Package a Go module for corepkgs. Use when writing or editing a buildGoModule derivation — covers vendorHash, ldflags, subPackages, tags, env.CGO_ENABLED, proxyVendor, shell completions, and pinning a Go version.

中文简介正在准备中。当前显示原文说明。

ekala-project/corepkgs942026年10月26日 更新

meson

免费

Package a Meson/Ninja project for corepkgs. Use when a source tree has a meson.build — covers mesonFlags, auto features, cross-compilation, and diagnosing Meson setup failures.

中文简介正在准备中。当前显示原文说明。

ekala-project/corepkgs942026年10月26日 更新

Work with multi-version packages under pkgs-many (guile, go, erlang, perl, openssl, ...). Use when adding or changing a package that ships several versions side by side — covers the default.nix/variants.nix/generic.nix three-file pattern, the packageOlder/packageAtLeast version helpers, and mkVariantPassthru.

中文简介正在准备中。当前显示原文说明。

ekala-project/corepkgs942026年10月26日 更新

packaging

免费

corepkgs packaging conventions. Use when writing or reviewing any pkgs/<name>/default.nix — covers package organization (auto-registration, top-level.nix, alternative implementations), the finalAttrs pattern, meta attributes, where each kind of dependency belongs, fetchers, patching, install phases, multiple outputs, and passthru.

中文简介正在准备中。当前显示原文说明。

ekala-project/corepkgs942026年10月26日 更新

查看 ekala-project 的全部技能

报告此技能的问题