Skip to content

Commit

Permalink
adminer-pematon: init at 4.12
Browse files Browse the repository at this point in the history
This is an active fork of adminer by pematon. Seems to be in rapid development.
The index.php is required for plugins to work, and the upstream provides an example, but not a ".php" file.
We need to modify it for NixOS use anyway.

Signed-off-by: John Titor <[email protected]>
  • Loading branch information
JohnRTitor committed Nov 24, 2024
1 parent dce14bd commit b68d27a
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pkgs/by-name/ad/adminer-pematon/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace nixos {
function adminer_object() {
require_once(__DIR__ . '/plugins/plugin.php');

$plugins = [];
if (file_exists(__DIR__ . '/plugins.json')) {
$names = json_decode(file_get_contents(__DIR__ . '/plugins.json'), true);

foreach ($names as $name) {
$plugin = __DIR__ . '/plugins/' . $name . '.php';
if (is_readable($plugin)) {
require($plugin);

preg_match_all('/(\w+)/', $name, $matches);

$className = 'Adminer'. implode('', array_map('ucfirst', $matches[1]));

$plugins[] = new $className;
}
}
}

return new \AdminerPlugin($plugins);
}
}

namespace {
function adminer_object() {
return \nixos\adminer_object();
}

require(__DIR__ . '/adminer.php');
}
75 changes: 75 additions & 0 deletions pkgs/by-name/ad/adminer-pematon/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
lib,
stdenvNoCC,
fetchFromGitHub,
php,
writeText,
nix-update-script,
theme ? null,
plugins ? [ ],
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "adminer-pematon";
version = "4.12";

src = fetchFromGitHub {
owner = "pematon";
repo = "adminer";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-ExCHEsZ+VFmrom3632/1OOjb3zbZgiaZJDapBkBGUnQ=";
};

nativeBuildInputs = [
php
];

buildPhase = ''
runHook preBuild
php compile.php
runHook postBuild
'';

installPhase = ''
runHook preInstall
mkdir $out
cp temp/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 ${writeText "$out/plugins.json" ''
${toString (builtins.toJSON plugins)}
''} $out/plugins.json
''}
runHook postInstall
'';

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

meta = {
description = "Database management in a single PHP file (Pematon fork)";
homepage = "https://github.com/pematon/adminer";
license = with lib.licenses; [
asl20
gpl2Only
];
maintainers = with lib.maintainers; [
johnrtitor
];
platforms = lib.platforms.all;
};
})

0 comments on commit b68d27a

Please sign in to comment.