forked from fossar/selfoss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
90 lines (73 loc) · 2.76 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
description = "selfoss feed reader and aggregator";
inputs = {
# Shim to make flake.nix work with stable Nix.
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
# Repository with software packages.
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
# Package expression for old PHP versions.
phps.url = "github:fossar/nix-phps";
};
outputs = { self, flake-compat, nixpkgs, phps, utils }:
let
# Configure the development shell here (e.g. for CI).
# By default, we use the default PHP version from Nixpkgs.
matrix.phpPackage = "php";
# We install all storage backends by default.
matrix.storage = "all";
in
# For each supported platform,
utils.lib.eachDefaultSystem (system:
let
# Get Nixpkgs packages for current platform.
pkgs = nixpkgs.legacyPackages.${system};
# Create a PHP package from the selected PHP package, with some extra extensions enabled.
php = phps.packages.${system}.${matrix.phpPackage}.withExtensions ({ enabled, all }: with all; enabled ++ [
imagick
]);
# Create a Python package with some extra packages installed.
python = pkgs.python3.withPackages (pp: with pp; [
# For integration tests.
bcrypt
requests
]);
# Database servers for testing.
dbServers = {
mysql = [ pkgs.mariadb ];
postgresql = [ pkgs.postgresql ];
sqlite = [ ];
all = builtins.concatLists (builtins.attrValues (builtins.removeAttrs dbServers [ "all" ]));
};
in
{
# Expose shell environment for development.
devShell = pkgs.mkShell {
nativeBuildInputs = [
# Composer and PHP for back-end.
php
php.packages.composer
# Back-end code validation.
php.packages.psalm
php.packages.phpstan
# npm for front-end.
pkgs.nodejs_latest
# For building zip archive.
pkgs.jq
# For building zip archive and integration tests.
python
# Website generator.
pkgs.zola
] ++ dbServers.${matrix.storage};
# node-gyp wants some locales, let’s make them available through an environment variable.
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
# This has not been backported to the phpunit-bridge version we use:
# https://github.com/symfony/phpunit-bridge/commit/d3bc23e3471d978218121175516045981fcef411
SYMFONY_PHPUNIT_VERSION = pkgs.lib.optionalString (matrix.phpPackage == "php81") "9.5";
};
}
);
}