forked from ddeboer/transcoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
57 lines (50 loc) · 1.73 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{
description = "Better encoding conversion for PHP";
inputs = {
# For old PHP versions.
phps.url = "github:fossar/nix-phps";
};
outputs = { self, phps }:
let
# nixpkgs is a repository with software packages and some utilities.
# From simplicity, we inherit it from the phps flake.
inherit (phps.inputs) nixpkgs;
# Configure the development shell here (e.g. for CI).
# By default, we use the default PHP version from Nixpkgs.
matrix.phpPackage = "php";
# Allow easily removing some extensions for testing.
matrix.forbiddenExtensionNames = [
# "iconv"
# "mbstring"
];
in
let
# We only support a single platform at the moment,
# since our binary cache only contains PHP packages for that.
system = "x86_64-linux";
# Get Nixpkgs packages for current platform.
pkgs = nixpkgs.legacyPackages.${system};
# Create a PHP package from the selected PHP package.
phpBase = phps.packages.${system}.${matrix.phpPackage};
php =
phpBase.withExtensions
({ all, enabled }:
let
# Get the forbidden extensions by name.
forbiddenExtensions = pkgs.lib.attrVals matrix.forbiddenExtensionNames all;
in
builtins.filter (ext: !builtins.elem ext forbiddenExtensions) enabled
);
in {
# Expose shell environment for development.
devShell.${system} = pkgs.mkShell {
nativeBuildInputs = [
# Composer and PHP.
php
phpBase.packages.composer
phpBase.packages.php-cs-fixer
phpBase.packages.phpstan
];
};
};
}