aboutsummaryrefslogtreecommitdiffstats
path: root/flake.nix
blob: 95cc8f9c87ea2d3510909ba50f74ba52bf246e71 (plain)
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
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
        lib = pkgs.lib;
      in
      {
        devShells.default =
          let
            php_version = lib.strings.concatStrings (builtins.match ".*PHP_VERSION_ID < ([0-9])0([0-9])00.*" (builtins.readFile ./lib/versioncheck.php));
            php = pkgs.pkgs."php${php_version}".buildEnv {
              # Based off https://docs.nextcloud.com/server/latest/admin_manual/installation/php_configuration.html
              extensions = ({ enabled, all }: enabled ++ (with all; [
                # Required
                ctype
                curl
                dom
                fileinfo
                filter
                gd
                mbstring
                openssl
                posix
                session
                simplexml
                xmlreader
                xmlwriter
                zip
                zlib
                # Database connectors
                pdo_sqlite
                pdo_mysql
                pdo_pgsql
                # Recommended
                intl
                sodium
                # Required for specific apps
                ldap
                smbclient
                ftp
                imap
                # Recommended for specific apps (optional)
                gmp
                exif
                # For enhanced server performance (optional)
                apcu
                memcached
                redis
                # For preview generation (optional)
                imagick
                # For command line processing (optional)
                pcntl

                # Debugging
                xdebug
              ]));

              extraConfig = ''
                max_execution_time=300
                memory_limit=-1

                xdebug.mode=debug
              '';
            };
            node_version = builtins.substring 1 (-1) (builtins.elemAt (lib.strings.splitString "." (builtins.fromJSON (builtins.readFile ./package.json)).engines.node) 0);
            node = pkgs."nodejs_${node_version}";
          in
          pkgs.mkShell {
            NOCOVERAGE = 1;

            packages = [
              php
              php.packages.composer
              node
              # Preview generation
              pkgs.ffmpeg
              pkgs.libreoffice
            ];
          };
      }
    );
}