diff options
-rw-r--r-- | .envrc | 12 | ||||
-rw-r--r-- | .envrc-local_ | 34 | ||||
-rw-r--r-- | .gitattributes | 4 | ||||
-rw-r--r-- | .gitignore | 46 | ||||
-rwxr-xr-x | default.nix | 3 | ||||
-rw-r--r-- | derivation.nix | 110 | ||||
-rw-r--r-- | flake.lock | 80 | ||||
-rw-r--r-- | flake.nix | 29 | ||||
-rw-r--r-- | makefile | 905 | ||||
-rw-r--r-- | org/config_git.org | 104 | ||||
-rw-r--r-- | org/config_make.org | 927 | ||||
-rw-r--r-- | org/config_nix.org | 846 | ||||
-rwxr-xr-x[-rw-r--r--] | shell.nix | 99 |
13 files changed, 3175 insertions, 24 deletions
@@ -0,0 +1,12 @@ +# nix_direnv_watch_file provided-filename +use flake . +NIX_ENFORCE_PURITY=1 +NixDirEnvVersion="2.2.0" +if ! has nix_direnv_version || ! nix_direnv_version ${NixDirEnvVersion}; then +# - https://github.com/nix-community/nix-direnv +# source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-0000000000000000000000000000000000000000000=" + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-5EwyKnkJNQeXrRkYbwwRBcXbibosCJqyIUuz9Xq+LRc=" +fi +if [ -f .envrc-local ]; then + source_env_if_exists .envrc-local || source .envrc-local +fi diff --git a/.envrc-local_ b/.envrc-local_ new file mode 100644 index 0000000..af41175 --- /dev/null +++ b/.envrc-local_ @@ -0,0 +1,34 @@ +# reload when these files change +watch_file flake.lock +#watch_file flake.nix +nix flake update; nix flake check; nix flake show +#use flake .#default +PATH_add result/bin +#path_add PATH result/bin +#export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos +#export NIX_PATH=nixpkgs=/srv/nix/nixpkgs +export DFLAGS="-O2 -inline -boundscheck=on -color=on" +## load the flake devShell +# eval "$(nix print-dev-env)" +# echo $NIX_BUILD_TOP +export Date=`date "+%Y%m%d"` +export SpineDOC=. +#export SpineSRC= +export SpineBIN=result/bin +#export SpineDOC= +export SpinePOD=$SpineDOC/markup/pod +export SpineOUT=/srv/www/spine +export SpineDBpath=/srv/www/spine/sqlite +#export SpineDBpath=/var/www/sqlite +export SpineSearchActionLocal='http://localhost/spine_search' +export SpineSearchActionRemote='https://sisudoc.org/spine_search' +export SpineCGIform='spine_search' +export SpineSQLdb='spine.search.db' +#export PROG_VER_DECLARED="`cat ./views/version.txt | grep --color=never "enum" | sed 's/.\+(\([0-9]\+\),[ \t]\+\([0-9]\+\),[ \t]\+\([0-9]\+\)[ \t]*).\+/\1.\2.\3/g'`" +#direnv allow +echo " +nix build -v .#default --print-build-logs +nix run .#default --print-build-logs +nix shell .#default --print-build-logs --command spine -v +nix develop --build .#default --print-build-logs +" diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d157ce9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +/org export-ignore +.gitattributes export-ignore +.gitignore export-ignore +tangle export-ignore @@ -1,12 +1,29 @@ # git ls-files --others --exclude-from=.git/info/exclude -#./.dub/** +# git check-ignore -v flake.lock +# git clean -ix +# find . -name "*_" | xargs rm -rf +# find . -name "*.o" | xargs rm -rf * !.gitignore -!COPYRIGHT +!.gitattributes +!nix/** +!*.nix +!flake.lock +!.envrc !README -!shell.nix -!packages.nix +!COPYRIGHT +!CHANGELOG +!makefile !version.txt +!configuration.txt +!*.json +!*.sdl +!tangle +!*.org +!org +!org/*.org +!.dr +!.dr/* !markup/ !markup/pod/ !markup/pod/*/ @@ -36,32 +53,19 @@ !markup/pod/*/tools/po4a/po/*/*.ssm.po !markup/pod/*/tools/po4a/po/*/*.ssi.po .dub/** +**/.dub/** tmp/** *_.org +*_.nix *_.d *_.txt *_ +*.swp *~ \#* *.\#* +!.envrc-local_ #!*/ -#*~ #\#* #*.\#* -#!debian -#!debian/* #.reggae/** -# !markup -# !markup/* -# !markup/src/** -# !markup/src_yaml/** -# !markup/pod/** -# !markup/pod_yaml/** -# !*.sst -# !*.ssm -# !**/*.sst -# !**/*.ssm -# !pod.manifest -# !sisu_document_make -# !config_local_site -# !sisudoc diff --git a/default.nix b/default.nix new file mode 100755 index 0000000..72f4f02 --- /dev/null +++ b/default.nix @@ -0,0 +1,3 @@ +#!/usr/bin/env -S nix-build +{ pkgs ? import <nixpkgs> {} }: +pkgs.callPackage ./derivation.nix {} diff --git a/derivation.nix b/derivation.nix new file mode 100644 index 0000000..3b9ce81 --- /dev/null +++ b/derivation.nix @@ -0,0 +1,110 @@ +{ pkgs ? import <nixpkgs> {}, + stdenv ? pkgs.stdenv, + lib ? pkgs.lib, + ldc ? null, + dcompiler ? pkgs.ldc, + dub ? pkgs.dub +}: +assert dcompiler != null; +with ( + with lib; + let + filterDub = name: type: let baseName = baseNameOf (toString name); in ! ( # filter function to remove the .dub package folder from src + 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/bin -type f -exec ${removeExpr (disallowedReferences deps)} '{}' + || true + ''; + buildPhase = '' + runHook preBuild + HOME="$PWD" + DFLAGS="-O2 -inline" + 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 + HOME="$PWD" + dub test --combined --skip-registry=all + runHook postCheck + ''; + installPhase = '' + runHook preInstall + mkdir -p $out/bin + cp -r "${targetOf package}" $out/bin + #cp -rv "${targetOf package}" $out/spine-markup-samples/. + #cp -rv ./markup $out/spine-markup-samples/. + runHook postInstall + ''; + #postInstall= '' + # cp -rv ./markup $out/spine-markup-samples/. + #''; + 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 { + pname = "spine"; + version = "0.12.0"; + zipfile = "spine-0.12.0-tag-0.11.2.r107.gf89a107.tar.gz"; + src = fetchTarball { + #url = "file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/tarball/${pname}-${version}.tar.gz"; + #url = "file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine/tarballGitHEAD/${pname}-${version}.tar.gz"; + #sha256 = "sha256:0000000000000000000000000000000000000000000000000000"; + url = "file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/tarball/spine-0.12.0-tag-0.11.2.r107.gf89a107.tar.gz"; + sha256 = "sha256:03dr7dn7kq6arw4ry7qar13iqmi1caw70imfjwi8qr7g2j4mnk2q"; + }; + nativeBuildInputs = with pkgs; [ dub ldc ]; + buildInputs = with pkgs; [ + nixVersions.unstable #nixFlakes + sqlite + ]; + meta = with pkgs.lib; { + description = "A sisu like parser & document generator"; + longDescription = '' + A sisu like parser & document generator + ''; + homepage = "https://sisudoc.org"; + license = licenses.agpl3Plus; + platforms = platforms.linux; + maintainers = [ "RalphAmissah" ]; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ea922cf --- /dev/null +++ b/flake.lock @@ -0,0 +1,80 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1672249180, + "narHash": "sha256-ipos/gTMHqxS39asqNWEJZ7nXdcTHa0TB0AIZXkGapg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e58a7747db96c23b8a977e7c1bbfc5753b81b6fa", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "spine": "spine" + } + }, + "spine": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1672249472, + "narHash": "sha256-4rNyilsqtbTmkEyXgWcz1J3FDs5UpkXNMX+CkHfoKyE=", + "ref": "refs/heads/main", + "rev": "ba118bbf9d8040152798b60417da31d6d5a8cfb9", + "revCount": 568, + "type": "git", + "url": "file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine" + }, + "original": { + "type": "git", + "url": "file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3ef1f17 --- /dev/null +++ b/flake.nix @@ -0,0 +1,29 @@ +{ + description = "a sisu like document parser search form"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; # "github:nixos/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + spine.url = "git+file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine"; + spine.inputs.nixpkgs.follows = "nixpkgs"; + spine.flake = true; + }; + outputs = { self, nixpkgs, flake-utils, spine }: + let + version = "0.12.0"; + supportedSystems = [ "x86_64-linux" ]; # [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); # nixpkgs instantiated for supported system types. + in { + packages = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + in { + default = spine.packages.${system}.default; + #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; + }); + devShells = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + in with pkgs; { + devShell = mkShell { buildInputs = [ git dub dmd ldc gdc sqlite ]; }; + }); + }; +} diff --git a/makefile b/makefile new file mode 100644 index 0000000..70e6929 --- /dev/null +++ b/makefile @@ -0,0 +1,905 @@ +PROG_VER_GIT :=$(shell echo `git describe --long --tags | sed -e "s/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g"`) +#PROG_VER_DECLARED :=$(shell echo `cat ./views/version.txt | grep --color=never "enum" | sed 's/.\+(\([0-9]\+\),[ \t]\+\([0-9]\+\),[ \t]\+\([0-9]\+\)[ \t]*).\+/\1.\2.\3/g'`) +DUB=dub +DUB_FLAGS=-v --force --compiler= +PRG_NAME=doc-reform +PRG_NICKAME=spine +PRG_NAME_DIR=$(shell echo `echo $(PRG_NAME) | sed -e "s/-/_/g"`) +PRG_SRC=$(PRG_NAME).d +PRG_SRCDIR=./src +PRG_BIN=$(PRG_NAME) +PRG_BINDIR=./bin +PRG_DOCDIR=./docs +EMACSLISP=/usr/share/emacs/site-lisp +ORG_VER_AVAILABLE=$(shell echo `ls -d ~/.emacs.d/elpa/org-???????? | cut -d '-' -f2`) +EMACSLISP_ORG=~/.emacs.d/elpa/org-$($(shell echo $(ORG_VER_AVAILABLE))) +ORG_CONTRIB_VER_AVAILABLE=$(shell echo `ls -d ~/.emacs.d/elpa/org-plus-contrib-???????? | cut -d '-' -f2`) +EMACSLISP_ORG_CONTRIB=~/.emacs.d/elpa/org-plus-contrib-$($(shell echo $(ORG_CONTRIB_VER_AVAILABLE))) +ORGFILELIST=$(shell echo `ls -1 org/*.org`) +ORGFILES="" +ORGDIR :=$(shell echo `pwd`) +SiSU_MARKUP_SAMPLES_FIND_PODS= \ +find data/pod -maxdepth 2 -name pod.manifest | cut -f 1-3 -d / | sort + +SiSU_MARKUP_SAMPLES_PODS_FOUND= \ +$(SiSU_MARKUP_SAMPLES_FIND_PODS) | xargs + +# SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND = \ +# find data/sisudir/media/text -name *.ss[tm] | sort | xargs +# +Date := `date "+%Y%m%d"` +SpineBIN := "${SpineBIN}" # './result/bin' +SpineOUT := "${SpineOUT}" # '/srv/www/spine' +SpinePOD := "${SpinePOD}" # '~/grotto/repo/git.repo/projects/doc-reform/data/markup/spine-samples/markup/pod' +SpineSearchActionLocal := 'http://localhost/spine_search' +SpineSearchActionRemote := 'https://sisudoc.org/spine_search' +SpineCGIform := 'spine_search' +SpineSQLdb := 'spine.search.db' +hwd := `pwd` +gwd := `pwd` + "/src/ext_depends" +deps := "`ls -gx './src/ext_depends'`" +dirs_loc := "`ls -gx '.'`" +#dirs := "`ls -gx ${gwd}`" + +commands: + rg --color=always -B1 "^[a-z]\w+:" makefile | less + +cmd: + rg --color=always -B1 "^[a-z]\w+:" makefile | page + +# tangle org files +org-tangle: + cd ./org; \ + org-tangle *.org; \ + cd - + +# epub output +out-epub: + ${SpineBIN}/spine -v \ + --epub --output=${SpineOUT} ${SpinePOD}/* + +# html output with local search links +out-html: + ${SpineBIN}/spine -v --generated-by \ + --curate \ + --html --html-link-search --html-link-curate --cgi-url-action="${SpineSearchActionLocal}" \ + --output=${SpineOUT} ${SpinePOD}/* + +# latex output +out-latex: + ${SpineBIN}/spine -v \ + --latex \ + --output=${SpineOUT} ${SpinePOD}/* + +# odf output +out-odf: + ${SpineBIN}/spine -v \ + --odf \ + --output=${SpineOUT} ${SpinePOD}/* + +# sqlite output +out-sqlite: + ${SpineBIN}/spine -v \ + --sqlite-update --sqlite-db-filename="${SpineSQLdb}" \ + --output=${SpineOUT} ${SpinePOD}/* + +# generate markup sample output with local search links +output-samples-local: + ${SpineBIN}/spine -v \ + --latex --latex-init \ + --epub \ + --html --html-link-search --html-link-pdf --html-link-curate --html-link-markup \ + --cgi-sqlite-search-filename="${SpineCGIform}" --cgi-url-action="${SpineSearchActionLocal}" \ + --curate \ + --sqlite-update --sqlite-db-filename="${SpineSQLdb}" \ + --output=${SpineOUT} ${SpinePOD}/* + +# generate markup sample output with remote search links +output-samples-remote: + ${SpineBIN}/spine -v \ + --generated-by \ + --latex --latex-init \ + --epub \ + --html --html-link-search --html-link-pdf --html-link-curate \ + --cgi-sqlite-search-filename="${SpineCGIform}" --cgi-url-action="${SpineSearchActionRemote}" \ + --curate \ + --sqlite-update --sqlite-db-filename="${SpineSQLdb}" \ + --output=${SpineOUT} ${SpinePOD}/* + +# generate markup sample output with local search links +output-samples: output-samples-local + +# nix build (remote) run +generate-output-remote: nix-build output-samples-remote + +# nix build (local) run +generate-output-local: nix-build output-samples-local + +# preview org files vim +files-vim: + fd --max-depth 6 --type file -g "*" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(nvim {})"; \ + +# preview org files emacs +files-emacs: + fd --max-depth 6 --type file -g "*" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(emacsclient -nw -a -f {})"; \ + +# preview org files vim +org-vim: + cd ./org; \ + fd --max-depth 5 --type file -g "*.org" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(nvim {})"; \ + cd - + +# preview org files emacs +org-emacs: + cd ./org; \ + fd --max-depth 5 --type file -g "*.org" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(emacsclient -nw -a -f {})"; \ + cd - + +## search org files (view in vim) +#org-v find: +# cd ./org; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(nvim -c \"silent! /${find}\" {1})"; \ +# cd - +# +## search org files (view in emacsclient) +#org-e find: +# cd ./org; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(emacsclient -nw -a -f {})"; \ +# cd - +# +## search tips.org files (view in emacs) +#org-E find: +# cd ./org; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(emacs {} &)"; \ +# cd - +# +## search for in directory specified (view in vim, uses rg & fzf) ["find" for emacs] +#sDir-v find dir: +# cd ${dir}; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(nvim -c \"silent! /${find}\" {1})"; \ +# cd - +# +## search for in directory specified (view in emacs, uses rg & fzf) ["search" for emacs] +#sDir-e find dir: +# cd ${dir}; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(emacsclient -nw -a -f {})"; \ +# cd - +# +## search for in directory specified (view in emacs, uses rg & fzf) ["search" for emacs] +#sDir-E find dir: +# cd ${dir}; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(emacs {} &)"; \ +# cd - + +# show markup pod source selections +markup: + ls -1 --color=always ${SpinePOD} + ls -1 -d --color=always ${SpinePOD}/*/ + +# show markup pod source tree +markup-pod-tree: + exa -alT --git -I'.git|.dub|*_' --color=always -L5 ${SpinePOD} | less -R + +# show markup pod source tree +tree-src-search-cgi: + exa -alT --git -I'*_' --color=always -L5 ${SpineSearchCGI}/src ${SpineSearchCGI}/views | less -R + +# show markup files +markup-files: + cd ${SpinePOD}; \ + find . -type f -iname "*sst"; \ + cd -; \ + echo ${SpinePOD} +# find ${SpinePOD}/. -type f -iname "*sst" + +# preview markup files vim +markup-files-vim: + cd ${SpinePOD}; \ + fd --max-depth 5 --type file -g "*.ss?" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(nvim {})"; \ + cd - + +# preview markup files emacs +markup-files-emacs: + cd ${SpinePOD}; \ + fd --max-depth 5 --type file -g "*.ss?" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(emacsclient -nw -a -f {})"; \ + cd - + +# markup samples list +markup-sample: markup-pod-sample + +# markup samples list +markup-pod-sample: + find data/pod -name pod.manifest | cut -f 1-3 -d / | sort + +# markup samples pod manifests and sst files +markup-samples: markup-pod-samples markup-file-samples + +# markup samples pod manifests +markup-pod-samples: + echo "${SpinePOD}"; \ + find ${SpinePOD} -name pod.manifest | sort + +#find ${SpinePOD} -name pod.manifest | sed -E 's:.+?(([/][^/]+){2})$:\1:' + +# markup samples sst files +markup-file-samples: + echo "${SpinePOD}"; \ + find ${SpinePOD} -name *.ss[tm] | sort + +# markup_dir_samples: +# find data/sisudir/media/text -name *.ss[tm] | sort + +# version_tag: +# echo "DRV=0.11.3; git tag -f doc-reform_v$$\{DRV} -m\"doc-reform $$\{DRV}\" HEAD" && \ +# echo "git tag -f doc-reform_v0.11.3 -m\"doc-reform spine-0.11.3\" HEAD" + +# archive spine output (www) +spineWWWarchive: + cd /srv/www ; \ + rm spine_output.${Date}.tar.bz2 ; \ + sudo tar --exclude='./spine/latex' --exclude='./spine/pod' --exclude='./spine/*_' -cjf spine_output.${Date}.tar.bz2 ./spine ; \ + cd - + +# rsync archived spine output to Linode +spineWWWrsyncLinode: + rsync -v /srv/www/spine_output.${Date}.tar.bz2 linode:./stage/. ; \ + rsync -v /var/www/sqlite/spine.search.db linode:./stage/. ; \ + echo "tar -xf ../spine_output.${Date}.tar.bz2" + +# get project external dependencies +depends_get: + dub upgrade; \ + cd ${gwd} && \ + echo "${dirs_loc}" && \ + for dir in ${dirs_loc}; do \ + if [[ -d ${dir} ]]; then \ + echo ${gwd}/${dir} && \ + if [[ "imageformats" == ${dir} ]]; then \ + echo ${gwd}/${dir} && \ + rm -rvf ${gwd}/${dir} && \ + git clone --depth=1 https://github.com/tjhann/${dir} && \ + cd ${dir} && \ + echo $$PWD && \ + echo "${dir} `git rev-parse HEAD | cut -c 1-8`" > ../${dir}.meta && \ + echo "https://github.com/tjhann/${dir}" >> ../${dir}.meta && \ + echo "Boost Software License 1.0 (BSL-1.0)" >> ../${dir}.meta && \ + cd ${gwd} && \ + rm -rf ${gwd}/${dir}/.git; \ + elif [[ "d2sqlite3" == ${dir} || "D-YAML" == ${dir} || "tinyendian" == ${dir} ]]; then \ + echo ${gwd}/${dir} && \ + rm -rvf ${gwd}/${dir} && \ + git clone --depth=1 https://github.com/dlang-community/${dir} && \ + cd ${gwd}/${dir} && \ + echo "${dir} `git rev-parse HEAD | cut -c 1-8`" > ../${dir}.meta && \ + echo "https://github.com/dlang-community/${dir}" >> ../${dir}.meta && \ + echo "Boost Software License 1.0 (BSL-1.0)" >> ../${dir}.meta && \ + cd ${gwd} && \ + rm -rf ${gwd}/${dir}/.git; \ + fi; \ + fi; \ + done; \ + cd ${hwd} + +# get and set project external dependencies +depends_set: depends_get + dub describe | sed 's~$(shell echo `pwd | sed 's_/_\\/_g'`)~.~g' > dub_describe.json + +# markup_samples: +# find data/pod -name pod.manifest | cut -f 1-3 -d / | sort; \ +# find data/sisudir/media/text -name *.ss[tm] | sort +# +# markup_pod_samples: +# find data/pod -name pod.manifest | cut -f 1-3 -d / | sort +# +# markup_dir_samples: +# find data/sisudir/media/text -name *.ss[tm] | sort +# +version_tag: + echo "DRV=0.11.3; git tag -f doc-reform_v$$\{DRV} -m\"doc-reform $$\{DRV}\" HEAD" && \ + echo "git tag -f doc-reform_v0.11.3 -m\"doc-reform spine-0.11.3\" HEAD" + +changelog_: + git log --pretty=format:'---%+s %+as %ae%+h%d%+b' --no-merges | sed "/^\\s*$$/d" | sed "s/^---$$//" | sed "s/^\(\*\)\+/-/" | sed "s/ \+$$//" > CHANGELOG_ + +# git changelog for project +changelog: + git log --pretty=format:'---%+s %+as %ae%+h%d%+b' --no-merges | sed "/^\\s*$$/d" | sed "s/^---$$//" | sed "s/^\(\*\)\+/-/" | sed "s/ \+$$//" | sed "s/ \+$//" > CHANGELOG_ + +#gitZip: +# git archive -v --format=tar --prefix=`echo spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)`/ HEAD | gzip > ./tarballGitHEAD/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz && \ +# echo "to unzip: tar -xzf spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz" +# +## git archive project, produce current state .tar.gz +#gitArchive: +# git archive -v --format=tar --prefix=spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)/ HEAD | gzip > ./tarballGitHEAD/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz && \ +# echo "to unzip: tar -xzf spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz" +# +## git archive project, produce current state .tar.gz +## gitArchive: +## git archive -v --format=tar --prefix="spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}/" HEAD | gzip > ./tarballGitHEAD/spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz && \ +## echo "to unzip: tar -xzf spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz" + +# remove test tarball dir +nixGitHEADtarballClean: + if [ -d "./tarballGitHEAD" ]; then \ + rm -rv ./tarballGitHEAD; \ + fi; + +## create test tarball +#nixGitHEADtarballTar: +# if [ ! -d "./tarballGitHEAD" ]; then \ +# mkdir ./tarballGitHEAD; \ +# fi; \ +# git archive -v --format=tar --prefix="spine-${PROG_VER_DECLARED}/" HEAD | \ +# gzip > ./tarballGitHEAD/spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz && \ +# cp -v ./tarballGitHEAD/spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz ./tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz && \ +# echo "to unzip: tar -xzf spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz"; \ +# echo "to unzip: tar -xzf spine-${PROG_VER_DECLARED}.tar.gz" +# +## check test tarball +#nixGitHEADtarballCheck: +# nix flake check file://${hwd}/tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz; \ +# nix flake lock file://${hwd}/tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz; \ +# nix flake show file://${hwd}/tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz; + +## build test tarball +#nixGitHEADtarballBuild: +# echo "nix build file://${hwd}/tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz#spine --print-build-logs" +# nix build file://${hwd}/tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz#spine --print-build-logs +# #nix build "./tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz#spine" --print-build-logs + +# clean create check & build test tarball +nixGitHEADtarball: nixGitHEADtarballClean nixGitHEADtarballTar nixGitHEADtarballCheck nixGitHEADtarballBuild + +get_depends: + hwd=$$(echo `pwd`) && \ + gwd="${hwd}/src/ext_depends" && \ + dirs=$$(echo `ls -gx ${gwd}`) && \ + license_bsl="Boost Software License 1.0 (BSL-1.0)" && \ + echo ${hwd} && \ + echo ${gwd} && \ + echo ${deps} && \ + dub upgrade; \ + cd ${gwd} && \ + for dir in ${deps}; do \ + if [ -d ${dir} ]; then \ + echo ${dir} && \ + if [ "imageformats" == ${dir} ]; then \ + echo ${dir} && \ + rm -rf ${dir} && \ + git clone --depth=1 https://github.com/tjhann/${dir} && \ + cd ${dir} && \ + echo $$PWD && \ + echo "${dir} `git rev-parse HEAD | cut -c 1-8`" > ../${dir}.meta && \ + echo "https://github.com/tjhann/${dir}" >> ../${dir}.meta && \ + echo "${license_bsl}" >> ../${dir}.meta && \ + cd ${gwd} && \ + rm -rf ${dir}/.git; \ + elif [[ "d2sqlite3" == ${dir} || "D-YAML" == ${dir} || "tinyendian" == ${dir} ]]; then \ + echo ${dir} && \ + rm -rf ${dir} && \ + git clone --depth=1 https://github.com/dlang-community/${dir} && \ + cd ${dir} && \ + echo "${dir} `git rev-parse HEAD | cut -c 1-8`" > ../${dir}.meta && \ + echo "https://github.com/dlang-community/${dir}" >> ../${dir}.meta && \ + echo "${license_bsl}" >> ../${dir}.meta && \ + cd ${gwd} && \ + rm -rf ${dir}/.git; \ + fi; \ + fi; \ + done; \ + cd ${hwd} + +set_depends: get_depends + dub describe | sed 's~$(shell echo `pwd | sed 's_/_\\/_g'`)~.~g' > dub_describe.json + +rm_flakelock: + git reset HEAD flake.lock && \ + touch flake.lock \ + git rm -f flake.lock + +flake_update: + git add .; \ + nix flake lock && \ + git reset HEAD flake.lock; \ + cp flake.lock flake.lock_ + +flake_update_move_lock: flake_update + touch flake.lock \ + git rm -f flake.lock + +set_latest: set_depends flake_update rm_flakelock + +dub_upgrade: + $(DUB) upgrade + +default: ldc + +all: dmd ldc gdc + +all_ver: dmd_ver ldc_ver gdc_ver + +all_debug: dmd_debug gdc_debug ldc_debug + +meson_clean_build_dir: + rm -r build; mkdir build + +meson_build: meson_clean_build_dir + meson --buildtype=debugoptimized build + ninja -C build + notify-send -t 0 'D meson build ldc compiled test release executable ready' 'spine' + +meson_redo: meson_clean_build_dir meson_build + +meson_project_build_clean: clean skel tangle dub_upgrade meson_build + +meson: meson_clean_build_dir dub_upgrade meson_build + +all_clean: clean tangle dmd ldc gdc + +all_ver_clean: clean tangle dmd_ver ldc_ver gdc_ver + +all_debug_ver: dmd_debug_ver gdc_debug_ver ldc_debug_ver + +all_debug_clean_ver: clean tangle dmd_debug_ver gdc_debug_ver ldc_debug_ver + +dmd: dub_upgrade + $(DUB) --compiler=dmd --config=dmd --build=release-nobounds + notify-send -t 0 'D dmd compiled test release executable ready' 'spine-dmd' + +dmd_debug: + $(DUB) --compiler=dmd --config=dmd --build=debug + +## assumes git tags with program version +#dmd_ver: dub_upgrade +# $(DUB) --compiler=dmd --config=dmd-version +# mv bin/spine-dmd-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-dmd +# notify-send -t 0 'D dmd compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-dmd' + +dmd_clean_ver: clean tangle dmd_ver + +dmd_rel: expunge skel tangle + $(DUB) --compiler=dmd --config=spine-release + +dmd_rel_tangle: tangle + $(DUB) --compiler=dmd --config=spine-dmd + +dmd_rel_expunge_tangle: expunge skel tangle dmd_rel_tangle + +dmd_debug_tangle: tangle + $(DUB) --compiler=dmd --config=spine-dmd-debug + +gdc: dub_upgrade + $(DUB) --compiler=gdc --config=gdc + notify-send -t 0 'D gdc compiled test release executable ready' 'spine-gdc' + +gdc_debug: + $(DUB) --compiler=gdc --config=gdc --build=debug + +## assumes git tags with program version +#gdc_ver: dub_upgrade +# $(DUB) --compiler=gdc --config=gdc-version +# mv bin/spine-gdc-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-gdc +# notify-send -t 0 'D gdc compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-gdc' + +gdc_clean_ver: clean tangle gdc_ver + +gdc_rel: expunge skel tangle + $(DUB) --compiler=gdc --config=spine-release + +gdc_rel_tangle: tangle + $(DUB) --compiler=gdc --config=spine-gdc + +gdc_rel_expunge_tangle: expunge skel tangle gdc_rel_tangle + +gdc_debug_tangle: tangle + $(DUB) --compiler=gdc --config=spine-gdc-debug + +ldc: dub_upgrade + $(DUB) --compiler=ldc2 --config=ldc --build=release + notify-send -t 0 'D ldc compiled test release executable ready' 'spine-ldc' + +ldc_debug: + $(DUB) --compiler=ldc2 --config=ldc --build=debug + +# assumes git tags with program version +ldc_ver: dub_upgrade + $(DUB) --compiler=ldc2 --config=ldc-version + mv bin/spine-ldc-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-ldc + notify-send -t 0 'D ldc2 compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-ldc' + +ldc_clean_ver: clean tangle ldc_ver + +ldc_rel: expunge skel tangle + $(DUB) --compiler=ldc2 --config=spine-release + +ldc_rel_tangle: tangle + $(DUB) --compiler=ldc2 --config=spine-ldc + +ldc_rel_expunge_tangle: expunge skel tangle ldc_rel_tangle + +ldc_debug_tangle: tangle + $(DUB) --compiler=ldc2 --config=spine-ldc-debug + +reinit: clean skel tangle + +skel: + mkdir -p $(PRG_BINDIR); \ + mkdir -p $(PRG_BINDIR)-archive; \ + mkdir -p build; \ + mkdir -p views; \ + mkdir -p data; \ + mkdir -p sundry/misc/util/d/cgi/search/cgi-bin/src; \ + mkdir -p sundry/misc/util/d/tools/markup_conversion; \ + mkdir -p sundry/misc/editor-syntax-etc/emacs; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/syntax; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/colors; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/ftplugin; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/rc; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/templates; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/conf; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/io_in; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/io_out; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/meta; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/share; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR); \ + mkdir -p $(PRG_BINDIR); + +init: skel + +clean: + rm -rf build; \ + rm -rf $(PRG_SRCDIR); \ + rm -rf $(PRG_DOCDIR); + +clean_bin: + rm $(PRG_BINDIR)/* + +clean_src: + rm -rf $(PRG_SRCDIR); + +clean_docs: + rm -rf $(PRG_DOCDIR) + +expunge: + rm -f dub.selections.json; \ + rm -rf build; \ + rm -rf $(PRG_SRCDIR); \ + rm -rf $(PRG_BINDIR); \ + rm -rf $(PRG_DOCDIR); + +distclean: expunge + +distclean_and_init: expunge + mkdir -p views; \ + mkdir -p sundry/misc/util/d/cgi/search/cgi-bin/src; \ + mkdir -p sundry/misc/util/d/tools/markup_conversion; \ + mkdir -p sundry/misc/editor-syntax-etc/emacs; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/syntax; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/colors; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/ftplugin; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/rc; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/templates; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR); \ + mkdir -p $(PRG_BINDIR); + +ver: + echo spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT) + +clean_tangle_build: clean tangle build + +tangle_build: tangle build + +build: $(PRG_SRCDIR)/$(PRG_SRC) + $(DC) $(DC_FLAGS) \ + $(DC_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \ + $(PRG_SRCDIR)/$(PRG_SRC) + +rebuild: $(PRG_SRCDIR)/$(PRG_SRC) $(PRG_BINDIR)/$(PRG_BIN).o clean build + +makefile_new: + make -k tangle_maker + +restart: clean tangle + +find_pods: + $(SiSU_MARKUP_SAMPLES_FIND_PODS) + +testrun_find: + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_pod \ + data/pod/sisu-manual + +testrun_find_pod_source: + $(SiSU_MARKUP_SAMPLES_PODS_FOUND) \ + ./bin/spine-ldc -v --source \ + --output-dir=tmp/program_output_pod + +testrun_find_pod_pod: + $(SiSU_MARKUP_SAMPLES_PODS_FOUND) \ + ./bin/spine-ldc -v --pod \ + --output-dir=tmp/program_output_pod + +testrun_find_pod_html: + $(SiSU_MARKUP_SAMPLES_PODS_FOUND) \ + ./bin/spine-ldc -v --html \ + --output-dir=tmp/program_output_pod + +testrun_find_pod_epub: + $(SiSU_MARKUP_SAMPLES_PODS_FOUND) \ + ./bin/spine-ldc -v --epub \ + --output-dir=tmp/program_output_pod + +testrun_find_pod_all: + $(SiSU_MARKUP_SAMPLES_PODS_FOUND) \ + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_pod + +testrun_paths: + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_pod \ + data/pod/sisu-manual + +testrun_paths_pod_source: + ./bin/spine-ldc -v --source \ + --output-dir=tmp/program_output_pod \ + ./markup/pod/* + +testrun_paths_pod_pod: + ./bin/spine-ldc -v --pod \ + --output-dir=tmp/program_output_pod \ + ./markup/pod/* + +testrun_paths_pod_html: + ./bin/spine-ldc -v --html \ + --output-dir=tmp/program_output_pod \ + ./markup/pod/* + +testrun_paths_pod_epub: + ./bin/spine-ldc -v --epub \ + --output-dir=tmp/program_output_pod \ + ./markup/pod/* + +testrun_paths_pod_all: + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_pod \ + ./markup/pod/* + +testrun_find_dir_source: + $(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \ + ./bin/spine-ldc -v --source \ + --output-dir=tmp/program_output_dir + +testrun_find_dir_pod: + $(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \ + ./bin/spine-ldc -v --pod \ + --output-dir=tmp/program_output_dir + +testrun_find_dir_html: + $(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \ + ./bin/spine-ldc -v --html \ + --output-dir=tmp/program_output_dir + +testrun_find_dir_epub: + $(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \ + ./bin/spine-ldc -v --epub \ + --output-dir=tmp/program_output_dir + +testrun_find_dir_all: + $(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \ + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_dir + +testrun_filelist_dir_source: + ./bin/spine-ldc -v --source \ + --output-dir=tmp/program_output_dir \ + $(SiSU_MARKUP_SAMPLES_DIR) + +testrun_filelist_dir_pod: + ./bin/spine-ldc -v --pod \ + --output-dir=tmp/program_output_dir \ + $(SiSU_MARKUP_SAMPLES_DIR) + +testrun_filelist_dir_html: + ./bin/spine-ldc -v --html \ + --output-dir=tmp/program_output_dir \ + $(SiSU_MARKUP_SAMPLES_DIR) + +testrun_filelist_dir_epub: + ./bin/spine-ldc -v --epub \ + --output-dir=tmp/program_output_dir \ + $(SiSU_MARKUP_SAMPLES_DIR) + +testrun_filelist_dir_all: + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_dir \ + $(SiSU_MARKUP_SAMPLES_DIR) + +tangle: skel + for f in $(ORGFILELIST); do \ + ORGFILES="$$ORGFILES \"$$f\""; \ + done; \ + emacs --batch -Q -q \ + --eval "(progn \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP)\")) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG)\" t)) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG_CONTRIB)\" t)) \ + (require 'org)(require 'ob)(require 'ob-tangle) \ + (mapc (lambda (file) \ + (find-file (expand-file-name file \"$(ORGDIR)\")) \ + (setq-local org-src-preserve-indentation t) \ + (org-babel-tangle) \ + (kill-buffer)) '($$ORGFILES)))" 2>&1 + +tangle_maker: + for f in $(ORGFILELIST); do \ + ORGFILES="\"org/dr_build_scaffold.org\""; \ + done; \ + emacs --batch -Q -q \ + --eval "(progn \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP)\")) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG)\" t)) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG_CONTRIB)\" t)) \ + (require 'org)(require 'ob)(require 'ob-tangle) \ + (mapc (lambda (file) \ + (find-file (expand-file-name file \".\")) \ + (setq-local org-src-preserve-indentation t) \ + (org-babel-tangle) \ + (kill-buffer)) '($$ORGFILES)))" 2>&1 + +lorri_shell: + lorri shell + +# nix-shell +nix-shell: + nix-shell -I .envrc + +nix-shell-pure: + nix-shell -I .envrc --pure + +# nix-shell (with local tools, presumably latest dlang compiler & build tools (ldc & dub)) +nix-shell-updated: + nix-shell -I nixpkgs=/nixpkgs-ra/nixpkgs --pure + +# shell.nix (with shebang) +shell: + shell.nix + +# nix-build spine +nix-build: + nix-build default.nix && ./result/bin/spine -v + +# nix-build spine (with local tools, presumably latest dlang compiler & build tools (ldc & dub)) +nix-build-use-tools-new: + nix-build -I .envrc + +# tangle-build +tangle-build: org-tangle nix-build + +# build-run +build-run: nix-build output-samples + +# tangle-build-run +tangle-build-run: org-tangle nix-build output-samples + +# nix-build spine search +nix-build-search: + cd ./sundry/spine_search_cgi; \ + nix-build \ + cd - + +_flake-lock-reset: + git reset HEAD flake.lock + +_flake-show-name: + nix search --json 2>/dev/null |jq; + +_flake-show-package: + nix flake show; + +_flake-show-derivation: + nix show-derivation |jq; + +nix-develop: + nix develop -f default.nix -I nixpkgs=/nixpkgs-ra/nixpkgs + +# nix flake show +flake-show: _flake-show-package _flake-show-name _flake-show-derivation + +# nix-build flake spine +flake-build: _flake-show-name + nix build --print-build-logs + +# nix-build flake spine +flake-reset-build: _flake-lock-reset _flake-show-name + nix build --print-build-logs + +# nix-build flake spine debug +flake-build-debug: + nix build --debug + +# nix-build spine (with local tools, presumably latest dlang compiler & build tools (ldc & dub)) +flake-build-use-tools-new: + nix build --print-build-logs -I nixpkgs=/nixpkgs-ra/nixpkgs + +# tangle-build-flake +flake-tangle-build: org-tangle flake-build + +# build-flake-run +flake-build-run: flake-build output-samples + +# tangle-build-run +flake-tangle-build-run: org-tangle flake-build output-samples + +# nix-build spine search +flake-build-search: + cd ./sundry/spine_search_cgi; \ + nix build --print-build-logs \ + cd - + +gitsnapshot: distclean tangle + git commit -a + +.PHONY : all build rebuild debug release \ + distclean init \ + tangle gitsnapshot diff --git a/org/config_git.org b/org/config_git.org new file mode 100644 index 0000000..e042f2d --- /dev/null +++ b/org/config_git.org @@ -0,0 +1,104 @@ +-*- mode: org -*- +#+TITLE: configuration git +#+DESCRIPTION: documents - structuring, various output representations & search +#+FILETAGS: :spine:hub: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2022 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no +#+PROPERTY: header-args+ :mkdirp yes +#+OPTIONS: H:3 num:nil toc:t \n:t ::t |:t ^:nil -:t f:t *:t + +* spine markup samples +** .gitignore :gitignore: + +#+HEADER: :tangle "../.gitignore" +#+BEGIN_SRC sh +# git ls-files --others --exclude-from=.git/info/exclude +# git check-ignore -v flake.lock +# git clean -ix +# find . -name "*_" | xargs rm -rf +# find . -name "*.o" | xargs rm -rf +* +!.gitignore +!.gitattributes +!nix/** +!*.nix +!flake.lock +!.envrc +!README +!COPYRIGHT +!CHANGELOG +!makefile +!version.txt +!configuration.txt +!*.json +!*.sdl +!tangle +!*.org +!org +!org/*.org +!.dr +!.dr/* +!markup/ +!markup/pod/ +!markup/pod/*/ +!markup/pod/*/pod.manifest +!markup/pod/*/conf/ +!markup/pod/*/conf/sisu_document_make +!markup/pod/*/media/ +!markup/pod/*/media/text/ +!markup/pod/*/media/text/*/ +!markup/pod/*/media/text/*/*.sst +!markup/pod/*/media/text/*/*.ssm +!markup/pod/*/media/text/*/*.ssi +!markup/pod/*/media/image/ +!markup/pod/*/media/image/*.png +!markup/pod/*/media/image/*.jpg +!markup/pod/*/media/image/*.PNG +!markup/pod/*/media/image/*.JPG +!markup/pod/*/tools/ +!markup/pod/*/tools/po4a/ +!markup/pod/*/tools/po4a/pot/ +!markup/pod/*/tools/po4a/pot/*.sst.pot +!markup/pod/*/tools/po4a/pot/*.ssm.pot +!markup/pod/*/tools/po4a/pot/*.ssi.pot +!markup/pod/*/tools/po4a/po/ +!markup/pod/*/tools/po4a/po/*/ +!markup/pod/*/tools/po4a/po/*/*.sst.po +!markup/pod/*/tools/po4a/po/*/*.ssm.po +!markup/pod/*/tools/po4a/po/*/*.ssi.po +.dub/** +**/.dub/** +tmp/** +*_.org +*_.nix +*_.d +*_.txt +*_ +*.swp +*~ +\#* +*.\#* +!.envrc-local_ +#!*/ +#\#* +#*.\#* +#.reggae/** +#+END_SRC + +** .gitattributes :gitattributes: + +#+HEADER: :tangle "../.gitattributes" +#+BEGIN_SRC sh +/org export-ignore +.gitattributes export-ignore +.gitignore export-ignore +tangle export-ignore +#+END_SRC diff --git a/org/config_make.org b/org/config_make.org new file mode 100644 index 0000000..b603bfe --- /dev/null +++ b/org/config_make.org @@ -0,0 +1,927 @@ +-*- mode: org -*- +#+TITLE: spine (doc_reform) (project) makefile +#+DESCRIPTION: makefile for spine +#+FILETAGS: :spine:build:tools: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2022 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no +#+PROPERTY: header-args+ :mkdirp yes + +- [[./doc-reform.org][doc-reform.org]] [[../org/][org/]] + +#+HEADER: :tangle ../makefile +#+HEADER: :noweb yes +#+BEGIN_SRC makefile +PROG_VER_GIT :=$(shell echo `git describe --long --tags | sed -e "s/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g"`) +#PROG_VER_DECLARED :=$(shell echo `cat ./views/version.txt | grep --color=never "enum" | sed 's/.\+(\([0-9]\+\),[ \t]\+\([0-9]\+\),[ \t]\+\([0-9]\+\)[ \t]*).\+/\1.\2.\3/g'`) +DUB=dub +DUB_FLAGS=-v --force --compiler= +PRG_NAME=doc-reform +PRG_NICKAME=spine +PRG_NAME_DIR=$(shell echo `echo $(PRG_NAME) | sed -e "s/-/_/g"`) +PRG_SRC=$(PRG_NAME).d +PRG_SRCDIR=./src +PRG_BIN=$(PRG_NAME) +PRG_BINDIR=./bin +PRG_DOCDIR=./docs +EMACSLISP=/usr/share/emacs/site-lisp +ORG_VER_AVAILABLE=$(shell echo `ls -d ~/.emacs.d/elpa/org-???????? | cut -d '-' -f2`) +EMACSLISP_ORG=~/.emacs.d/elpa/org-$($(shell echo $(ORG_VER_AVAILABLE))) +ORG_CONTRIB_VER_AVAILABLE=$(shell echo `ls -d ~/.emacs.d/elpa/org-plus-contrib-???????? | cut -d '-' -f2`) +EMACSLISP_ORG_CONTRIB=~/.emacs.d/elpa/org-plus-contrib-$($(shell echo $(ORG_CONTRIB_VER_AVAILABLE))) +ORGFILELIST=$(shell echo `ls -1 org/*.org`) +ORGFILES="" +ORGDIR :=$(shell echo `pwd`) +SiSU_MARKUP_SAMPLES_FIND_PODS= \ +find data/pod -maxdepth 2 -name pod.manifest | cut -f 1-3 -d / | sort + +SiSU_MARKUP_SAMPLES_PODS_FOUND= \ +$(SiSU_MARKUP_SAMPLES_FIND_PODS) | xargs + +# SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND = \ +# find data/sisudir/media/text -name *.ss[tm] | sort | xargs +# +Date := `date "+%Y%m%d"` +SpineBIN := "${SpineBIN}" # './result/bin' +SpineOUT := "${SpineOUT}" # '/srv/www/spine' +SpinePOD := "${SpinePOD}" # '~/grotto/repo/git.repo/projects/doc-reform/data/markup/spine-samples/markup/pod' +SpineSearchActionLocal := 'http://localhost/spine_search' +SpineSearchActionRemote := 'https://sisudoc.org/spine_search' +SpineCGIform := 'spine_search' +SpineSQLdb := 'spine.search.db' +hwd := `pwd` +gwd := `pwd` + "/src/ext_depends" +deps := "`ls -gx './src/ext_depends'`" +dirs_loc := "`ls -gx '.'`" +#dirs := "`ls -gx ${gwd}`" + +commands: + rg --color=always -B1 "^[a-z]\w+:" makefile | less + +cmd: + rg --color=always -B1 "^[a-z]\w+:" makefile | page + +# tangle org files +org-tangle: + cd ./org; \ + org-tangle *.org; \ + cd - + +# epub output +out-epub: + ${SpineBIN}/spine -v \ + --epub --output=${SpineOUT} ${SpinePOD}/* + +# html output with local search links +out-html: + ${SpineBIN}/spine -v --generated-by \ + --curate \ + --html --html-link-search --html-link-curate --cgi-url-action="${SpineSearchActionLocal}" \ + --output=${SpineOUT} ${SpinePOD}/* + +# latex output +out-latex: + ${SpineBIN}/spine -v \ + --latex \ + --output=${SpineOUT} ${SpinePOD}/* + +# odf output +out-odf: + ${SpineBIN}/spine -v \ + --odf \ + --output=${SpineOUT} ${SpinePOD}/* + +# sqlite output +out-sqlite: + ${SpineBIN}/spine -v \ + --sqlite-update --sqlite-db-filename="${SpineSQLdb}" \ + --output=${SpineOUT} ${SpinePOD}/* + +# generate markup sample output with local search links +output-samples-local: + ${SpineBIN}/spine -v \ + --latex --latex-init \ + --epub \ + --html --html-link-search --html-link-pdf --html-link-curate --html-link-markup \ + --cgi-sqlite-search-filename="${SpineCGIform}" --cgi-url-action="${SpineSearchActionLocal}" \ + --curate \ + --sqlite-update --sqlite-db-filename="${SpineSQLdb}" \ + --output=${SpineOUT} ${SpinePOD}/* + +# generate markup sample output with remote search links +output-samples-remote: + ${SpineBIN}/spine -v \ + --generated-by \ + --latex --latex-init \ + --epub \ + --html --html-link-search --html-link-pdf --html-link-curate \ + --cgi-sqlite-search-filename="${SpineCGIform}" --cgi-url-action="${SpineSearchActionRemote}" \ + --curate \ + --sqlite-update --sqlite-db-filename="${SpineSQLdb}" \ + --output=${SpineOUT} ${SpinePOD}/* + +# generate markup sample output with local search links +output-samples: output-samples-local + +# nix build (remote) run +generate-output-remote: nix-build output-samples-remote + +# nix build (local) run +generate-output-local: nix-build output-samples-local + +# preview org files vim +files-vim: + fd --max-depth 6 --type file -g "*" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(nvim {})"; \ + +# preview org files emacs +files-emacs: + fd --max-depth 6 --type file -g "*" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(emacsclient -nw -a -f {})"; \ + +# preview org files vim +org-vim: + cd ./org; \ + fd --max-depth 5 --type file -g "*.org" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(nvim {})"; \ + cd - + +# preview org files emacs +org-emacs: + cd ./org; \ + fd --max-depth 5 --type file -g "*.org" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(emacsclient -nw -a -f {})"; \ + cd - + +## search org files (view in vim) +#org-v find: +# cd ./org; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(nvim -c \"silent! /${find}\" {1})"; \ +# cd - +# +## search org files (view in emacsclient) +#org-e find: +# cd ./org; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(emacsclient -nw -a -f {})"; \ +# cd - +# +## search tips.org files (view in emacs) +#org-E find: +# cd ./org; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(emacs {} &)"; \ +# cd - +# +## search for in directory specified (view in vim, uses rg & fzf) ["find" for emacs] +#sDir-v find dir: +# cd ${dir}; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(nvim -c \"silent! /${find}\" {1})"; \ +# cd - +# +## search for in directory specified (view in emacs, uses rg & fzf) ["search" for emacs] +#sDir-e find dir: +# cd ${dir}; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(emacsclient -nw -a -f {})"; \ +# cd - +# +## search for in directory specified (view in emacs, uses rg & fzf) ["search" for emacs] +#sDir-E find dir: +# cd ${dir}; \ +# rg --files-with-matches --no-messages "${find}" | \ +# fzf --multi --ansi --print0 \ +# --preview-window=right:66% \ +# --preview="rg --pretty --after-context 3 --before-context 2 -- \"${find}\" {}" \ +# --bind="enter:execute(emacs {} &)"; \ +# cd - + +# show markup pod source selections +markup: + ls -1 --color=always ${SpinePOD} + ls -1 -d --color=always ${SpinePOD}/*/ + +# show markup pod source tree +markup-pod-tree: + exa -alT --git -I'.git|.dub|*_' --color=always -L5 ${SpinePOD} | less -R + +# show markup pod source tree +tree-src-search-cgi: + exa -alT --git -I'*_' --color=always -L5 ${SpineSearchCGI}/src ${SpineSearchCGI}/views | less -R + +# show markup files +markup-files: + cd ${SpinePOD}; \ + find . -type f -iname "*sst"; \ + cd -; \ + echo ${SpinePOD} +# find ${SpinePOD}/. -type f -iname "*sst" + +# preview markup files vim +markup-files-vim: + cd ${SpinePOD}; \ + fd --max-depth 5 --type file -g "*.ss?" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(nvim {})"; \ + cd - + +# preview markup files emacs +markup-files-emacs: + cd ${SpinePOD}; \ + fd --max-depth 5 --type file -g "*.ss?" | sort \ + | fzf \ + --preview='bat --color "always" {}' \ + --preview-window=right:66% \ + --bind="enter:execute(emacsclient -nw -a -f {})"; \ + cd - + +# markup samples list +markup-sample: markup-pod-sample + +# markup samples list +markup-pod-sample: + find data/pod -name pod.manifest | cut -f 1-3 -d / | sort + +# markup samples pod manifests and sst files +markup-samples: markup-pod-samples markup-file-samples + +# markup samples pod manifests +markup-pod-samples: + echo "${SpinePOD}"; \ + find ${SpinePOD} -name pod.manifest | sort + +#find ${SpinePOD} -name pod.manifest | sed -E 's:.+?(([/][^/]+){2})$:\1:' + +# markup samples sst files +markup-file-samples: + echo "${SpinePOD}"; \ + find ${SpinePOD} -name *.ss[tm] | sort + +# markup_dir_samples: +# find data/sisudir/media/text -name *.ss[tm] | sort + +# version_tag: +# echo "DRV=0.11.3; git tag -f doc-reform_v$$\{DRV} -m\"doc-reform $$\{DRV}\" HEAD" && \ +# echo "git tag -f doc-reform_v0.11.3 -m\"doc-reform spine-0.11.3\" HEAD" + +# archive spine output (www) +spineWWWarchive: + cd /srv/www ; \ + rm spine_output.${Date}.tar.bz2 ; \ + sudo tar --exclude='./spine/latex' --exclude='./spine/pod' --exclude='./spine/*_' -cjf spine_output.${Date}.tar.bz2 ./spine ; \ + cd - + +# rsync archived spine output to Linode +spineWWWrsyncLinode: + rsync -v /srv/www/spine_output.${Date}.tar.bz2 linode:./stage/. ; \ + rsync -v /var/www/sqlite/spine.search.db linode:./stage/. ; \ + echo "tar -xf ../spine_output.${Date}.tar.bz2" + +# get project external dependencies +depends_get: + dub upgrade; \ + cd ${gwd} && \ + echo "${dirs_loc}" && \ + for dir in ${dirs_loc}; do \ + if [[ -d ${dir} ]]; then \ + echo ${gwd}/${dir} && \ + if [[ "imageformats" == ${dir} ]]; then \ + echo ${gwd}/${dir} && \ + rm -rvf ${gwd}/${dir} && \ + git clone --depth=1 https://github.com/tjhann/${dir} && \ + cd ${dir} && \ + echo $$PWD && \ + echo "${dir} `git rev-parse HEAD | cut -c 1-8`" > ../${dir}.meta && \ + echo "https://github.com/tjhann/${dir}" >> ../${dir}.meta && \ + echo "Boost Software License 1.0 (BSL-1.0)" >> ../${dir}.meta && \ + cd ${gwd} && \ + rm -rf ${gwd}/${dir}/.git; \ + elif [[ "d2sqlite3" == ${dir} || "D-YAML" == ${dir} || "tinyendian" == ${dir} ]]; then \ + echo ${gwd}/${dir} && \ + rm -rvf ${gwd}/${dir} && \ + git clone --depth=1 https://github.com/dlang-community/${dir} && \ + cd ${gwd}/${dir} && \ + echo "${dir} `git rev-parse HEAD | cut -c 1-8`" > ../${dir}.meta && \ + echo "https://github.com/dlang-community/${dir}" >> ../${dir}.meta && \ + echo "Boost Software License 1.0 (BSL-1.0)" >> ../${dir}.meta && \ + cd ${gwd} && \ + rm -rf ${gwd}/${dir}/.git; \ + fi; \ + fi; \ + done; \ + cd ${hwd} + +# get and set project external dependencies +depends_set: depends_get + dub describe | sed 's~$(shell echo `pwd | sed 's_/_\\/_g'`)~.~g' > dub_describe.json + +# markup_samples: +# find data/pod -name pod.manifest | cut -f 1-3 -d / | sort; \ +# find data/sisudir/media/text -name *.ss[tm] | sort +# +# markup_pod_samples: +# find data/pod -name pod.manifest | cut -f 1-3 -d / | sort +# +# markup_dir_samples: +# find data/sisudir/media/text -name *.ss[tm] | sort +# +version_tag: + echo "DRV=0.11.3; git tag -f doc-reform_v$$\{DRV} -m\"doc-reform $$\{DRV}\" HEAD" && \ + echo "git tag -f doc-reform_v0.11.3 -m\"doc-reform spine-0.11.3\" HEAD" + +changelog_: + git log --pretty=format:'---%+s %+as %ae%+h%d%+b' --no-merges | sed "/^\\s*$$/d" | sed "s/^---$$//" | sed "s/^\(\*\)\+/-/" | sed "s/ \+$$//" > CHANGELOG_ + +# git changelog for project +changelog: + git log --pretty=format:'---%+s %+as %ae%+h%d%+b' --no-merges | sed "/^\\s*$$/d" | sed "s/^---$$//" | sed "s/^\(\*\)\+/-/" | sed "s/ \+$$//" | sed "s/ \+$//" > CHANGELOG_ + +#gitZip: +# git archive -v --format=tar --prefix=`echo spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)`/ HEAD | gzip > ./tarballGitHEAD/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz && \ +# echo "to unzip: tar -xzf spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz" +# +## git archive project, produce current state .tar.gz +#gitArchive: +# git archive -v --format=tar --prefix=spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)/ HEAD | gzip > ./tarballGitHEAD/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz && \ +# echo "to unzip: tar -xzf spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz" +# +## git archive project, produce current state .tar.gz +## gitArchive: +## git archive -v --format=tar --prefix="spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}/" HEAD | gzip > ./tarballGitHEAD/spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz && \ +## echo "to unzip: tar -xzf spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz" + +# remove test tarball dir +nixGitHEADtarballClean: + if [ -d "./tarballGitHEAD" ]; then \ + rm -rv ./tarballGitHEAD; \ + fi; + +## create test tarball +#nixGitHEADtarballTar: +# if [ ! -d "./tarballGitHEAD" ]; then \ +# mkdir ./tarballGitHEAD; \ +# fi; \ +# git archive -v --format=tar --prefix="spine-${PROG_VER_DECLARED}/" HEAD | \ +# gzip > ./tarballGitHEAD/spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz && \ +# cp -v ./tarballGitHEAD/spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz ./tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz && \ +# echo "to unzip: tar -xzf spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz"; \ +# echo "to unzip: tar -xzf spine-${PROG_VER_DECLARED}.tar.gz" +# +## check test tarball +#nixGitHEADtarballCheck: +# nix flake check file://${hwd}/tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz; \ +# nix flake lock file://${hwd}/tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz; \ +# nix flake show file://${hwd}/tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz; + +## build test tarball +#nixGitHEADtarballBuild: +# echo "nix build file://${hwd}/tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz#spine --print-build-logs" +# nix build file://${hwd}/tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz#spine --print-build-logs +# #nix build "./tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz#spine" --print-build-logs + +# clean create check & build test tarball +nixGitHEADtarball: nixGitHEADtarballClean nixGitHEADtarballTar nixGitHEADtarballCheck nixGitHEADtarballBuild + +get_depends: + hwd=$$(echo `pwd`) && \ + gwd="${hwd}/src/ext_depends" && \ + dirs=$$(echo `ls -gx ${gwd}`) && \ + license_bsl="Boost Software License 1.0 (BSL-1.0)" && \ + echo ${hwd} && \ + echo ${gwd} && \ + echo ${deps} && \ + dub upgrade; \ + cd ${gwd} && \ + for dir in ${deps}; do \ + if [ -d ${dir} ]; then \ + echo ${dir} && \ + if [ "imageformats" == ${dir} ]; then \ + echo ${dir} && \ + rm -rf ${dir} && \ + git clone --depth=1 https://github.com/tjhann/${dir} && \ + cd ${dir} && \ + echo $$PWD && \ + echo "${dir} `git rev-parse HEAD | cut -c 1-8`" > ../${dir}.meta && \ + echo "https://github.com/tjhann/${dir}" >> ../${dir}.meta && \ + echo "${license_bsl}" >> ../${dir}.meta && \ + cd ${gwd} && \ + rm -rf ${dir}/.git; \ + elif [[ "d2sqlite3" == ${dir} || "D-YAML" == ${dir} || "tinyendian" == ${dir} ]]; then \ + echo ${dir} && \ + rm -rf ${dir} && \ + git clone --depth=1 https://github.com/dlang-community/${dir} && \ + cd ${dir} && \ + echo "${dir} `git rev-parse HEAD | cut -c 1-8`" > ../${dir}.meta && \ + echo "https://github.com/dlang-community/${dir}" >> ../${dir}.meta && \ + echo "${license_bsl}" >> ../${dir}.meta && \ + cd ${gwd} && \ + rm -rf ${dir}/.git; \ + fi; \ + fi; \ + done; \ + cd ${hwd} + +set_depends: get_depends + dub describe | sed 's~$(shell echo `pwd | sed 's_/_\\/_g'`)~.~g' > dub_describe.json + +rm_flakelock: + git reset HEAD flake.lock && \ + touch flake.lock \ + git rm -f flake.lock + +flake_update: + git add .; \ + nix flake lock && \ + git reset HEAD flake.lock; \ + cp flake.lock flake.lock_ + +flake_update_move_lock: flake_update + touch flake.lock \ + git rm -f flake.lock + +set_latest: set_depends flake_update rm_flakelock + +dub_upgrade: + $(DUB) upgrade + +default: ldc + +all: dmd ldc gdc + +all_ver: dmd_ver ldc_ver gdc_ver + +all_debug: dmd_debug gdc_debug ldc_debug + +meson_clean_build_dir: + rm -r build; mkdir build + +meson_build: meson_clean_build_dir + meson --buildtype=debugoptimized build + ninja -C build + notify-send -t 0 'D meson build ldc compiled test release executable ready' 'spine' + +meson_redo: meson_clean_build_dir meson_build + +meson_project_build_clean: clean skel tangle dub_upgrade meson_build + +meson: meson_clean_build_dir dub_upgrade meson_build + +all_clean: clean tangle dmd ldc gdc + +all_ver_clean: clean tangle dmd_ver ldc_ver gdc_ver + +all_debug_ver: dmd_debug_ver gdc_debug_ver ldc_debug_ver + +all_debug_clean_ver: clean tangle dmd_debug_ver gdc_debug_ver ldc_debug_ver + +dmd: dub_upgrade + $(DUB) --compiler=dmd --config=dmd --build=release-nobounds + notify-send -t 0 'D dmd compiled test release executable ready' 'spine-dmd' + +dmd_debug: + $(DUB) --compiler=dmd --config=dmd --build=debug + +## assumes git tags with program version +#dmd_ver: dub_upgrade +# $(DUB) --compiler=dmd --config=dmd-version +# mv bin/spine-dmd-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-dmd +# notify-send -t 0 'D dmd compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-dmd' + +dmd_clean_ver: clean tangle dmd_ver + +dmd_rel: expunge skel tangle + $(DUB) --compiler=dmd --config=spine-release + +dmd_rel_tangle: tangle + $(DUB) --compiler=dmd --config=spine-dmd + +dmd_rel_expunge_tangle: expunge skel tangle dmd_rel_tangle + +dmd_debug_tangle: tangle + $(DUB) --compiler=dmd --config=spine-dmd-debug + +gdc: dub_upgrade + $(DUB) --compiler=gdc --config=gdc + notify-send -t 0 'D gdc compiled test release executable ready' 'spine-gdc' + +gdc_debug: + $(DUB) --compiler=gdc --config=gdc --build=debug + +## assumes git tags with program version +#gdc_ver: dub_upgrade +# $(DUB) --compiler=gdc --config=gdc-version +# mv bin/spine-gdc-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-gdc +# notify-send -t 0 'D gdc compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-gdc' + +gdc_clean_ver: clean tangle gdc_ver + +gdc_rel: expunge skel tangle + $(DUB) --compiler=gdc --config=spine-release + +gdc_rel_tangle: tangle + $(DUB) --compiler=gdc --config=spine-gdc + +gdc_rel_expunge_tangle: expunge skel tangle gdc_rel_tangle + +gdc_debug_tangle: tangle + $(DUB) --compiler=gdc --config=spine-gdc-debug + +ldc: dub_upgrade + $(DUB) --compiler=ldc2 --config=ldc --build=release + notify-send -t 0 'D ldc compiled test release executable ready' 'spine-ldc' + +ldc_debug: + $(DUB) --compiler=ldc2 --config=ldc --build=debug + +# assumes git tags with program version +ldc_ver: dub_upgrade + $(DUB) --compiler=ldc2 --config=ldc-version + mv bin/spine-ldc-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-ldc + notify-send -t 0 'D ldc2 compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-ldc' + +ldc_clean_ver: clean tangle ldc_ver + +ldc_rel: expunge skel tangle + $(DUB) --compiler=ldc2 --config=spine-release + +ldc_rel_tangle: tangle + $(DUB) --compiler=ldc2 --config=spine-ldc + +ldc_rel_expunge_tangle: expunge skel tangle ldc_rel_tangle + +ldc_debug_tangle: tangle + $(DUB) --compiler=ldc2 --config=spine-ldc-debug + +reinit: clean skel tangle + +skel: + mkdir -p $(PRG_BINDIR); \ + mkdir -p $(PRG_BINDIR)-archive; \ + mkdir -p build; \ + mkdir -p views; \ + mkdir -p data; \ + mkdir -p sundry/misc/util/d/cgi/search/cgi-bin/src; \ + mkdir -p sundry/misc/util/d/tools/markup_conversion; \ + mkdir -p sundry/misc/editor-syntax-etc/emacs; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/syntax; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/colors; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/ftplugin; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/rc; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/templates; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/conf; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/io_in; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/io_out; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/meta; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/share; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR); \ + mkdir -p $(PRG_BINDIR); + +init: skel + +clean: + rm -rf build; \ + rm -rf $(PRG_SRCDIR); \ + rm -rf $(PRG_DOCDIR); + +clean_bin: + rm $(PRG_BINDIR)/* + +clean_src: + rm -rf $(PRG_SRCDIR); + +clean_docs: + rm -rf $(PRG_DOCDIR) + +expunge: + rm -f dub.selections.json; \ + rm -rf build; \ + rm -rf $(PRG_SRCDIR); \ + rm -rf $(PRG_BINDIR); \ + rm -rf $(PRG_DOCDIR); + +distclean: expunge + +distclean_and_init: expunge + mkdir -p views; \ + mkdir -p sundry/misc/util/d/cgi/search/cgi-bin/src; \ + mkdir -p sundry/misc/util/d/tools/markup_conversion; \ + mkdir -p sundry/misc/editor-syntax-etc/emacs; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/syntax; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/colors; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/ftplugin; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/rc; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/templates; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR); \ + mkdir -p $(PRG_BINDIR); + +ver: + echo spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT) + +clean_tangle_build: clean tangle build + +tangle_build: tangle build + +build: $(PRG_SRCDIR)/$(PRG_SRC) + $(DC) $(DC_FLAGS) \ + $(DC_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \ + $(PRG_SRCDIR)/$(PRG_SRC) + +rebuild: $(PRG_SRCDIR)/$(PRG_SRC) $(PRG_BINDIR)/$(PRG_BIN).o clean build + +makefile_new: + make -k tangle_maker + +restart: clean tangle + +find_pods: + $(SiSU_MARKUP_SAMPLES_FIND_PODS) + +testrun_find: + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_pod \ + data/pod/sisu-manual + +testrun_find_pod_source: + $(SiSU_MARKUP_SAMPLES_PODS_FOUND) \ + ./bin/spine-ldc -v --source \ + --output-dir=tmp/program_output_pod + +testrun_find_pod_pod: + $(SiSU_MARKUP_SAMPLES_PODS_FOUND) \ + ./bin/spine-ldc -v --pod \ + --output-dir=tmp/program_output_pod + +testrun_find_pod_html: + $(SiSU_MARKUP_SAMPLES_PODS_FOUND) \ + ./bin/spine-ldc -v --html \ + --output-dir=tmp/program_output_pod + +testrun_find_pod_epub: + $(SiSU_MARKUP_SAMPLES_PODS_FOUND) \ + ./bin/spine-ldc -v --epub \ + --output-dir=tmp/program_output_pod + +testrun_find_pod_all: + $(SiSU_MARKUP_SAMPLES_PODS_FOUND) \ + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_pod + +testrun_paths: + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_pod \ + data/pod/sisu-manual + +testrun_paths_pod_source: + ./bin/spine-ldc -v --source \ + --output-dir=tmp/program_output_pod \ + ./markup/pod/* + +testrun_paths_pod_pod: + ./bin/spine-ldc -v --pod \ + --output-dir=tmp/program_output_pod \ + ./markup/pod/* + +testrun_paths_pod_html: + ./bin/spine-ldc -v --html \ + --output-dir=tmp/program_output_pod \ + ./markup/pod/* + +testrun_paths_pod_epub: + ./bin/spine-ldc -v --epub \ + --output-dir=tmp/program_output_pod \ + ./markup/pod/* + +testrun_paths_pod_all: + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_pod \ + ./markup/pod/* + +testrun_find_dir_source: + $(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \ + ./bin/spine-ldc -v --source \ + --output-dir=tmp/program_output_dir + +testrun_find_dir_pod: + $(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \ + ./bin/spine-ldc -v --pod \ + --output-dir=tmp/program_output_dir + +testrun_find_dir_html: + $(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \ + ./bin/spine-ldc -v --html \ + --output-dir=tmp/program_output_dir + +testrun_find_dir_epub: + $(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \ + ./bin/spine-ldc -v --epub \ + --output-dir=tmp/program_output_dir + +testrun_find_dir_all: + $(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \ + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_dir + +testrun_filelist_dir_source: + ./bin/spine-ldc -v --source \ + --output-dir=tmp/program_output_dir \ + $(SiSU_MARKUP_SAMPLES_DIR) + +testrun_filelist_dir_pod: + ./bin/spine-ldc -v --pod \ + --output-dir=tmp/program_output_dir \ + $(SiSU_MARKUP_SAMPLES_DIR) + +testrun_filelist_dir_html: + ./bin/spine-ldc -v --html \ + --output-dir=tmp/program_output_dir \ + $(SiSU_MARKUP_SAMPLES_DIR) + +testrun_filelist_dir_epub: + ./bin/spine-ldc -v --epub \ + --output-dir=tmp/program_output_dir \ + $(SiSU_MARKUP_SAMPLES_DIR) + +testrun_filelist_dir_all: + ./bin/spine-ldc -v --source --html --epub --sqlite-discrete \ + --sqlite-create --sqlite-update \ + --output-dir=tmp/program_output_dir \ + $(SiSU_MARKUP_SAMPLES_DIR) + +tangle: skel + for f in $(ORGFILELIST); do \ + ORGFILES="$$ORGFILES \"$$f\""; \ + done; \ + emacs --batch -Q -q \ + --eval "(progn \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP)\")) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG)\" t)) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG_CONTRIB)\" t)) \ + (require 'org)(require 'ob)(require 'ob-tangle) \ + (mapc (lambda (file) \ + (find-file (expand-file-name file \"$(ORGDIR)\")) \ + (setq-local org-src-preserve-indentation t) \ + (org-babel-tangle) \ + (kill-buffer)) '($$ORGFILES)))" 2>&1 + +tangle_maker: + for f in $(ORGFILELIST); do \ + ORGFILES="\"org/dr_build_scaffold.org\""; \ + done; \ + emacs --batch -Q -q \ + --eval "(progn \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP)\")) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG)\" t)) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG_CONTRIB)\" t)) \ + (require 'org)(require 'ob)(require 'ob-tangle) \ + (mapc (lambda (file) \ + (find-file (expand-file-name file \".\")) \ + (setq-local org-src-preserve-indentation t) \ + (org-babel-tangle) \ + (kill-buffer)) '($$ORGFILES)))" 2>&1 + +lorri_shell: + lorri shell + +# nix-shell +nix-shell: + nix-shell -I .envrc + +nix-shell-pure: + nix-shell -I .envrc --pure + +# nix-shell (with local tools, presumably latest dlang compiler & build tools (ldc & dub)) +nix-shell-updated: + nix-shell -I nixpkgs=/nixpkgs-ra/nixpkgs --pure + +# shell.nix (with shebang) +shell: + shell.nix + +# nix-build spine +nix-build: + nix-build default.nix && ./result/bin/spine -v + +# nix-build spine (with local tools, presumably latest dlang compiler & build tools (ldc & dub)) +nix-build-use-tools-new: + nix-build -I .envrc + +# tangle-build +tangle-build: org-tangle nix-build + +# build-run +build-run: nix-build output-samples + +# tangle-build-run +tangle-build-run: org-tangle nix-build output-samples + +# nix-build spine search +nix-build-search: + cd ./sundry/spine_search_cgi; \ + nix-build \ + cd - + +_flake-lock-reset: + git reset HEAD flake.lock + +_flake-show-name: + nix search --json 2>/dev/null |jq; + +_flake-show-package: + nix flake show; + +_flake-show-derivation: + nix show-derivation |jq; + +nix-develop: + nix develop -f default.nix -I nixpkgs=/nixpkgs-ra/nixpkgs + +# nix flake show +flake-show: _flake-show-package _flake-show-name _flake-show-derivation + +# nix-build flake spine +flake-build: _flake-show-name + nix build --print-build-logs + +# nix-build flake spine +flake-reset-build: _flake-lock-reset _flake-show-name + nix build --print-build-logs + +# nix-build flake spine debug +flake-build-debug: + nix build --debug + +# nix-build spine (with local tools, presumably latest dlang compiler & build tools (ldc & dub)) +flake-build-use-tools-new: + nix build --print-build-logs -I nixpkgs=/nixpkgs-ra/nixpkgs + +# tangle-build-flake +flake-tangle-build: org-tangle flake-build + +# build-flake-run +flake-build-run: flake-build output-samples + +# tangle-build-run +flake-tangle-build-run: org-tangle flake-build output-samples + +# nix-build spine search +flake-build-search: + cd ./sundry/spine_search_cgi; \ + nix build --print-build-logs \ + cd - + +gitsnapshot: distclean tangle + git commit -a + +.PHONY : all build rebuild debug release \ + distclean init \ + tangle gitsnapshot +#+END_SRC diff --git a/org/config_nix.org b/org/config_nix.org new file mode 100644 index 0000000..4768bc3 --- /dev/null +++ b/org/config_nix.org @@ -0,0 +1,846 @@ +-*- mode: org -*- +#+TITLE: configuration nix +#+DESCRIPTION: makefile for spine +#+FILETAGS: :spine:build:tools: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2022 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no +#+PROPERTY: header-args+ :mkdirp yes +#+OPTIONS: H:3 num:nil toc:t \n:t ::t |:t ^:nil -:t f:t *:t + +* nix :nix: + +#+NAME: nixpkgs_local +#+BEGIN_SRC sh +/srv/nixpkgs-dev/nixpkgs +#+END_SRC + +** spine markup samples + +- default.nix +- shell.nix + +*** envrc :envrc: +**** .envrc + +- https://github.com/nix-community/nix-direnv + - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-0000000000000000000000000000000000000000000=" + +#+HEADER: :tangle ../.envrc +#+BEGIN_SRC sh +# nix_direnv_watch_file provided-filename +use flake . +NIX_ENFORCE_PURITY=1 +NixDirEnvVersion="2.2.0" +if ! has nix_direnv_version || ! nix_direnv_version ${NixDirEnvVersion}; then +# - https://github.com/nix-community/nix-direnv +# source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-0000000000000000000000000000000000000000000=" + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-5EwyKnkJNQeXrRkYbwwRBcXbibosCJqyIUuz9Xq+LRc=" +fi +if [ -f .envrc-local ]; then + source_env_if_exists .envrc-local || source .envrc-local +fi +#+END_SRC + +**** .envrc-local CHECK MODIFY + +- bespoke modify appropriately and generate if needed + +#+HEADER: :tangle ../.envrc-local_ +#+HEADER: :noweb yes +#+BEGIN_SRC sh +# reload when these files change +watch_file flake.lock +#watch_file flake.nix +nix flake update; nix flake check; nix flake show +#use flake .#default +PATH_add result/bin +#path_add PATH result/bin +#export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos +#export NIX_PATH=nixpkgs=/srv/nix/nixpkgs +export DFLAGS="-O2 -inline -boundscheck=on -color=on" +## load the flake devShell +# eval "$(nix print-dev-env)" +# echo $NIX_BUILD_TOP +export Date=`date "+%Y%m%d"` +export SpineDOC=. +#export SpineSRC= +export SpineBIN=result/bin +#export SpineDOC= +export SpinePOD=$SpineDOC/markup/pod +export SpineOUT=/srv/www/spine +export SpineDBpath=/srv/www/spine/sqlite +#export SpineDBpath=/var/www/sqlite +export SpineSearchActionLocal='http://localhost/spine_search' +export SpineSearchActionRemote='https://sisudoc.org/spine_search' +export SpineCGIform='spine_search' +export SpineSQLdb='spine.search.db' +#export PROG_VER_DECLARED="`cat ./views/version.txt | grep --color=never "enum" | sed 's/.\+(\([0-9]\+\),[ \t]\+\([0-9]\+\),[ \t]\+\([0-9]\+\)[ \t]*).\+/\1.\2.\3/g'`" +#direnv allow +echo " +nix build -v .#default --print-build-logs +nix run .#default --print-build-logs +nix shell .#default --print-build-logs --command spine -v +nix develop --build .#default --print-build-logs +" +#+END_SRC + +*** flake :flake: +**** flake static :flake:static: +***** flake.nix + +#+HEADER: :tangle ../flake.nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ + description = "a sisu like document parser search form"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; # "github:nixos/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + spine.url = "<<spine_git_file_path_url>>"; + spine.inputs.nixpkgs.follows = "nixpkgs"; + spine.flake = true; + }; + outputs = { self, nixpkgs, flake-utils, spine }: + let + version = "<<spine_version_set>>"; + supportedSystems = [ "x86_64-linux" ]; # [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); # nixpkgs instantiated for supported system types. + in { + packages = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + in { + default = spine.packages.${system}.default; + #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; + }); + devShells = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + in with pkgs; { + devShell = mkShell { buildInputs = [ git dub dmd ldc gdc sqlite ]; }; + }); + }; +} +#+END_SRC + +***** flake single system + +#+HEADER: :tangle-NO ../flake-1_.nix +#+BEGIN_SRC nix +{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.spine.url = "git+file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine"; + outputs = { nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = import nixpkgs { inherit system; }; + in with pkgs; { + devShell = mkShell { buildInputs = [ git dub dmd ldc sqlite ]; }; + default = spine.packages.x86_64-linux.default; + }); +} +#+END_SRC + +#+HEADER: :tangle-NO ../flake-2_.nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.spine.url = "git+file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine"; + outputs = { nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + with import nixpkgs { inherit system; }; { + devShell = mkShell { buildInputs = [ git dub dmd ldc sqlite ]; }; + default = spine.packages.x86_64-linux.default; + }); +} +#+END_SRC + +#+HEADER: :tangle-NO ../flake-3_.nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ + description = "a sisu like parser & document generator"; + #version = "<<spine_version_set>>"; + inputs.nixpkgs.url = "<<nixpkgs_url>>"; + inputs.spine.url = "<<spine_git_file_path_url>>"; + inputs.spine.flake = true; + inputs.spine-tarball.url = "<<spine_tarball_path_url>>"; + inputs.spine-tarball.flake = true; + outputs = { <<flake_outputs>>, spine, spine-tarball }: { + <<flake_output_spine>> + <<flake_output_spine_tarball>> + <<flake_output_spine_markup_samples>> + <<flake_output_default>> + }; +} +#+END_SRC + +*** flake :flake: +**** notes? + +- flake.nix + /srv/nix/nixpkgs + ./shell.nix + - shell.nix + ./pkgs/shell-pkgs.nix + - pkgs/shell-pkgs.nix + - default.nix + ./nix/dub.selections.nix # + - dub.selections.nix + +- nix develop + +- nix flake update + +- nix shell -f default.nix --print-build-logs +- nix shell -c default.nix + +- nix build `nix-instantiate` +- 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 search --json 2>/dev/null |jq +- nix flake show +- nix show-derivation + +nix shell git+file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine --print-build-logs +nix build "git+file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine" --print-build-logs +nix develop 'git+file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine#default' +nix flake clone git+file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine/ + +# nix-instantiate | nix-build + +***** flake inputs +****** flake inputs static + +#+NAME: flake_inputs_nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +nixpkgs.url = "github:nixos/nixpkgs"; +flake-utils.url = "github:numtide/flake-utils"; +#+END_SRC + +#+NAME: flake_inputs_spine +#+HEADER: :noweb yes +#+BEGIN_SRC nix +spine.url = "git+file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine"; +spine.flake = true; +#+END_SRC + +***** flake outputs +****** flake outputs static + +#+NAME: flake_outputs +#+HEADER: :noweb yes +#+BEGIN_SRC nix +self, nixpkgs, flake-utils +#+END_SRC + +***** flake devshells + +#+NAME: flake_devshells +#+HEADER: :noweb yes +#+BEGIN_SRC nix +devShells = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + in { + default = pkgs.mkShell { + buildInputs = with pkgs; [ git dub dmd ldc sqlite ]; + }; +}); +#+END_SRC + +***** flake output default + +#+NAME: flake_output_default +#+HEADER: :noweb yes +#+BEGIN_SRC nix +packages.x86_64-linux.default = self.packages.x86_64-linux.spine; +#+END_SRC + +#+NAME: flake_output_spine +#+HEADER: :noweb yes +#+BEGIN_SRC nix +packages.x86_64-linux.spine = spine.packages.x86_64-linux.default; +#+END_SRC + +#+NAME: flake_output_spine_tarball +#+HEADER: :noweb yes +#+BEGIN_SRC nix +packages.x86_64-linux.spine-tarball = spine-tarball.packages.x86_64-linux.default; +#+END_SRC + +**** flake result/lib/spine-markup-samples + +#+NAME: flake_output_spine_markup_samples +#+HEADER: :noweb yes +#+BEGIN_SRC nix +packages.x86_64-linux.spine-markup-samples = + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + }; + in + pkgs.stdenv.mkDerivation { + pname = "spine-markup-samples"; + version = "<<spine_version_set>>"; + description = "markup samples for spine, a sisu like parser & document generator"; + inherit self; + src = self; + shell = ./shell.nix; + buildPhase = '' + runHook preBuild + HOME="$PWD" + runHook postBuild + ''; + checkPhase = '' + runHook preCheck + HOME="$PWD" + runHook postCheck + ''; + installPhase = '' + runHook preInstall + mkdir -p $out/lib/spine-markup-samples + echo "pwd: $PWD" + cp -rv ./markup $out/lib/spine-markup-samples/. + runHook postInstall + ''; + }; +#+END_SRC + +postInstall = '' + #${spine} -v + #echo "built:" + #$out/share/spine-markup-samples +''; + +***** flake misc + +#+BEGIN_SRC nix +inputs.spine.url = fetchTarball { + url = "<<spine_tarball_path_url>>"; + sha256 = "<<spine_tarball_sha256>>"; +}; +#+END_SRC + +*** shell.nix :shell: +**** tangle + +#+HEADER: :tangle ../shell.nix +#+HEADER: :tangle-mode (identity #o755) +#+HEADER: :shebang "#!/usr/bin/env -S nix-shell --pure\n#!nix-shell -i bash" +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ pkgs ? import <nixpkgs> {} }: +with pkgs; +mkShell { + buildInputs = [ + ### nix_related + # direnv + # nixVersions.unstable #nixFlakes + # nix-prefetch-git + # validatePkgConfig + # nix-tree jq nix-output-monitor + # git + # ps + ### d_build_related + ### package manager + # dub + ### compiler + # ldc + # rund + ### linker + # #lld + # #mold + ## builder + # #ninja + # #meson + ### sqlite search related + # sqlite + ### pdf_latex_related + # source-sans-pro + # source-serif-pro + # source-code-pro + # texlive.combined.scheme-full + ### xml_and_epub_related + # libxml2 + # html-tidy + # xmlstarlet + # epubcheck + # ebook_tools + # epr + # sigil + # calibre #(suite includes: ebook-viewer) + # foliate + ### i18n translation related + # perl534Packages.Po4a + ]; + shellHook = '' + #if [[ -f ".envrc" ]]; then + # source .envrc + #fi + #nix flake update + #echo "" + #echo "nix flake metadata:" + #nix flake metadata + #echo "" + #echo "nix flake check:" + #nix flake check + #echo "" + #echo "nix flake show:" + #nix flake show + echo " + nix flake update + nix flake metadata + nix flake check + nix flake show + + nix build or nix develop? (suggestions): + + - nix build + nix build .#default --print-build-logs + nix build .#default-tarball --print-build-logs + nix build .#default-markup-samples --print-build-logs + nix build --print-build-logs + nix build .#default --print-build-logs |& nom + + - nix run + nix run .#default --print-build-logs + nix run default.nix --print-build-logs + + - nix shell + nix shell .#default --print-build-logs --command spine -v + + - nix develop + nix develop --build .#default --print-build-logs + nix develop --build -f derivation.nix -I .envrc --print-build-logs + nix develop ; eval \$buildPhase + + nix-build |& nom + + spine -v + + nix-instantiate | nix show-derivation | jq + nix-build . --no-out-link | xargs -o nix-tree + nix-tree --derivation .#default + + " + ''; +} +#+END_SRC + +#+BEGIN_SRC nix +{ pkgs ? import <nixpkgs> {} }: +with pkgs; +mkShell { + buildInputs = [ + # ### nix_related + # direnv + # nixVersions.unstable #nixFlakes + # nix-prefetch-git + # validatePkgConfig + # nix-tree jq nix-output-monitor + # git + # ps + # ### d_build_related + # ## package manager + # dub + # ## compiler + # ldc + # rund + # ## linker + # #lld + # #mold + # ## builder + # #ninja + # #meson + # ### sqlite search related + # sqlite + # # ### pdf_latex_related + # # source-sans-pro + # # source-serif-pro + # # source-code-pro + # # texlive.combined.scheme-full + # # ### xml_and_epub_related + # # libxml2 + # # html-tidy + # # xmlstarlet + # # epubcheck + # # ebook_tools + # # epr + # # sigil + # # calibre #(suite includes: ebook-viewer) + # # foliate + # # ### i18n translation related + # # perl534Packages.Po4a + # ### candy + # #starship + ]; + shellHook = '' + #if [[ -f ".envrc" ]]; then + # source .envrc + #fi + #nix flake update + #echo "" + #echo "nix flake metadata:" + #nix flake metadata + #echo "" + #echo "nix flake check:" + #nix flake check + #echo "" + #echo "nix flake show:" + #nix flake show + echo " + nix flake update + nix flake metadata + nix flake check + nix flake show + + nix build or nix develop? (suggestions): + + - nix build + nix build .#default --print-build-logs + nix build .#default-tarball --print-build-logs + nix build .#default-markup-samples --print-build-logs + nix build --print-build-logs + nix build .#default --print-build-logs |& nom + + - nix run + nix run .#default --print-build-logs + nix run default.nix --print-build-logs + + - nix shell + nix shell --print-build-logs --command spine -v + + - nix develop + nix develop --build .#default --print-build-logs + nix develop --build -f derivation.nix -I .envrc --print-build-logs + nix develop ; eval \$buildPhase + + nix-build |& nom + + spine -v + + nix-instantiate | nix show-derivation | jq + nix-build . --no-out-link | xargs -o nix-tree + nix-tree --derivation .#default + + " + ''; +} +#+END_SRC + +#+BEGIN_SRC text +#% Notes + +# - shell.nix -I .envrc +# - shell.nix -I .envrc --pure + +# [ nix-shell ] + + # - nix-shell -I nixpkgs=/nixpkgs-ra/nixpkgs --pure + # - nix-shell -p "with import /nixpkgs-ra/nixpkgs {}; ldc" --pure + # - nix-shell -p "with import /nixpkgs-ra/nixpkgs {}; [dub ldc]" --pure + + # - nix-shell -p nixFlakes + # - nix-shell -p nixFlakes --pure + # - nix-shell -p nixFlakes --pure -p "with import /nixpkgs-ra/nixpkgs {}; [nix dub ldc git ps]" + # - nix-shell shell.nix direnv: export +IN_NIX_SHELL + # - nix-shell shell.nix + +# [ nix-build ] + + # - nix-build -I nixpkgs=/nixpkgs-ra/nixpkgs # --pure + # - nix-build -I .envrc --pure + # - nix-build default.nix -I .envrc && result/bin/spine -v + +# [ nix-instantiate ] + + # - nix-instantiate | nix show-derivation | jq + # - nix-instantiate -I .envrc | nix show-derivation -f derivation.nix -I .envrc | jq + # - nix-instantiate | nix show-derivation --recursive | jq + # - nix-instantiate -I .envrc | nix show-derivation -f derivation.nix --recursive -I .envrc | jq + # - nix-instantiate | nix-build + # - nix-instantiate -I .envrc | nix-build -I .envrc + +# [ nix shell ] + + # - nix shell -c default.nix + # - nix shell -f default.nix --print-build-logs + +# [ nix build ] + + # - nix build -I .envrc --print-build-logs + # - nix build -f default.nix --print-build-logs + # - nix build -f derivation.nix --print-build-logs + + # - nix build `nix-instantiate` + # - nix build `nix-instantiate -I .envrc` + + # - nix build -f default.nix && ./result/bin/spine -v && noti -t "spine build" -m "see ./result/bin/spine" + +# [ nix run ] + + # - nix run default.nix --print-build-logs + # - nix run -I .envrc default.nix --print-build-logs + +# - nix-shell -I .envrc --pure +# - nix develop --build -f derivation.nix -I .envrc --print-build-logs + +# - nix-shell -p nixFlakes --pure -p "with import /nixpkgs-ra/nixpkgs {}; [nix dub ldc git ps]" +# - nix-build +# - nix build `nix-instantiate -I .envrc` + +# - nix develop --build -f default.nix -I .envrc + +# - nix-shell -I .envrc --pure +# - nix-build default.nix -I .envrc && result/bin/spine -v + +# - nix shell -f default.nix --print-build-logs +# - nix-instantiate -I .envrc | nix-build -I .envrc +#+END_SRC + +*** default.nix :default: + +- default.nix -I nixpkgs=<provide local nix path> + e.g. default.nix -I nixpkgs=/nixpkgs-ra/nixpkgs + +- nix-build -I nixpkgs=<provide local nix path> + e.g. nix-build -I nixpkgs=<<nixpkgs_local>> + +#+HEADER: :noweb yes +#+BEGIN_SRC sh +nix-build -I nixpkgs=<<nixpkgs_local>> +nix-build -I .envrc-local +nix-build -I .envrc +default.nix -I .envrc +default.nix + +nix build -f default.nix --print-build-logs +nix build -f derivation.nix --print-build-logs +nix shell -f default.nix --print-build-logs +nix develop --build -f derivation.nix -I .envrc --print-build-logs + +# nix build -f project.nix +# nix build -f spine.nix +#+END_SRC + +#+HEADER: :tangle ../default.nix +#+HEADER: :tangle-mode (identity #o755) +#+HEADER: :shebang "#!/usr/bin/env -S nix-build" +#+BEGIN_SRC nix +{ pkgs ? import <nixpkgs> {} }: +pkgs.callPackage ./derivation.nix {} +#+END_SRC + +*** derivation.nix :default: + +#+HEADER: :tangle ../derivation.nix +#+HEADER: :tangle-mode (identity #o644) +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ pkgs ? import <nixpkgs> {}, + stdenv ? pkgs.stdenv, + lib ? pkgs.lib, + ldc ? null, + dcompiler ? pkgs.ldc, + dub ? pkgs.dub +}: +assert dcompiler != null; +with ( + with lib; + let + filterDub = name: type: let baseName = baseNameOf (toString name); in ! ( # filter function to remove the .dub package folder from src + 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/bin -type f -exec ${removeExpr (disallowedReferences deps)} '{}' + || true + ''; + buildPhase = '' + runHook preBuild + HOME="$PWD" + DFLAGS="-O2 -inline" + 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 + HOME="$PWD" + dub test --combined --skip-registry=all + runHook postCheck + ''; + installPhase = '' + runHook preInstall + mkdir -p $out/bin + cp -r "${targetOf package}" $out/bin + #cp -rv "${targetOf package}" $out/spine-markup-samples/. + #cp -rv ./markup $out/spine-markup-samples/. + runHook postInstall + ''; + #postInstall= '' + # cp -rv ./markup $out/spine-markup-samples/. + #''; + 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 { + pname = "spine"; + version = "0.12.0"; + zipfile = "<<spine_tarball_filename>>"; + src = fetchTarball { + #url = "file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/tarball/${pname}-${version}.tar.gz"; + #url = "file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine/tarballGitHEAD/${pname}-${version}.tar.gz"; + #sha256 = "sha256:0000000000000000000000000000000000000000000000000000"; + url = "<<spine_tarball_path_url>>"; + sha256 = "<<spine_tarball_sha256>>"; + }; + nativeBuildInputs = with pkgs; [ dub ldc ]; + buildInputs = with pkgs; [ + nixVersions.unstable #nixFlakes + sqlite + ]; + meta = with pkgs.lib; { + description = "A sisu like parser & document generator"; + longDescription = '' + A sisu like parser & document generator + ''; + homepage = "https://sisudoc.org"; + license = licenses.agpl3Plus; + platforms = platforms.linux; + maintainers = [ "RalphAmissah" ]; + }; +} +#+END_SRC + +# src = fetchTarball { +# url = "file:///[path]/${pname}-${version}.tar.gz"; +# sha256 = "sha256:0000000000000000000000000000000000000000000000000000"; +# }; + +#src = ./.; + +** variables +*** spine version SET VERSION :version:set:project: + +#+NAME: spine_version_set +#+BEGIN_SRC sh +0.12.0 +#+END_SRC + +#+NAME: project_path_local_out_static +#+HEADER: :noweb yes +#+BEGIN_SRC nix +/srv/www/spine +#+END_SRC + +#+NAME: spine_tarball_path +#+HEADER: :noweb yes +#+BEGIN_SRC nix +/home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/tarball +#+END_SRC + +#+NAME: spine_tarball_path_url +#+HEADER: :noweb yes +#+BEGIN_SRC nix +file://<<spine_tarball_path>>/<<spine_tarball_filename>> +#+END_SRC + +#+NAME: spine_git_file_path +#+HEADER: :noweb yes +#+BEGIN_SRC nix +/home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/spine +#+END_SRC + +#+NAME: spine_git_file_path_url +#+HEADER: :noweb yes +#+BEGIN_SRC nix +git+file://<<spine_git_file_path>> +#+END_SRC + +#+NAME: spine_tarball_filename +#+HEADER: :noweb yes +#+BEGIN_SRC nix +spine-0.12.0-tag-0.11.2.r107.gf89a107.tar.gz +#+END_SRC + +#+NAME: spine_tarball_sha256 +#+HEADER: :noweb yes +#+BEGIN_SRC nix +sha256:03dr7dn7kq6arw4ry7qar13iqmi1caw70imfjwi8qr7g2j4mnk2q +#+END_SRC + +#+BEGIN_SRC nix +sha256:0000000000000000000000000000000000000000000000000000 +#+END_SRC + +/home/ralph/grotto/repo/git.repo/projects/project-spine/tarball + +#+NAME: project_path_local_out_static_ +#+BEGIN_SRC nix +/var/www +#+END_SRC + +#+NAME: project_path_sqlite +#+BEGIN_SRC nix +/var/www/sqlite +#+END_SRC + +#+NAME: nixpkgs_url +#+BEGIN_SRC nix +github:nixos/nixpkgs +#+END_SRC + +#+HEADER: :noweb yes +#+BEGIN_SRC nix +<<nixpkgs_path_local>> +#+END_SRC + diff --git a/shell.nix b/shell.nix index 0a6aa9a..517e9a2 100644..100755 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,98 @@ +#!/usr/bin/env -S nix-shell --pure +#!nix-shell -i bash { pkgs ? import <nixpkgs> {} }: -pkgs.mkShell { - buildInputs = with pkgs; - [ (import ./packages-ldc.nix { inherit pkgs; }) ]; +with pkgs; +mkShell { + buildInputs = [ + ### nix_related + # direnv + # nixVersions.unstable #nixFlakes + # nix-prefetch-git + # validatePkgConfig + # nix-tree jq nix-output-monitor + # git + # ps + ### d_build_related + ### package manager + # dub + ### compiler + # ldc + # rund + ### linker + # #lld + # #mold + ## builder + # #ninja + # #meson + ### sqlite search related + # sqlite + ### pdf_latex_related + # source-sans-pro + # source-serif-pro + # source-code-pro + # texlive.combined.scheme-full + ### xml_and_epub_related + # libxml2 + # html-tidy + # xmlstarlet + # epubcheck + # ebook_tools + # epr + # sigil + # calibre #(suite includes: ebook-viewer) + # foliate + ### i18n translation related + # perl534Packages.Po4a + ]; + shellHook = '' + #if [[ -f ".envrc" ]]; then + # source .envrc + #fi + #nix flake update + #echo "" + #echo "nix flake metadata:" + #nix flake metadata + #echo "" + #echo "nix flake check:" + #nix flake check + #echo "" + #echo "nix flake show:" + #nix flake show + echo " + nix flake update + nix flake metadata + nix flake check + nix flake show + + nix build or nix develop? (suggestions): + + - nix build + nix build .#default --print-build-logs + nix build .#default-tarball --print-build-logs + nix build .#default-markup-samples --print-build-logs + nix build --print-build-logs + nix build .#default --print-build-logs |& nom + + - nix run + nix run .#default --print-build-logs + nix run default.nix --print-build-logs + + - nix shell + nix shell .#default --print-build-logs --command spine -v + + - nix develop + nix develop --build .#default --print-build-logs + nix develop --build -f derivation.nix -I .envrc --print-build-logs + nix develop ; eval \$buildPhase + + nix-build |& nom + + spine -v + + nix-instantiate | nix show-derivation | jq + nix-build . --no-out-link | xargs -o nix-tree + nix-tree --derivation .#default + + " + ''; } |