From fb112dca9c785a71eaf033732b87519a6575b3a8 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 25 Nov 2022 20:51:34 -0500 Subject: spine-search-cgi separate commits, remove sundry --- org/config_nix.org | 361 ----------------------------------------------------- 1 file changed, 361 deletions(-) (limited to 'org/config_nix.org') diff --git a/org/config_nix.org b/org/config_nix.org index 8286b05..7bd1645 100644 --- a/org/config_nix.org +++ b/org/config_nix.org @@ -1245,367 +1245,6 @@ jq git #+END_SRC -** spine search cgi (in ./sundry) -*** envrc :envrc: -**** .envrc - -#+HEADER: :tangle "../sundry/spine_search_cgi/.envrc" -#+BEGIN_SRC sh -NIX_ENFORCE_PURITY=0 -if ! has nix_direnv_version || ! nix_direnv_version 1.4.0; then -# https://github.com/nix-community/nix-direnv - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/1.4.0/direnvrc" "sha256-4XfVDjv75eHMWN4G725VW7BoOV4Vl3vAabK4YXIfPyE=" -fi -if [ -f .envrc-local ]; then - source_env_if_exists .envrc-local || source .envrc-local -fi -#+END_SRC - -**** .envrc-local - -#+HEADER: :tangle "../sundry/spine_search_cgi/.envrc-local_" -#+HEADER: :noweb yes -#+BEGIN_SRC nix -export NIX_PATH=<> -#export NIX_PATH=nixpkgs=<> -# reload when these files change -# watch_file flake.nix -# watch_file flake.lock -## load the flake devShell -# eval "$(nix print-dev-env)" -# echo $NIX_BUILD_TOP -export SpineVER=$(git describe --long --tags | sed 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g') -export SpinePROJ=<> -export SpineSRC=<> -export SpineBIN=<> -export SpineDOC=<> -export SpinePOD=$SpineDOC/markup/pod -#export SpineOUTversioned=<> -export SpineOUT=<> -export SpineDBpath=<> -export SpineCgiBIN=<> -if [ -e .env/echo-nixNote ]; then # source an additional user-specific .envrc in ./.envrc-local - source .env/echo-nixNote -fi -#+END_SRC - -**** .envrc-local - -#+HEADER: :tangle "../sundry/spine_search_cgi/.env/echo-nixNote" -#+BEGIN_SRC sh -echo '-*- mode: org -*- - -,* nixpkgs path? - - # eval "$(nix print-dev-env)" -' > nixNote_.org - -echo " == `nix-instantiate --find-file nixpkgs`" >> nixNote_.org - -echo ' -,* nix build and show derivation - -,#+BEGIN_SRC sh -nix-shell --pure - -nix-build -nix build -f default.nix --print-build-logs -nix shell -f default.nix --print-build-logs -nix develop --build -f derivation.nix -I .envrc --print-build-logs -nix-instantiate | nix-build -nix build `nix-instantiate` - -nix develop - -nix-instantiate | nix show-derivation | jq -nix-instantiate | nix show-derivation --recursive | jq - -nix search --json 2>/dev/null |jq -,#+END_SRC - -,* version and build info - -,#+BEGIN_SRC sh' >> nixNote_.org - -echo 'spine version (git) == $SpineVER' >> nixNote_.org -echo "spine version (git) == $SpineVER" >> nixNote_.org -echo 'nix-instantiate == `nix-instantiate`' >> nixNote_.org -echo "nix-instantiate == `nix-instantiate`" >> nixNote_.org - -echo "#+END_SRC - -,* initialised shell variables - -,#+BEGIN_SRC sh -SpineSRC=$SpineSRC -SpineBIN=$SpineBIN -SpineDOC=$SpineDOC -SpinePOD=$SpinePOD -#SpineOUTversioned=$SpineOUTversioned -SpineOUT=$SpineOUT -SpineCgiBIN=$SpineCgiBIN -,#+END_SRC -" >> nixNote_.org - -echo '* cgi form spine_search nix build and copy to spine-search - -,#+BEGIN_SRC sh -nix-build && sudo cp -vi result/share/cgi-bin/spine_search $SpineCgiBIN/. -,#+END_SRC - -,* spine run instruction examples -,** cgi operations (output to $SpineOUT) -,*** configuration - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --show-config --config=$SpinePOD/.dr -,#+END_SRC - -,*** generate html (linked to search form & curate) - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --html --html-link-search --html-link-curate --sqlite-db-filename="<>" --cgi-sqlite-search-filename="<>"--output=$SpineOUT $SpinePOD/* -,#+END_SRC - -,*** generate sql output - -,#+BEGIN_SRC sh -SpineBIN/spine -v --sqlite-update --sqlite-db-filename="<>" --sqlite-db-path="$SpineDBpath" -,#+END_SRC - -,*** generate curate - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --curate --output=$SpineOUT $SpinePOD/* -$SpineBIN/spine -v --html --html-link-curate --curate --output=$SpineOUT $SpinePOD/* -,#+END_SRC - -,*** create or re-create sql db (--sqlite-db-create or --sqlite-db-recreate) - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --sqlite-db-recreate --sqlite-db-filename="<>" --sqlite-db-path="$SpineDBpath" -,#+END_SRC - -,*** generate html (linked to search form), sql output, curate - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --html --html-link-search --html-link-curate --curate --sqlite-db-filename="<>" --cgi-sqlite-search-filename="<>" --sqlite-update --sqlite-db-path="$SpineDBpath" --output="$SpineOUT" $SpinePOD/* -#if names and paths are configured in resource configuration file, e.g. $SpinePOD/.rc/config_local_site -$SpineBIN/spine -v --html --html-link-search --html-link-curate --curate --sqlite-update $SpinePOD/* -,#+END_SRC - -,*** make search form - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --cgi-search-form-codegen --config=$SpinePOD/.dr/config_local_site -#$SpineBIN/spine -v --cgi-search-form-codegen --output=$SpineOUT $SpinePOD/* -,#+END_SRC -' >> nixNote_.org - -#cat nixNote_.org - -#echo "emacs nixNote_.org" -#echo "cat nixNote_.org" -#+END_SRC - -*** flake :flake: - -- flake.nix - -nix develop - -nix flake update - -#+HEADER: :tangle "../sundry/spine_search_cgi/flake.nix" -#+HEADER: :noweb yes -#+BEGIN_SRC nix -{ - description = "a sisu like document parser search form"; - inputs = { - flake-utils.url = "github:numtide/flake-utils"; - nixpkgs.url = "<>"; - }; - outputs = { self, nixpkgs, flake-utils }: - let - pkgs = nixpkgs.legacyPackages.x86_64-linux; - in { - packages.x86_64-linux.spine = pkgs.stdenv.mkDerivation { - name = "spine_search"; - inherit self; - src = self; - shell = ./shell.nix; - installPhase = '' - install -m755 -D spine_search $out/share/cgi-bin/spine_search - ''; - }; - defaultPackage.x86_64-linux = self.packages.x86_64-linux.spine; - }; -} -#+END_SRC - -*** shell.nix :shell: - -#+HEADER: :tangle "../sundry/spine_search_cgi/shell.nix" -#+HEADER: :tangle-mode (identity #o755) -#+HEADER: :shebang "#!/usr/bin/env -S nix-shell --pure" -#+HEADER: :noweb yes -#+BEGIN_SRC nix -{ pkgs ? import {} }: -with pkgs; -mkShell { - buildInputs = [ - <> - <> - <> - <> - <> - ]; - shellHook = '' - if [[ -f ".envrc" ]]; then - source .envrc - fi - ''; -} -#+END_SRC - -*** default.nix :default: - -#+HEADER: :tangle "../sundry/spine_search_cgi/default.nix" -#+HEADER: :tangle-mode (identity #o755) -#+HEADER: :shebang "#!/usr/bin/env -S nix-build" -#+BEGIN_SRC nix -{ pkgs ? import {} }: -pkgs.callPackage ./derivation.nix {} -#+END_SRC - -*** derivation.nix :derivation: - -#+HEADER: :tangle "../sundry/spine_search_cgi/derivation.nix" -#+HEADER: :tangle-mode (identity #o644) -#+HEADER: :noweb yes -#+BEGIN_SRC nix -{ pkgs ? import {}, - stdenv ? pkgs.stdenv, - lib ? pkgs.lib, - ldc ? null, - dcompiler ? pkgs.ldc, - dub ? pkgs.dub -}: -assert dcompiler != null; -with ( - assert dcompiler != null; - with lib; - let - # Filter function to remove the .dub package folder from src - filterDub = name: type: let baseName = baseNameOf (toString name); in ! ( - type == "directory" && baseName == ".dub" - ); - targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}"; - # Remove reference to build tools and library sources - disallowedReferences = deps: [ dcompiler dub ]; - removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}''; - in { - mkDubDerivation = lib.makeOverridable ({ - src, - nativeBuildInputs ? [], - dubJSON ? src + "/dub.json", - passthru ? {}, - package ? lib.importJSON dubJSON, - ... - } @ attrs: stdenv.mkDerivation (attrs // { - pname = package.name; - nativeBuildInputs = [ dcompiler dub pkgs.removeReferencesTo ] ++ nativeBuildInputs; - disallowedReferences = disallowedReferences deps; - passthru = passthru // { - inherit dub dcompiler pkgs; - }; - src = lib.cleanSourceWith { - filter = filterDub; - src = lib.cleanSource src; - }; - preFixup = '' - find $out/share/cgi-bin -type f -exec ${removeExpr (disallowedReferences deps)} '{}' + || true - ''; - buildPhase = '' - runHook preBuild - export HOME=$PWD - for dc_ in dmd ldmd2 gdmd; do - echo "- check for D compiler $dc_" - dc=$(type -P $dc_ || echo "") - if [ ! "$dc" == "" ]; then - break - fi - done - if [ "$dc" == "" ]; then - exit "Error: could not find D compiler" - fi - echo "$dc_ used as D compiler to build $pname" - dub build --compiler=$dc --build=release --combined --skip-registry=all - runHook postBuild - ''; - checkPhase = '' - runHook preCheck - export HOME=$PWD - dub test --combined --skip-registry=all - runHook postCheck - ''; - installPhase = '' - runHook preInstall - mkdir -p $out/share/cgi-bin - cp -r "${targetOf package}" $out/share/cgi-bin - install -m755 -D $out/share/cgi-bin/spine_search spine_search - runHook postInstall - ''; - postInstall = '' - echo "HERE ${targetOf package} $out/share/cgi-bin" - echo `ls -la $out/share/cgi-bin/spine_search` - ''; - meta = lib.optionalAttrs (package ? description) { - description = package.description; - } // attrs.meta or {}; - } // lib.optionalAttrs (!(attrs ? version)) { - name = package.name; # use name from dub.json, unless pname and version are specified - })); - } -); -mkDubDerivation rec { - name = "spine-search-${version}"; - version = "<>"; - src = ./.; - buildInputs = [ - pkgs.sqlite ( - with pkgs; [ - nixVersions.unstable #nixFlakes - ## package manager - dub - ## compiler - ldc - rund - ## linker - #lld - #mold - ## builder - #ninja - sqlite - ] - ) - ]; - meta = with pkgs.lib; { - pname = "spine-search"; - version = "<>"; - homepage = "https://sisudoc.org"; - description = "cgi sqlite search form for document object search"; - longDescription = '' - A sisu like parser and document generator - ... - ''; - license = licenses.agpl3Plus; - platforms = platforms.linux; - maintainers = [ "RalphAmissah" ]; - }; -} -#+END_SRC - ** variables *** spine version SET VERSION :version:set:project: -- cgit v1.2.3