fix?(package): postgreact: ~stir the stupid shit till it works [3]
This commit is contained in:
3
package/c/postgreact/.gitignore
vendored
Normal file
3
package/c/postgreact/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
package/c/postgreact/postgreact.control
|
||||
package/c/postgreact/postgreact.o
|
||||
package/c/postgreact/postgreact.so
|
||||
@@ -1,16 +1,18 @@
|
||||
EXTENSION ?= postgreact
|
||||
EXTENSION_VERSION ?= 1.0
|
||||
|
||||
# INFO(nrv): just in case idk how pgxs Makefile and shit all work
|
||||
EXTVERSION = $(EXTENSION_VERSION)
|
||||
EXTENSION_COMMENT ?= My first extension
|
||||
|
||||
MODULE_big = $(EXTENSION)
|
||||
DATA = $(EXTENSION)--$(EXTENSION_VERSION).sql
|
||||
DATA = $(EXTENSION)--$(EXTENSION_VERSION).sql $(EXTENSION).control
|
||||
OBJS = $(EXTENSION).o
|
||||
PG_CONFIG = pg_config
|
||||
|
||||
$(BUILD_DIR)/$(EXTENSION).control:
|
||||
sed "s/@EXTENSION_VERSION@/$(EXTVERSION)/g" $(EXTENSION).control.in > $@
|
||||
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
|
||||
.PHONY: $(EXTENSION).control
|
||||
|
||||
$(EXTENSION).control:
|
||||
sed "s/@EXTENSION_VERSION@/$(EXTENSION_VERSION)/g; s/@EXTENSION_COMMENT@/$(EXTENSION_COMMENT)/g; s/@EXTENSION@/$(EXTENSION)/g" $(EXTENSION).control.in > $@
|
||||
|
||||
include $(PGXS)
|
||||
|
||||
# vim:wrap
|
||||
|
||||
@@ -1,11 +1,42 @@
|
||||
{
|
||||
lib,
|
||||
}: {
|
||||
stdenv,
|
||||
postgresql,
|
||||
...
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "postgreact";
|
||||
version = "1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
USE_PGXS = 1;
|
||||
EXTENSION = pname;
|
||||
EXTENSION_VERSION = version;
|
||||
EXTENSION_COMMENT = meta.description;
|
||||
|
||||
buildInputs = [
|
||||
postgresql
|
||||
];
|
||||
|
||||
buildPhase = ''make all'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/lib/postgresql $out/share/postgresql/extension
|
||||
|
||||
# Install compiled library
|
||||
install -m 755 -D postgreact.so $out/lib/postgresql/postgreact.so
|
||||
|
||||
# Install control and SQL files
|
||||
install -m 644 -D postgreact.control $out/share/postgresql/extension/postgreact.control
|
||||
install -m 644 -D postgreact--${EXTENSION_VERSION}.sql $out/share/postgresql/extension/postgreact--${EXTENSION_VERSION}.sql
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "PostgreSQL extension for simple templating.";
|
||||
homepage = "https://github.com/yukkop/util.nix";
|
||||
license = licenses.asl20;
|
||||
platforms = postgresql.meta.platforms;
|
||||
maintainers = with maintainers; [];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
#include "postgres.h"
|
||||
#include "fmgr.h"
|
||||
#include "utils/builtins.h" /* for text_to_cstring and cstring_to_text */
|
||||
#include "postgreact.h"
|
||||
|
||||
#ifdef PG_MODULE_MAGIC
|
||||
PG_MODULE_MAGIC;
|
||||
#endif
|
||||
|
||||
Datum hello(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_TEXT_P(cstring_to_text("Eblan!"));
|
||||
Datum hello(PG_FUNCTION_ARGS) {
|
||||
PG_RETURN_TEXT_P(cstring_to_text("Eblan!"));
|
||||
}
|
||||
|
||||
void _PG_init(void) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
comment = 'My first extension'
|
||||
comment = '@EXTENSION_COMMENT@'
|
||||
default_version = '@EXTENSION_VERSION@'
|
||||
module_pathname = '$libdir/postgreact'
|
||||
module_pathname = '$libdir/@EXTENSION@'
|
||||
relocatable = false
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef POSTGREACT_H
|
||||
#define POSTGREACT_H
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#ifdef PG_MODULE_MAGIC
|
||||
@@ -9,3 +12,5 @@ void _PG_fini(void);
|
||||
|
||||
Datum hello(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(hello);
|
||||
|
||||
#endif // POSTGREACT_H
|
||||
|
||||
Reference in New Issue
Block a user