From bc5b1b8bb3d45d9c04ccc46bb8732f859e4b896c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 29 Aug 2021 19:04:09 -0400 Subject: config nix --- org/config_nix.org | 444 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 258 insertions(+), 186 deletions(-) (limited to 'org') diff --git a/org/config_nix.org b/org/config_nix.org index ff3d540..3e63e9d 100644 --- a/org/config_nix.org +++ b/org/config_nix.org @@ -18,7 +18,7 @@ * nix :nix: ** NOTES -**** nix-shell +*** nix-shell - default.nix @@ -34,7 +34,7 @@ nix-shell nix-build project.nix #+END_SRC -**** nix-shell --pure +*** nix-shell --pure - default.nix @@ -57,7 +57,7 @@ nix build -f project.nix nix build -f spine.nix #+END_SRC -**** derivation .drv +*** derivation .drv #+BEGIN_SRC sh nix show-derivation /nix/store/q7n14bm8j5vzm62qaraczdb4bpyf59vv-spine-0.11.1.drv @@ -146,6 +146,7 @@ export SpineVER=$(git describe --long --tags | sed 's/^[ a-z_-]\+\([0-9.]\+\)/\1 export SpineSRC=<> export SpineBIN=<> export SpineDOC=<> +export SpinePOD=$SpineDOC/markup/pod export SpineOUTversioned=<> export SpineOUTstatic=<> @@ -194,6 +195,7 @@ echo "#+END_SRC ,#+BEGIN_SRC sh SpineSRC=$SpineSRC SpineDOC=$SpineDOC +SpinePOD=$SpinePOD SpineOUTversioned=$SpineOUTversioned SpineOUTstatic=$SpineOUTstatic ,#+END_SRC @@ -204,44 +206,44 @@ echo '* spine run instruction examples ,*** doc source ,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --pod --source --output="$SpineOUTversioned" $SpineDOC/markup/pod/* +$SpineBIN/spine --very-verbose --pod --source --output="$SpineOUTversioned" $SpinePOD/* ,#+END_SRC ,*** html & epub output ,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --html --epub --output="$SpineOUTversioned" $SpineDOC/markup/pod/* +$SpineBIN/spine --very-verbose --html --epub --output="$SpineOUTversioned" $SpinePOD/* ,#+END_SRC ,*** sqlite db for each document - populate each db ,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --sqlite-discrete --output="$SpineOUTversioned" $SpineDOC/markup/pod/* +$SpineBIN/spine --very-verbose --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/* ,#+END_SRC ,*** doc source; html, epub; sqlite outputs ,#+BEGIN_SRC sh -$SpineBIN/spine --verbose --pod --html --epub --sqlite-discrete --output="$SpineOUTversioned" $SpineDOC/markup/pod/* +$SpineBIN/spine --verbose --pod --html --epub --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/* ,#+END_SRC ,*** harvest (authors topics) ,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --harvest --output="$SpineOUTversioned" $SpineDOC/markup/pod/* +$SpineBIN/spine --very-verbose --harvest --output="$SpineOUTversioned" $SpinePOD/* ,#+END_SRC ,*** html, harvest ,#+BEGIN_SRC sh -$SpineBIN/spine --verbose --dark --html --html-link-harvest --harvest --output="$SpineOUTversioned" $SpineDOC/markup/pod/* -$SpineBIN/spine --very-verbose --html --html-link-harvest --harvest --output="$SpineOUTversioned" $SpineDOC/markup/pod/* +$SpineBIN/spine --verbose --dark --html --html-link-harvest --harvest --output="$SpineOUTversioned" $SpinePOD/* +$SpineBIN/spine --very-verbose --html --html-link-harvest --harvest --output="$SpineOUTversioned" $SpinePOD/* ,#+END_SRC ,*** composite command: source pod, html, epub, harvest, sqlite ,#+BEGIN_SRC sh -$SpineBIN/spine --verbose --dark --pod --epub --html --html-link-harvest --harvest --sqlite-discrete --output="$SpineOUTversioned" $SpineDOC/markup/pod/* +$SpineBIN/spine --verbose --dark --pod --epub --html --html-link-harvest --harvest --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/* ,#+END_SRC ,** sequential tasks @@ -266,42 +268,42 @@ $SpineBIN/spine --very-verbose --sqlite-db-drop --output="$SpineOUTversioned" ,*** sqlite db (shared) - create & populate db (single step) ,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --sqlite-db-create --sqlite-update --output="$SpineOUTversioned" $SpineDOC/markup/pod/* +$SpineBIN/spine --very-verbose --sqlite-db-create --sqlite-update --output="$SpineOUTversioned" $SpinePOD/* ,#+END_SRC ,*** composite command: source pod, html, epub, harvest, sqlite ,#+BEGIN_SRC sh -$SpineBIN/spine --verbose --no-parallel --dark --pod --epub --html --html-link-harvest --harvest --sqlite-discrete --output="$SpineOUTversioned" $SpineDOC/markup/pod/* +$SpineBIN/spine --verbose --no-parallel --dark --pod --epub --html --html-link-harvest --harvest --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/* ,#+END_SRC ,** config [./pod/].dr/config_local_site ,#+BEGIN_SRC sh -cat $SpineDOC/markup/pod/.dr/config_local_site -$SpineBIN/spine --show-config $SpineDOC/markup/pod -$SpineBIN/spine --show-config --output="$SpineOUTversioned" $SpineDOC/markup/pod +cat $SpinePOD/.dr/config_local_site +$SpineBIN/spine --show-config $SpinePOD +$SpineBIN/spine --show-config --output="$SpineOUTversioned" $SpinePOD ,#+END_SRC ,** cgi operations (output to $SpineOUTstatic /var/www) ,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --sqlite-db-create --output="$SpineOUTstatic" $SpineDOC/markup/pod/* +$SpineBIN/spine --very-verbose --sqlite-db-create --output="$SpineOUTstatic" $SpinePOD/* -$SpineBIN/spine -v --cgi-search-form-codegen --output=$SpineOUTstatic $SpineDOC/markup/pod/* +$SpineBIN/spine -v --cgi-search-form-codegen --output=$SpineOUTstatic $SpinePOD/* -$SpineBIN/spine -v --show-config --config=$SpineDOC/markup/pod/.dr +$SpineBIN/spine -v --show-config --config=$SpinePOD/.dr -$SpineBIN/spine --html $SpineDOC/markup/pod/* +$SpineBIN/spine --html $SpinePOD/* -$SpineBIN/spine -v --cgi-search-form-codegen --config=$SpineDOC/markup/pod/.dr/config_local_site +$SpineBIN/spine -v --cgi-search-form-codegen --config=$SpinePOD/.dr/config_local_site ,#+END_SRC ,*** generate html linked to search form ,#+BEGIN_SRC sh -$SpineBIN/spine -v --html --html-link-search --html-link-harvest --harvest --output=$SpineOUTstatic $SpineDOC/markup/pod/* +$SpineBIN/spine -v --html --html-link-search --html-link-harvest --harvest --output=$SpineOUTstatic $SpinePOD/* ,#+END_SRC ,*** create or re-create sql db (--sqlite-db-create or --sqlite-db-recreate) @@ -314,19 +316,19 @@ $SpineBIN/spine -v --sqlite-db-recreate --sqlite-db-filename="< ,*** populate sqlite db ,#+BEGIN_SRC sh -$SpineBIN/spine -v --sqlite-update --sqlite-db-filename="<>" --output=$SpineOUTstatic $SpineDOC/markup/pod/* +$SpineBIN/spine -v --sqlite-update --sqlite-db-filename="<>" --output=$SpineOUTstatic $SpinePOD/* ,#+END_SRC ,*** generate html (linked to search form), sql output, harvest COMPOSITE ,#+BEGIN_SRC sh -$SpineBIN/spine -v --html --html-link-search --html-link-harvest --harvest --sqlite-update --sqlite-db-filename="<>" --cgi-sqlite-search-filename="<>" --output="$SpineOUTstatic" $SpineDOC/markup/pod/* +$SpineBIN/spine -v --html --html-link-search --html-link-harvest --harvest --sqlite-update --sqlite-db-filename="<>" --cgi-sqlite-search-filename="<>" --output="$SpineOUTstatic" $SpinePOD/* ,#+END_SRC ,*** make search form ,#+BEGIN_SRC sh -$SpineBIN/spine -v --cgi-search-form-codegen --config=$SpineDOC/markup/pod/.dr/config_local_site +$SpineBIN/spine -v --cgi-search-form-codegen --config=$SpinePOD/.dr/config_local_site ,#+END_SRC ' >> nix_note_.org @@ -452,6 +454,7 @@ nix flake update #+END_SRC *** shell.nix :shell: +**** NOTES nix-shell @@ -488,6 +491,8 @@ nix flake update nix build -f default.nix ./result/bin/spine +**** tangle + #+HEADER: :tangle ../shell.nix #+HEADER: :tangle-mode (identity #o755) #+HEADER: :shebang "#!/usr/bin/env -S nix-shell --pure" @@ -496,15 +501,9 @@ nix flake update pkgs.mkShell { buildInputs = with pkgs; [( with pkgs; [ - nixFlakes - rund - dub - ldc - sqlite - nix-prefetch-git - validatePkgConfig - jq - git + <> + <> + # <> ] )]; shellHook = '' @@ -515,6 +514,40 @@ pkgs.mkShell { } #+END_SRC +**** parts +***** packages nix related + +#+NAME: shell_packages_nix_related +#+BEGIN_SRC nix +# nix_related +nixFlakes +nix-prefetch-git +validatePkgConfig +jq +git +#+END_SRC + +***** packages d build related + +#+NAME: shell_packages_d_build_related +#+BEGIN_SRC nix +# d_build_related +rund +dub +ldc +#meson +#+END_SRC + +***** packages search sqlite related + +#+NAME: shell_packages_search_sqlite_related +#+BEGIN_SRC nix +# search_sqlite_related +sqlite +#+END_SRC + +**** misc + #+HEADER: :NO-tangle ../shell.nix #+HEADER: :tangle-mode (identity #o755) #+HEADER: :shebang "#!/usr/bin/env -S nix-shell" @@ -543,16 +576,18 @@ pkgs.mkShell { - nix-build -I nixpkgs= e.g. nix-build -I nixpkgs=/nixpkgs-ra/nixpkgs - nix-build -I nixpkgs=/nixpkgs-ra/nixpkgs - nix-build -I .envrc-local - nix-build -I .envrc - default.nix -I .envrc - default.nix +#+BEGIN_SRC sh +nix-build -I nixpkgs=/nixpkgs-ra/nixpkgs +nix-build -I .envrc-local +nix-build -I .envrc +default.nix -I .envrc +default.nix - nix build - nix build -f default.nix - nix build -f project.nix - nix build -f spine.nix +nix build +nix build -f default.nix +nix build -f project.nix +nix build -f spine.nix +#+END_SRC #+HEADER: :tangle ../default.nix #+HEADER: :tangle-mode (identity #o755) @@ -783,7 +818,185 @@ git #+END_SRC ** spine search cgi (in ./sundry) -*** shell.nix +*** envrc :envrc: +**** .envrc + +#+HEADER: :tangle "../sundry/spine_search_cgi/.envrc" +#+BEGIN_SRC sh +NIX_ENFORCE_PURITY=0 +if [ -e .envrc-local ]; then # source an additional user-specific .envrc in ./.envrc-local + source .envrc-local +fi +#+END_SRC + +**** .envrc-local + +#+HEADER: :tangle "../sundry/spine_search_cgi/.envrc-local_" +#+BEGIN_SRC sh +export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos +#export NIX_PATH=nixpkgs=/nixpkgs-ra/nixpkgs +# reload when these files change +watch_file flake.nix +# watch_file flake.lock +## load the flake devShell +eval "$(nix print-dev-env)" +# echo $NIX_BUILD_TOP +export SpineVER=$(git describe --long --tags | sed 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g') +export SpineSRC=<> +export SpineBIN=<> +export SpineDOC=<> +export SpinePOD=$SpineDOC/markup/pod +#export SpineOUTversioned=<> +export SpineOUTstatic=<> +export SpineCgiBIN=<> + +echo '-*- mode: org -*- + +,* nixpkgs path? + + eval "$(nix print-dev-env)" +' > nix_note_.org + +echo " == `nix-instantiate --find-file nixpkgs`" >> nix_note_.org + +echo ' +,* nix build and show derivation + +,#+BEGIN_SRC sh +nix-shell --pure + +nix-build +nix build -f default.nix +nix shell -f default.nix +nix-instantiate | nix-build +nix build `nix-instantiate` + +nix develop + +nix-instantiate | nix show-derivation | jq +nix-instantiate | nix show-derivation --recursive | jq + +nix search --json 2>/dev/null |jq +,#+END_SRC + +,* version and build info + +,#+BEGIN_SRC sh' >> nix_note_.org + +echo 'spine version (git) == $SpineVER' >> nix_note_.org +echo "spine version (git) == $SpineVER" >> nix_note_.org +echo 'nix-instantiate == `nix-instantiate`' >> nix_note_.org +echo "nix-instantiate == `nix-instantiate`" >> nix_note_.org + +echo "#+END_SRC + +,* initialised shell variables + +,#+BEGIN_SRC sh +SpineSRC=$SpineSRC +SpineBIN=$SpineBIN +SpineDOC=$SpineDOC +SpinePOD=$SpinePOD +#SpineOUTversioned=$SpineOUTversioned +SpineOUTstatic=$SpineOUTstatic +SpineCgiBIN=$SpineCgiBIN +,#+END_SRC +" >> nix_note_.org + +echo '* cgi form spine_search nix build and copy to spine-search + +,#+BEGIN_SRC sh +nix-build && sudo cp -vi result/share/cgi-bin/spine_search $SpineCgiBIN/. +,#+END_SRC + +,* spine run instruction examples +,** cgi operations (output to $SpineOUTstatic) +,*** configuration + +,#+BEGIN_SRC sh +$SpineBIN/spine -v --show-config --config=$SpinePOD/.dr +,#+END_SRC + +,*** generate html (linked to search form & harvest) + +,#+BEGIN_SRC sh +$SpineBIN/spine -v --html --html-link-search --html-link-harvest --sqlite-db-filename="<>" --cgi-sqlite-search-filename="<>"--output=$SpineOUTstatic $SpinePOD/* +,#+END_SRC + +,*** generate sql output + +,#+BEGIN_SRC sh +SpineBIN/spine -v --sqlite-update --sqlite-db-filename="<>" --output=$SpineOUTstatic $SpinePOD/* +,#+END_SRC + +,*** generate harvest + +,#+BEGIN_SRC sh +$SpineBIN/spine -v --harvest --output=$SpineOUTstatic $SpinePOD/* +$SpineBIN/spine -v --html --html-link-harvest --harvest --output=$SpineOUTstatic $SpinePOD/* +,#+END_SRC + +,*** create or re-create sql db (--sqlite-db-create or --sqlite-db-recreate) + +,#+BEGIN_SRC sh +$SpineBIN/spine -v --sqlite-db-recreate --sqlite-db-filename="<>" --output="$SpineOUTstatic" +,#+END_SRC + +,*** generate html (linked to search form), sql output, harvest + +,#+BEGIN_SRC sh +$SpineBIN/spine -v --html --html-link-search --html-link-harvest --harvest --sqlite-db-filename="<>" --cgi-sqlite-search-filename="<>" --sqlite-update --output=$SpineOUTstatic $SpinePOD/* +,#+END_SRC + +,*** make search form + +,#+BEGIN_SRC sh +$SpineBIN/spine -v --cgi-search-form-codegen --config=$SpinePOD/.dr/config_local_site +#$SpineBIN/spine -v --cgi-search-form-codegen --output=$SpineOUTstatic $SpinePOD/* +,#+END_SRC +' >> nix_note_.org + +cat nix_note_.org + +echo "emacs nix_note_.org" +echo "cat nix_note_.org" +#+END_SRC + +*** flake :flake: + +- flake.nix + +nix develop + +nix flake update + +#+HEADER: :tangle "../sundry/spine_search_cgi/flake.nix" +#+BEGIN_SRC nix +{ + description = "a sisu like document parser search form"; + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs"; + }; + outputs = { self, nixpkgs, flake-utils }: + let + pkgs = nixpkgs.legacyPackages.x86_64-linux; + in { + packages.x86_64-linux.spine = pkgs.stdenv.mkDerivation { + name = "spine_search"; + inherit self; + src = self; + shell = ./shell.nix; + installPhase = '' + install -m755 -D spine_search $out/share/cgi-bin/spine_search + ''; + }; + defaultPackage.x86_64-linux = self.packages.x86_64-linux.spine; + }; +} +#+END_SRC + +*** shell.nix :shell: #+HEADER: :tangle "../sundry/spine_search_cgi/shell.nix" #+HEADER: :tangle-mode (identity #o755) @@ -812,7 +1025,7 @@ pkgs.mkShell { } #+END_SRC -*** default.nix +*** default.nix :default: #+HEADER: :tangle "../sundry/spine_search_cgi/default.nix" #+HEADER: :tangle-mode (identity #o755) @@ -933,147 +1146,6 @@ mkDubDerivation rec { } #+END_SRC -*** .envrc - -#+HEADER: :tangle "../sundry/spine_search_cgi/.envrc" -#+BEGIN_SRC sh -NIX_ENFORCE_PURITY=0 -if [ -e .envrc-local ]; then # source an additional user-specific .envrc in ./.envrc-local - source .envrc-local -fi -#+END_SRC - -*** .envrc-local - -#+HEADER: :tangle "../sundry/spine_search_cgi/.envrc-local_" -#+BEGIN_SRC sh -export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos -#export NIX_PATH=nixpkgs=/nixpkgs-ra/nixpkgs -# reload when these files change -watch_file flake.nix -# watch_file flake.lock -## load the flake devShell -eval "$(nix print-dev-env)" -# echo $NIX_BUILD_TOP -export SpineVER=$(git describe --long --tags | sed 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g') -export SpineSRC=<> -export SpineBIN=<> -export SpineDOC=<> -#export SpineOUTversioned=<> -export SpineOUTstatic=<> -export SpineCgiBIN=<> - -echo '-*- mode: org -*- - -,* nixpkgs path? - - eval "$(nix print-dev-env)" -' > nix_note_.org - -echo " == `nix-instantiate --find-file nixpkgs`" >> nix_note_.org - -echo ' -,* nix build and show derivation - -,#+BEGIN_SRC sh -nix-shell --pure - -nix-build -nix build -f default.nix -nix shell -f default.nix -nix-instantiate | nix-build -nix build `nix-instantiate` - -nix develop - -nix-instantiate | nix show-derivation | jq -nix-instantiate | nix show-derivation --recursive | jq - -nix search --json 2>/dev/null |jq -,#+END_SRC - -,* version and build info - -,#+BEGIN_SRC sh' >> nix_note_.org - -echo 'spine version (git) == $SpineVER' >> nix_note_.org -echo "spine version (git) == $SpineVER" >> nix_note_.org -echo 'nix-instantiate == `nix-instantiate`' >> nix_note_.org -echo "nix-instantiate == `nix-instantiate`" >> nix_note_.org - -echo "#+END_SRC - -,* initialised shell variables - -,#+BEGIN_SRC sh -SpineSRC=$SpineSRC -SpineBIN=$SpineBIN -SpineDOC=$SpineDOC -#SpineOUTversioned=$SpineOUTversioned -SpineOUTstatic=$SpineOUTstatic -SpineCgiBIN=$SpineCgiBIN -,#+END_SRC -" >> nix_note_.org - -echo '* cgi form spine_search nix build and copy to spine-search - -,#+BEGIN_SRC sh -nix-build && sudo cp -vi result/share/cgi-bin/spine_search $SpineCgiBIN/. -,#+END_SRC - -,* spine run instruction examples -,** cgi operations (output to $SpineOUTstatic) -,*** configuration - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --show-config --config=$SpineDOC/markup/pod/.dr -,#+END_SRC - -,*** generate html (linked to search form & harvest) - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --html --html-link-search --html-link-harvest --sqlite-db-filename="<>" --cgi-sqlite-search-filename="<>"--output=$SpineOUTstatic $SpineDOC/markup/pod/* -,#+END_SRC - -,*** generate sql output - -,#+BEGIN_SRC sh -SpineBIN/spine -v --sqlite-update --sqlite-db-filename="<>" --output=$SpineOUTstatic $SpineDOC/markup/pod/* -,#+END_SRC - -,*** generate harvest - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --harvest --output=$SpineOUTstatic $SpineDOC/markup/pod/* -$SpineBIN/spine -v --html --html-link-harvest --harvest --output=$SpineOUTstatic $SpineDOC/markup/pod/* -,#+END_SRC - -,*** create or re-create sql db (--sqlite-db-create or --sqlite-db-recreate) - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --sqlite-db-recreate --sqlite-db-filename="<>" --output="$SpineOUTstatic" -,#+END_SRC - -,*** generate html (linked to search form), sql output, harvest - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --html --html-link-search --html-link-harvest --harvest --sqlite-db-filename="<>" --cgi-sqlite-search-filename="<>" --sqlite-update --output=$SpineOUTstatic $SpineDOC/markup/pod/* -,#+END_SRC - -,*** make search form - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --cgi-search-form-codegen --config=$SpineDOC/markup/pod/.dr/config_local_site -#$SpineBIN/spine -v --cgi-search-form-codegen --output=$SpineOUTstatic $SpineDOC/markup/pod/* -,#+END_SRC -' >> nix_note_.org - -cat nix_note_.org - -echo "emacs nix_note_.org" -echo "cat nix_note_.org" -#+END_SRC - ** variables *** spine version SET VERSION :version:set:project: -- cgit v1.2.3