stephank/composer-plugin-nixify
Composer 安装命令:
composer require stephank/composer-plugin-nixify
包简介
Composer plugin to help with Nix packaging
README 文档
README
Generates a Nix expression to build a Composer project.
-
A default configure-phase that runs
composer installin your project. (May be all that's needed to build your project.) -
A default install-phase that creates executables for you based on
"bin"in yourcomposer.json, making your package readily installable. -
Granular fetching of dependencies in Nix, speeding up rebuilds and potentially allowing downloads to be shared between projects.
-
Preloading of your Composer cache into the Nix store, speeding up local
nix-build. -
Automatically keeps your Nix expression up-to-date as you
composer require/composer updatedependencies. -
No Nix installation required for the plugin itself, so it should be safe to add to your project even if some developers don't use Nix.
Related projects:
-
composer2nix: Does a similar job, but as a separate command. By comparison, this plugin tries to automate the process and make things easy for Nix and non-Nix devs alike.
-
yarn-plugin-nixify: Similar solution for Node.js with Yarn v2.
Usage
The Nixify plugin should work fine with Composer versions all the way back to 1.3.0, and also supports Composer 2.0.
To use the plugin:
# Install the plugin composer require stephank/composer-plugin-nixify # Build your project with Nix nix-build
Running Composer with this plugin enabled will generate two files:
-
composer-project.nix: This file is always overwritten, and contains a basic derivation for your project. -
default.nix: Only generated if it does not exist yet. This file is intended to be customized with any project-specific logic you need.
This may already build successfully! But if your project needs extra build
steps, you may have to customize default.nix a bit. Some examples of what's
possible:
{ pkgs ? import <nixpkgs> { } }: let # Example of providing a different source tree. src = pkgs.lib.cleanSource ./.; project = pkgs.callPackage ./composer-project.nix { # Example of selecting a specific version of PHP. php = pkgs.php74; } src; in project.overrideAttrs (oldAttrs: { # Example of overriding the default package name taken from composer.json. name = "myproject"; # Example of adding packages to the build environment. buildInputs = oldAttrs.buildInputs ++ [ pkgs.imagemagick ]; # Example of invoking a build step in your project. buildPhase = '' composer run lint ''; })
Settings
Some additional settings are available which can be set in the "extra" object
in your composer.json:
-
nix-expr-pathcan be set to customize the path where the Nixify plugin writescomposer-project.nix. For example, if you're also using Niv in your project, you may prefer to set this tonix/composer-project.nix. -
generate-default-nixcan be set tofalseto disable generating adefault.nix. This file is only generated if it doesn't exist yet, but this flag can be useful if you don't want adefault.nixat all. -
enable-nix-preloadcan be set tofalseto disable preloading Composer cache into the Nix store. This preloading is intended to speed up a localnix-build, because Nix will not have to download dependencies again. Preloading does mean another copy of dependencies on disk, even if you don't do local Nix builds, but the size is usually not an issue on modern disks.
stephank/composer-plugin-nixify 适用场景与选型建议
stephank/composer-plugin-nixify 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.45k 次下载、GitHub Stars 达 17, 最近一次更新时间为 2020 年 09 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 stephank/composer-plugin-nixify 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stephank/composer-plugin-nixify 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 11.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2020-09-27