about summary refs log tree commit diff
path: root/pkgs/by-name/ad/adminerevo/package.nix
blob: 398d007671002e3f85c465a015ccc220bd32bf64 (plain) (blame)
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
{ lib
, pkgs
, stdenvNoCC
, fetchFromGitHub
, php
, nix-update-script
, theme ? null
, plugins ? []
}:

stdenvNoCC.mkDerivation (finalAttrs: {
  version = "4.8.4";
  pname = "adminerevo";

  src = fetchFromGitHub {
    owner = "adminerevo";
    repo = "adminerevo";
    rev = "v${finalAttrs.version}";
    hash = "sha256-cyKSwzoVbS/0Fiv02kFIF4MTOqzpKSEFwwUwS4yqL6Q=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    php
  ];

  buildPhase = ''
    runHook preBuild

    php compile.php

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir $out
    cp adminer-${finalAttrs.version}.php $out/adminer.php
    cp ${./index.php} $out/index.php

    ${lib.optionalString (theme != null) ''
      cp designs/${theme}/adminer.css $out/adminer.css
    ''}

    # Copy base plugin
    mkdir -p $out/plugins
    cp plugins/plugin.php $out/plugins/plugin.php

    ${lib.optionalString (plugins != []) ''
      cp plugins/*.php $out/plugins/
      cp ${pkgs.writeText "$out/plugins.json" ''
        ${toString (builtins.toJSON plugins)}
      ''} $out/plugins.json
    ''}

    runHook postInstall
  '';

  passthru = {
    updateScript = nix-update-script { };
  };

  meta = with lib; {
    description = "Database management in a single PHP file";
    homepage = "https://docs.adminerevo.org";
    license = with licenses; [ asl20 gpl2Only ];
    maintainers = with maintainers; [
      shyim
    ];
    platforms = platforms.all;
  };
})