adminer-pematon: init at 4.12 (#358530)

authored by

Masum Reza and committed by
GitHub
d1d5334c 19f40a30

+120
+45
pkgs/by-name/ad/adminer-pematon/index.php
···
··· 1 + <?php 2 + 3 + declare(strict_types=1); 4 + 5 + namespace nixos { 6 + use AdminerPlugin; 7 + 8 + use function sprintf; 9 + 10 + function adminer_object(): object 11 + { 12 + require_once __DIR__ . '/plugins/plugin.php'; 13 + 14 + if (!file_exists(__DIR__ . '/plugins.json')) { 15 + return new AdminerPlugin(); 16 + } 17 + 18 + $plugins = array_map( 19 + static function (string $name): ?object { 20 + $plugin = sprintf('%s/plugins/%s.php', __DIR__, $name); 21 + 22 + if (!is_readable($plugin)) { 23 + return null; 24 + } 25 + 26 + require $plugin; 27 + 28 + preg_match_all('/(\w+)/', $name, $matches); 29 + 30 + return new sprintf('Adminer%s', implode('', array_map('ucfirst', $matches[1]))); 31 + }, 32 + json_decode(file_get_contents(sprintf('%s/plugins.json', __DIR__), true)) 33 + ); 34 + 35 + return new AdminerPlugin(array_filter($plugins)); 36 + } 37 + } 38 + 39 + namespace { 40 + function adminer_object() { 41 + return \nixos\adminer_object(); 42 + } 43 + 44 + require(__DIR__ . '/adminer.php'); 45 + }
+75
pkgs/by-name/ad/adminer-pematon/package.nix
···
··· 1 + { 2 + lib, 3 + stdenvNoCC, 4 + fetchFromGitHub, 5 + php, 6 + writeText, 7 + nix-update-script, 8 + theme ? null, 9 + plugins ? [ ], 10 + }: 11 + stdenvNoCC.mkDerivation (finalAttrs: { 12 + pname = "adminer-pematon"; 13 + version = "4.12"; 14 + 15 + src = fetchFromGitHub { 16 + owner = "pematon"; 17 + repo = "adminer"; 18 + rev = "refs/tags/v${finalAttrs.version}"; 19 + hash = "sha256-ExCHEsZ+VFmrom3632/1OOjb3zbZgiaZJDapBkBGUnQ="; 20 + }; 21 + 22 + nativeBuildInputs = [ 23 + php 24 + ]; 25 + 26 + buildPhase = '' 27 + runHook preBuild 28 + 29 + php compile.php 30 + 31 + runHook postBuild 32 + ''; 33 + 34 + installPhase = '' 35 + runHook preInstall 36 + 37 + mkdir $out 38 + cp temp/adminer-${finalAttrs.version}.php $out/adminer.php 39 + cp ${./index.php} $out/index.php 40 + 41 + ${lib.optionalString (theme != null) '' 42 + cp designs/${theme}/adminer.css $out/adminer.css 43 + ''} 44 + 45 + # Copy base plugin 46 + mkdir -p $out/plugins 47 + cp plugins/plugin.php $out/plugins/plugin.php 48 + 49 + ${lib.optionalString (plugins != [ ]) '' 50 + cp plugins/*.php $out/plugins/ 51 + cp ${writeText "$out/plugins.json" '' 52 + ${toString (builtins.toJSON plugins)} 53 + ''} $out/plugins.json 54 + ''} 55 + 56 + runHook postInstall 57 + ''; 58 + 59 + passthru = { 60 + updateScript = nix-update-script { }; 61 + }; 62 + 63 + meta = { 64 + description = "Database management in a single PHP file (Pematon fork)"; 65 + homepage = "https://github.com/pematon/adminer"; 66 + license = with lib.licenses; [ 67 + asl20 68 + gpl2Only 69 + ]; 70 + maintainers = with lib.maintainers; [ 71 + johnrtitor 72 + ]; 73 + platforms = lib.platforms.all; 74 + }; 75 + })