about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/by-name/ad/adminerevo/index.php35
-rw-r--r--pkgs/by-name/ad/adminerevo/package.nix73
2 files changed, 108 insertions, 0 deletions
diff --git a/pkgs/by-name/ad/adminerevo/index.php b/pkgs/by-name/ad/adminerevo/index.php
new file mode 100644
index 0000000000000..838b5948ae4d3
--- /dev/null
+++ b/pkgs/by-name/ad/adminerevo/index.php
@@ -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');
+}
diff --git a/pkgs/by-name/ad/adminerevo/package.nix b/pkgs/by-name/ad/adminerevo/package.nix
new file mode 100644
index 0000000000000..398d007671002
--- /dev/null
+++ b/pkgs/by-name/ad/adminerevo/package.nix
@@ -0,0 +1,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;
+  };
+})