• Stars
    star
    14
  • Rank 1,438,076 (Top 29 %)
  • Language
    PHP
  • License
    BSD 2-Clause "Sim...
  • Created about 4 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Composer plugin to help with Nix packaging

composer-plugin-nixify

Generates a Nix expression to build a Composer project.

  • A default configure-phase that runs composer install in 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 your composer.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 update dependencies.

  • 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-path can be set to customize the path where the Nixify plugin writes composer-project.nix. For example, if you're also using Niv in your project, you may prefer to set this to nix/composer-project.nix.

  • generate-default-nix can be set to false to disable generating a default.nix. This file is only generated if it doesn't exist yet, but this flag can be useful if you don't want a default.nix at all.

  • enable-nix-preload can be set to false to disable preloading Composer cache into the Nix store. This preloading is intended to speed up a local nix-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.

More Repositories

1

lazyssh

A jump-host SSH server that starts machines on-demand
Go
475
star
2

orona

Bolo, a game of tank warfare, rewritten for modern browsers.
CoffeeScript
263
star
3

surreal

Reviving the original Unreal Tournament on modern systems.
C++
83
star
4

docker-for-mac-nfs

NFS shares in Docker for Mac
Shell
62
star
5

villain

Real-time browser games in JavaScript and CoffeeScript.
CoffeeScript
58
star
6

castling.club

Challenge someone to a game of chess using toots!
TypeScript
50
star
7

hyper-staticfile

Static file-serving for Hyper 0.14
Rust
49
star
8

yarn-plugin-nixify

Yarn v3 plugin to help with Nix packaging
TypeScript
48
star
9

rvsim

A RISC-V simulator implementing RV32G[C].
Rust
31
star
10

domjuice

DOM-aware dynamic templates
CoffeeScript
29
star
11

vindinium-client

Client library for vindinium.org
JavaScript
25
star
12

inject_dylib

Load a dynamic library and start a thread in another process
C
23
star
13

arashi-js

ArashiJS is a Tempest-clone in JavaScript / HTML5
JavaScript
18
star
14

yaml.node

A Node.js binding for LibYAML.
JavaScript
13
star
15

docker-archlinux

Docker images of Arch Linux.
Shell
12
star
16

mcdisablewheel

Small patch for MCPatcher to disable the mouse wheel.
Java
10
star
17

nagios-bird

Nagios plugins for monitoring the BIRD routing daemon.
Perl
8
star
18

node-libalac

Apple Lossless codec bindings
C++
7
star
19

diridp

OIDC IdP that issues tokens as local files
Rust
6
star
20

tokio-smtp

Implementation of SMTP for Rust and Tokio.
Rust
6
star
21

nix-darwin-installer

Combined Nix / nix-darwin installer.
SCSS
6
star
22

libvirtweb

A simple web interface to libvirt
Java
6
star
23

openwrt

Fork of git://nbd.name/openwrt.git
C
5
star
24

webcoin-dogecoin

Experimental Dogecoin support for Webcoin
C++
5
star
25

sshiny

Work in progress SSH client & server
JavaScript
5
star
26

node-arrays

Pure-JS implementation of Typed Arrays
JavaScript
4
star
27

json-ns

A subset of JSON-LD
Rust
4
star
28

yarn-nixpkgs

A prototype tool for automating packaging of Node.js applications for NixOS / Nixpkgs.
TypeScript
3
star
29

luci2-netifd

Fork of git://nbd.name/luci2/netifd.git
C
2
star
30

jetpack

Jetpack is a small arcade game originally written by Mark Bradley.
C
2
star
31

out-game

'Out', the tiny arcade game I made for Ludum Dare 22
CoffeeScript
1
star
32

js-diff-benchmarks

Benchmarks of JS object diffing libraries.
JavaScript
1
star
33

authproto

Simple Auth Service Prototype
JavaScript
1
star
34

dumpnar

Minimal tool to produce a Nix NAR archive.
C++
1
star
35

broccoli-bundle-assets

Create bundles of JS and CSS assets
JavaScript
1
star
36

upgradeEx

Response object for HTTP Upgrade/CONNECT
JavaScript
1
star
37

broccoli-angular-templates

Inline files as ng-template script tags
JavaScript
1
star
38

zonemaster

DNS server implementing just zone transfer
JavaScript
1
star