From 3d78a7541b6bdeca09496c92387fc74f77b70962 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 15 Dec 2022 19:55:49 -0500 Subject: nix and build housekeeping --- org/config_dub.org | 43 +- org/config_git.org | 18 +- org/config_make.org | 10 +- org/config_nix.org | 1321 +++++++++++++++++++++++++++++++-------------------- 4 files changed, 859 insertions(+), 533 deletions(-) (limited to 'org') diff --git a/org/config_dub.org b/org/config_dub.org index 0384378..13f57ff 100644 --- a/org/config_dub.org +++ b/org/config_dub.org @@ -66,12 +66,27 @@ "buildTypes": { "dmd": { "dflags": [ "-J=views", "-I=src/doc_reform" ], - "buildOptions": [ "verbose", "inline" ], + "buildOptions": [ "inline", "verbose" ], "buildRequirements": [ "allowWarnings" ] }, - "ldc": { + "ldc2": { "dflags": [ "-O2", "-J=views", "-I=src/doc_reform" ], - "buildOptions": [ "verbose", "optimize", "inline" ], + "buildOptions": [ "optimize", "inline", "verbose" ], + "buildRequirements": [ "allowWarnings" ] + }, + "ldmd2": { + "dflags": [ "-O2", "-boundscheck=on", "-J=views", "-I=src/doc_reform", "-color=on" ], + "buildOptions": [ "optimize", "inline", "verbose" ], + "buildRequirements": [ "allowWarnings" ] + }, + "gdc": { + "dflags": [ "-O2", "-J=views", "-I=src/doc_reform" ], + "buildOptions": [ "optimize", "inline" ], + "buildRequirements": [ "allowWarnings" ] + }, + "gdmd": { + "dflags": [ "-O2", "-J=views", "-I=src/doc_reform" ], + "buildOptions": [ "optimize", "inline" ], "buildRequirements": [ "allowWarnings" ] } }, @@ -84,8 +99,8 @@ { "name": "d2sqlite3", "description": "A thin wrapper around SQLite 3", - "homepage": "https://github.com/dlang-community/d2sqlite3", - "authors": [ "Nicolas Sicard", "Other contributors: see Github repo" ], + "homepage": "https://github.com/dlang-community/d2sqlite3", + "authors": [ "Nicolas Sicard", "Other contributors: see Github repo" ], "copyright": "Copyright 2011-18 Nicolas Sicard", "license": "BSL-1.0", "sourcePaths": [ "./src/ext_depends/d2sqlite3/source" ], @@ -110,15 +125,15 @@ "importPaths": [ "./src/ext_depends/imageformats" ] }, { - "name": "dyaml", + "name": "dyaml", "description": "YAML parser and emitter", "authors": [ "Ferdinand Majerech", "Cameron \"Herringway\" Ross" ], - "license": "BSL-1.0", - "homepage": "https://github.com/dlang-community/D-YAML", - "copyright": "Copyright © 2011-2018, Ferdinand Majerech", + "license": "BSL-1.0", + "homepage": "https://github.com/dlang-community/D-YAML", + "copyright": "Copyright © 2011-2018, Ferdinand Majerech", "sourcePaths": [ "./src/ext_depends/D-YAML/source", "./src/ext_depends/tinyendian/source" @@ -139,12 +154,20 @@ "targetName": "spine" }, { - "name": "ldc", + "name": "ldc2", + "targetName": "spine-ldc" + }, + { + "name": "ldmd2", "targetName": "spine-ldc" }, { "name": "dmd", "targetName": "spine-dmd" + }, + { + "name": "gdc", + "targetName": "spine-gdc" } ] } diff --git a/org/config_git.org b/org/config_git.org index 328a192..303b4e7 100644 --- a/org/config_git.org +++ b/org/config_git.org @@ -30,11 +30,9 @@ ,* !.gitignore !.gitattributes -!*.nix -!nix !nix/** !*.nix -#!flake.lock +!flake.lock !.envrc !README.md !README @@ -53,7 +51,6 @@ !*.d !*.rb !*.txt -!conf.sdl !doc !doc/** !man @@ -93,6 +90,7 @@ notes/** ,**/cgi-bin/** tmp/** ,*_.org +,*_.nix ,*_.d ,*_.txt ,*_ @@ -107,3 +105,15 @@ tmp/** #*.\#* #.reggae/** #+END_SRC + +** gitattributes :gitattributes: + +#+HEADER: :tangle "../.gitattributes" +#+BEGIN_SRC sh +/org export-ignore +/subprojects export-ignore +/build export-ignore +.gitattributes export-ignore +tangle export-ignore +flake.lock export-ignore +#+END_SRC diff --git a/org/config_make.org b/org/config_make.org index cfbd01a..5451130 100644 --- a/org/config_make.org +++ b/org/config_make.org @@ -1628,7 +1628,7 @@ nix-shell-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 + nix-shell -I nixpkgs=/nix/nixpkgs --pure # shell.nix (with shebang) shell: @@ -1670,7 +1670,7 @@ _flake-show-derivation: nix show-derivation |jq; nix-develop: - nix develop -f default.nix -I nixpkgs=/nixpkgs-ra/nixpkgs + nix develop -f default.nix -I nixpkgs=/nix/nixpkgs # nix flake show flake-show: _flake-show-package _flake-show-name _flake-show-derivation @@ -1689,7 +1689,7 @@ flake-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 + nix build --print-build-logs -I nixpkgs=/nix/nixpkgs # tangle-build-flake flake-tangle-build: org-tangle flake-build @@ -1732,8 +1732,8 @@ gitsnapshot: distclean tangle #+HEADER: :NO-tangle ../.env/local #+BEGIN_SRC sh export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos -#export NIX_PATH=nixpkgs=/nixpkgs-ra/nixpkgs -#export NIX_PATH=/nixpkgs-ra/nixpkgs +#export NIX_PATH=nixpkgs=/nix/nixpkgs +#export NIX_PATH=/nix/nixpkgs # reload when these files change # watch_file flake.nix # watch_file flake.lock diff --git a/org/config_nix.org b/org/config_nix.org index 86c61ee..50583a1 100644 --- a/org/config_nix.org +++ b/org/config_nix.org @@ -19,50 +19,7 @@ #+NAME: nixpkgs_local #+BEGIN_SRC sh -/nixpkgs-ra/nixpkgs -#+END_SRC - -** NOTES -*** nix-shell - -- default.nix - -#+BEGIN_SRC sh -nix-shell -nix-build -#+END_SRC - -- project.nix - -#+BEGIN_SRC sh -nix-shell -nix-build project.nix -#+END_SRC - -*** nix-shell --pure - -- default.nix - -#+HEADER: :noweb yes -#+BEGIN_SRC sh -nix-shell --pure -nix-build -I nixpkgs=<> -nix-build -I .envrc -#+END_SRC - -#+BEGIN_SRC sh -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 build -f project.nix -# nix build -f spine.nix -nix develop --build -f derivation.nix -I .envrc --print-build-logs -#+END_SRC - -*** derivation .drv - -#+BEGIN_SRC sh -nix show-derivation /nix/store/q7n14bm8j5vzm62qaraczdb4bpyf59vv-spine-0.11.1.drv +/srv/nix/nixpkgs #+END_SRC ** spine @@ -78,89 +35,43 @@ nix show-derivation /nix/store/q7n14bm8j5vzm62qaraczdb4bpyf59vv-spine-0.11.1.drv #+HEADER: :tangle ../.envrc #+BEGIN_SRC sh +# nix_direnv_watch_file provided-filename use flake . NIX_ENFORCE_PURITY=1 -NixDirEnvVersion="2.1.2" +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-ytpQmMcUBR2czh8kGOqn/dmD6u55m3lDbeu/G8HGD7A=" -fi -if [ -f .envrc-local ]; then - source_env_if_exists .envrc-local || source .envrc-local -fi -#+END_SRC - -- lorri? - -#+HEADER: :NO-tangle ../.envrc -#+BEGIN_SRC sh -if type lorri &>/dev/null; then - echo "direnv: using lorri from PATH ($(type -p lorri))" - # eval "$(lorri direnv)" -else # fallback prevent bootstrapping problems by using direnv's builtin nix support - use nix - NIX_ENFORCE_PURITY=0 + 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 -- enable flakes - -#+HEADER: :NO-tangle ../.envrc -#+BEGIN_SRC sh -if [ -f flake.lock ] && [ -f flake.nix ]; then - # reload when these files change - watch_file flake.nix - watch_file flake.lock - # load the flake devShell - if [ ! -d $(direnv_layout_dir) ]; then - mkdir $(direnv_layout_dir) - fi - eval "$(nix --experimental-features 'nix-command flakes' print-dev-env --profile "$(direnv_layout_dir)/flake-profile")" -else - # fall back to using direnv's builtin nix support - # to prevent bootstrapping problems. - # use nix - if type lorri &>/dev/null; then - echo "direnv: using lorri from PATH ($(type -p lorri))" - eval "$(lorri direnv)" - else - # fall back to using direnv's builtin nix support - # to prevent bootstrapping problems. - use nix - NIX_ENFORCE_PURITY=0 - fi - if [ -f .envrc-local ]; then - source_env_if_exists .envrc-local || source .envrc-local - fi -fi -#+END_SRC - **** .envrc-local CHECK MODIFY - bespoke modify appropriately and generate if needed #+HEADER: :tangle ../.envrc-local_ #+HEADER: :noweb yes -#+BEGIN_SRC nix -echo ".envrc called .envrc-local" +#+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 export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos -#export NIX_PATH=nixpkgs=/nixpkgs/nixpkgs -#export NIX_PATH=/nixpkgs/nixpkgs +#export NIX_PATH=/srv/nix/nixpkgs +#export NIX_PATH=nixpkgs=/srv/nix/nixpkgs export DFLAGS="-O2 -inline -boundscheck=on -color=on" -# 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 Date=`date "+%Y%m%d"` export SpineVER=$(git describe --long --tags | sed 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g') -export SpinePROJ=~/grotto/repo/git.repo/projects/project-spine/doc-reform +export SpinePROJ=~/grotto/repo/git.repo/projects/doc-reform/code/software/spine export SpineSRC=$SpinePROJ/src export SpineBIN=$SpinePROJ/result/bin export SpineDOC=~/grotto/repo/git.repo/projects/project-spine/doc-reform-markup/spine-markup-samples @@ -175,413 +86,418 @@ export SpineCGIform='spine_search' export SpineSQLdb='spine.search.db' export PROG_VER_GIT="`git describe --long --tags | sed -e 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g'`" 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 #+END_SRC -**** .env/echo-nixNote CHECK MODIFY - -#+HEADER: :tangle ../.env/echo-nixNote -#+BEGIN_SRC sh -echo '-*- mode: org -*- +*** flake :flake: +**** flake +***** flake.nix -,* nixpkgs path? +#+HEADER: :tangle ../flake.nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ + description = "a sisu like parser & document generator"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; # "github:nixos/nixpkgs"; "github:NixOS/nixpkgs/nixpkgs-unstable"; "nixpkgs/nixos-unstable"; "nixpkgs/nixos-21.11"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + outputs = { self, nixpkgs, flake-utils }: + let + version = "<>"; + 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 with pkgs; { + default = stdenv.mkDerivation { + pname = "spine"; + inherit version; + meta.mainProgram = "spine"; + executable = true; + src = self; + shell = ./default.nix; + devEnv = ./devenv.nix; + buildInputs = [ sqlite ]; + nativeBuildInputs = [ dub dmd ]; # [ dub dmd ]; [ dub ldc ]; [ dub gdc ]; + <> + }; + #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; + }); + apps = forAllSystems (system: { + default = { + type = "app"; + program = "${self.packages.${system}.default}/bin/spine"; + }; + }); + devShells = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + in with pkgs; { + devShell = mkShell { buildInputs = [ git dub dmd ldc gdc sqlite ]; }; + }); + }; +} +#+END_SRC - # eval "$(nix print-dev-env)" -' > nixNote_.org +**** some other possible flakes (samples) +***** flake 0 -echo " == `nix-instantiate --find-file nixpkgs`" >> nixNote_.org +#+NAME: flake_0 +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ + description = "a sisu like parser & document generator"; + inputs.<> + outputs = { <> }: { + <> + <> + }; +} +#+END_SRC -echo ' -,* nix build and show derivation +***** flake single system -,#+BEGIN_SRC sh -nix-shell --pure +#+NAME: flake_single_sytem +#+HEADER: :tangle ../flake-1-single-system_.nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ + description = "a sisu like parser & document generator"; + inputs.<> + outputs = { <> }: { + packages.x86_64-linux.spine = + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + }; + #targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}"; + in pkgs.stdenv.mkDerivation { + <> + inherit self; + src = self; + #shell = ./shell.nix; + shell = ./default.nix; + devEnv = ./devenv.nix; + <> + buildInputs = [ sqlite ]; + nativeBuildInputs = with pkgs; [ dub <> ]; # [ dmd dub ]; [ ldc dub ]; [ gdc dub ]; + }; + <> + }; +} +#+END_SRC -nix-build -nix build -f default.nix --print-build-logs -nix shell -f default.nix --print-build-logs -nix develop --build -f derivation.nix -I .envrc --print-build-logs +***** flake 2 -nix-instantiate | nix-build +#+NAME: flake_2 +#+HEADER: :tangle ../flake-2_.nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ + description = "a sisu like parser & document generator"; + inputs.<> + outputs = { <> }: + let + system = "x86_64-linux"; + pkgs = import nixpkgs { + inherit system; + }; + #lib = nixpkgs.lib; + in { + packages.x86_64-linux.spine = pkgs.stdenv.mkDerivation { + inherit system; + <> + inherit self; + src = self; + #shell = ./shell.nix; + shell = ./default.nix; + devEnv = ./devenv.nix; + <> + buildInputs = [ sqlite ]; + nativeBuildInputs = with pkgs; [ dub <> ]; # [ dub dmd ]; [ dub ldc ]; [ dub gdc ]; + }; + <> + }; +} +#+END_SRC -nix-instantiate -I .envrc | nix-build -I .envrc -nix build `nix-instantiate` -nix build `nix-instantiate -I .envrc` +***** flake (multi-system) -nix develop +#+NAME: flake_multi_system_possible +#+HEADER: :tangle ../flake-0-multi-system_.nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ + description = "a sisu like parser & document generator"; + inputs.<> + outputs = { <> }: + let + version = "<>"; + supportedSystems = [ "x86_64-linux" ]; # [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + # helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. + 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 = pkgs.stdenv.mkDerivation { + pname = "spine"; + inherit version; + src = self; + shell = ./default.nix; + devEnv = ./devenv.nix; + <> + buildInputs = [ sqlite ]; + nativeBuildInputs = with pkgs; [ dub <> ]; # [ dub dmd ]; [ dub ldc ]; [ dub gdc ]; + }; + #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; + }); + }; +} +#+END_SRC -nix-instantiate | nix show-derivation | jq -nix-instantiate -I .envrc | nix show-derivation -f derivation.nix -I .envrc | jq +*** flake :flake: +**** notes? -nix-instantiate | nix show-derivation --recursive | jq -nix-instantiate -I .envrc | nix show-derivation -f derivation.nix --recursive -I .envrc | jq +- 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 search --json 2>/dev/null |jq -,#+END_SRC +- nix develop -,* version and build info +- nix flake update -,#+BEGIN_SRC sh' >> nixNote_.org +- nix shell -f default.nix --print-build-logs +- nix shell -c default.nix -echo 'spine version (git) == $SpineVER' >> nixNote_.org -echo "spine version (git) == $SpineVER" >> nixNote_.org -echo 'nix-instantiate == `nix-instantiate`' >> nixNote_.org -echo "nix-instantiate == `nix-instantiate`" >> nixNote_.org +- 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 develop --profile .#default --print-build-logs --command spine -v -echo "#+END_SRC +- nix search --json 2>/dev/null |jq +- nix flake show +- nix show-derivation -,* initialised shell variables +# nix-instantiate | nix-build -,#+BEGIN_SRC sh -SpineSRC=$SpineSRC -SpineDOC=$SpineDOC -SpinePOD=$SpinePOD -SpineOUTversioned=$SpineOUTversioned -SpineOUT=$SpineOUT -,#+END_SRC -" >> nixNote_.org +#nix flake update +#nix flake check +#nix flake show +#nix develop +#nix build .#default --print-build-logs -echo '* spine run instruction examples -,** parallelized tasks -,*** doc source +#+BEGIN_SRC nix +src = fetchTarball { + url = "file:///[path]/$(pname)-$(version).tar.gz"; + sha256 = "sha256:0000000000000000000000000000000000000000000000000000"; +}; +#+END_SRC -,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --pod --source --output="$SpineOUTversioned" $SpinePOD/* -,#+END_SRC +**** flake parts +***** flake metadata -,*** html & epub output +#+NAME: flake_metadata +#+HEADER: :noweb yes +#+BEGIN_SRC nix +pname = "spine"; +version = "<>"; +description = "a sisu like parser and document generator"; +#+END_SRC -,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --html --epub --output="$SpineOUTversioned" $SpinePOD/* -,#+END_SRC +***** flake inputs +****** flake inputs static -,*** sqlite db for each document - populate each db +#+NAME: flake_inputs_nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +nixpkgs.url = "github:nixos/nixpkgs"; +flake-utils.url = "github:numtide/flake-utils"; +#+END_SRC -,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/* -,#+END_SRC +****** flake inputs for dub2nix -,*** doc source; html, epub; sqlite outputs +#+NAME: flake_inputs_dub2nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +flake-utils.url = "github:numtide/flake-utils"; +nixpkgs.url = "github:nixos/nixpkgs"; +d2sqlite3-src = { url = "github:dlang-community/d2sqlite3"; flake = false; }; +tinyendian-src = { url = "github:kiith-sa/tinyendian"; flake = false; }; +dyaml-src = { url = "github:dlang-community/D-YAML"; flake = false; }; +imageformats-src = { url = "github:lgvz/imageformats"; flake = false; }; +dub2nix-src = { url = "github:lionello/dub2nix"; flake = false; }; +#+END_SRC -,#+BEGIN_SRC sh -$SpineBIN/spine --verbose --pod --html --epub --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/* -,#+END_SRC +***** flake outputs +****** flake outputs static -,*** curate (authors topics) +#+NAME: flake_outputs +#+HEADER: :noweb yes +#+BEGIN_SRC nix +self, nixpkgs, flake-utils +#+END_SRC -,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --curate --output="$SpineOUTversioned" $SpinePOD/* -,#+END_SRC +****** flake outputs for dub2nix -,*** html, curate +#+NAME: flake_outputs_dub2nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +self, nixpkgs, flake-utils, dub2nix-src, d2sqlite3-src, tinyendian-src, dyaml-src, imageformats-src +#+END_SRC -,#+BEGIN_SRC sh -$SpineBIN/spine --verbose --dark --html --html-link-curate --curate --output="$SpineOUTversioned" $SpinePOD/* -$SpineBIN/spine --very-verbose --html --html-link-curate --curate --output="$SpineOUTversioned" $SpinePOD/* -,#+END_SRC +***** flake devshells -,*** composite command: source pod, html, epub, curate, sqlite +#+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 -,#+BEGIN_SRC sh -$SpineBIN/spine --verbose --dark --pod --epub --html --html-link-curate --curate --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/* -,#+END_SRC +***** flake phases -,** sequential tasks -,*** sqlite db (shared) - create db +#+NAME: flake_phases +#+HEADER: :noweb yes +#+BEGIN_SRC nix +buildPhase = '' + runHook preBuild + HOME="$PWD" + for DC_ in dmd ldmd2 ldc2 gdc 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=$DC_ --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 + install -m755 ./bin/spine $out/bin/spine + runHook postInstall +''; +postInstall = '' + echo `ls -la $out/bin/spine` + echo " + nix build or nix develop? (suggestions): + - nix build + nix build .#default --print-build-logs + nix flake update; nix build .#default --print-build-logs + nix build --print-build-logs + - 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 --profile .#default --print-build-logs --command spine -v + nix develop ; eval \"$buildPhase\" + nix develop --build -f derivation.nix -I .envrc --print-build-logs + - nix profile install . --print-build-logs + spine -v + nix-instantiate | nix show-derivation | jq + " + $out/bin/spine -v +''; +#+END_SRC -,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --sqlite-db-create --output="$SpineOUTversioned" -,#+END_SRC +***** flake output default -,*** sqlite db (shared) - populate db +#+NAME: flake_output_default +#+HEADER: :noweb yes +#+BEGIN_SRC nix +packages.x86_64-linux.default = self.packages.x86_64-linux.spine; +#+END_SRC -,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --sqlite-update --output="$SpineOUTversioned" $SpineDOC/spine-markup-samples/markup/pod/* -,#+END_SRC - -,*** sqlite db (shared) - drop db - -,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --sqlite-db-drop --output="$SpineOUTversioned" -,#+END_SRC - -,*** sqlite db (shared) - create & populate db (single step) - -,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --sqlite-db-create --sqlite-update --output="$SpineOUTversioned" $SpinePOD/* -,#+END_SRC - -,*** composite command: source pod, html, epub, curate, sqlite - -,#+BEGIN_SRC sh -$SpineBIN/spine --verbose --no-parallel --dark --pod --epub --html --html-link-curate --curate --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/* -,#+END_SRC - -,** config [./pod/].dr/config_local_site - -,#+BEGIN_SRC sh -cat $SpinePOD/.dr/config_local_site -$SpineBIN/spine --show-config $SpinePOD -$SpineBIN/spine --show-config --output="$SpineOUTversioned" $SpinePOD -,#+END_SRC - -,** cgi operations (output to $SpineOUT /var/www) - -,#+BEGIN_SRC sh -$SpineBIN/spine --very-verbose --sqlite-db-create --output="$SpineOUT" $SpinePOD/* - -$SpineBIN/spine -v --cgi-search-form-codegen --output=$SpineOUT $SpinePOD/* - -$SpineBIN/spine -v --show-config --config=$SpinePOD/.dr - -$SpineBIN/spine --html $SpinePOD/* - - -$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-curate --curate --output=$SpineOUT $SpinePOD/* -,#+END_SRC - -,*** create or re-create sql db (--sqlite-db-create or --sqlite-db-recreate) - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --sqlite-db-create --sqlite-db-filename="<>" --sqlite-db-path="$SpineDBpath" -$SpineBIN/spine -v --sqlite-db-recreate --sqlite-db-filename="<>" --sqlite-db-path="$SpineDBpath" -,#+END_SRC - -,*** populate sqlite db - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --sqlite-update --sqlite-db-filename="<>" --output=$SpineOUT $SpinePOD/* -,#+END_SRC - -,*** generate html (linked to search form), sql output, curate COMPOSITE - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --html --html-link-search --html-link-curate --curate --sqlite-update --sqlite-db-filename="<>" --cgi-sqlite-search-filename="<>" --sqlite-db-path="$SpineDBpath" --output="$SpineOUT" $SpinePOD/* -$SpineBIN/spine --epub --html --html-link-search --html-link-curate --curate --sqlite-update --sqlite-db-filename="spine.search.db" --cgi-sqlite-search-filename="spine_search" --cgi-url-action="https://sisudoc.org/spine_search" --ouput="$SpineOUT" $SpinePOD/* -,#+END_SRC - -,*** generate html (linked to search form), sql output, curate COMPOSITE with resource configuration - -if names and paths are configured in resource configuration file, e.g. $SpinePOD/.rc/config_local_site - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --html --html-link-search --html-link-curate --curate --sqlite-update $SpinePOD/* -,#+END_SRC - -,#+BEGIN_SRC yaml -# sample resource configuration file ( $SpinePOD/.rc/config_local_site ) -output: - path: "/srv/www/spine" -default: - language: "en" - papersize: "a4" - text_wrap: "80" - digest: "sha256" -webserv: - http: "http" - domain: "localhost" - data_http: "http" - data_domain: "localhost" - data_root_url: "https://sisudoc.org" - data_root_path: "/srv/www/spine" - images_root_part: "image" - cgi_search_form_title: "≅ SiSU Spine search" - cgi_http: "https" - cgi_domain: "sisudoc.org" - cgi_bin_url: "http://sisudoc.org/cgi-bin" - cgi_bin_part: "cgi-bin" - cgi_bin_path: "/var/www/cgi/cgi-bin" - cgi_search_script: "<>" - cgi_action: "https://sisudoc.org/spine_search" - db_sqlite_filename: "<>" - db_sqlite_path: "/var/www/sqlite" -,#+END_SRC - -,*** make search form - -,#+BEGIN_SRC sh -$SpineBIN/spine -v --cgi-search-form-codegen --config=$SpinePOD/.dr/config_local_site -,#+END_SRC - -,*** latex - -,#+BEGIN_SRC sh -$SpineBIN/spine --latex --serial --output="$SpineOUT" $SpinePOD/* -ls $SpineOutstatic/latex/*.tex -,#+END_SRC -' >> nixNote_.org - -#cat nixNote_.org - -#echo "emacs nixNote_.org" -#echo "cat nixNote_.org" -#+END_SRC - -*** makefile - -#+HEADER: :tangle ../makefile_ -#+BEGIN_SRC make -buildPhase: - HOME=$${PWD}; \ - for DC_ in dmd ldmd2 gdmd; do \ - echo "- check for D compiler $${DC_}"; \ - DC=$$(type -P $${DC_} || echo ""); \ - if [ ! "$${DC}" == "" ]; then \ - break; \ - fi; \ - done; \ - echo "D compiler = $${DC}"; \ - if [ "$${DC}" == "" ]; then \ - echo "Error: could not find D compiler"; \ - exit 1; \ - fi; \ - echo "$${DC_} used as D compiler to build $${pname}"; \ - export DFLAGS="-O2 -inline"; \ - dub build --compiler=$${DC} --build=release --combined --skip-registry=all; -checkPhase: - runHook preCheck; \ - HOME=$${PWD}; \ - dub test --combined --skip-registry=all; \ - runHook postCheck -installPhase: - runHook preInstall; \ - mkdir -p $${out}/bin; \ - install -m755 ./bin/spine $${out}/bin/spine; \ - runHook postInstall - #cp -r bin/spine $out/bin/. -postInstall: - echo "$${out}/share/cgi-bin"; \ - echo `ls -la $${out}/bin/spine` +#+NAME: flake_output_spine +#+HEADER: :noweb yes +#+BEGIN_SRC nix +packages.x86_64-linux.spine = + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + }; + #targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}"; + in pkgs.stdenv.mkDerivation { + <> + inherit self; + src = self; + #shell = ./shell.nix; + shell = ./default.nix; + devEnv = ./devenv.nix; + <> + buildInputs = [ sqlite ]; + nativeBuildInputs = with pkgs; [ <> dub ]; # [ dmd dub ]; [ ldc dub ]; [ gdc dub ]; + }; #+END_SRC -*** flake :flake: - -- flake.nix - /nixpkgs-ra/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 +***** d-compiler (dmd ldc gdc) -- 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 +- dmd ldc gdc -- nix search --json 2>/dev/null |jq -- nix flake show -- nix show-derivation +#+NAME: d-compiler +#+HEADER: :noweb yes +#+BEGIN_SRC nix +dmd +#+END_SRC -# nix-instantiate | nix-build +***** flake spine dub2nix -#+HEADER: :tangle ../flake.nix +#+NAME: flake_output_spine_dub2nix #+HEADER: :noweb yes #+BEGIN_SRC nix -{ - description = "a sisu like parser and document generator"; - inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.nixpkgs.url = "github:nixos/nixpkgs"; - #inputs.nixpkgs.url = "/nixpkgs-ra/nixpkgs"; - outputs = { self, nixpkgs, flake-utils }: { - packages.x86_64-linux.spine = - let - pkgs = import nixpkgs { - system = "x86_64-linux"; - }; - #targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}"; - in pkgs.stdenv.mkDerivation { - pname = "spine"; - version = "<>"; - description = "a sisu like parser and document generator"; - inherit self; - src = self; - shell = ./shell.nix; - 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 - install -m755 ./bin/spine $out/bin/spine - #cp -r bin/spine $out/bin/. - runHook postInstall - ''; - postInstall = '' - echo `ls -la $out/bin/spine` - echo "" - echo "nix build or nix develop? (suggestions):" - echo '- nix build' - echo ' nix build .#spine --print-build-logs' - echo ' nix build --print-build-logs' - echo '- nix run' - echo ' nix run .#spine --print-build-logs' - echo ' nix run default.nix --print-build-logs' - echo '- nix shell' - echo ' nix shell --print-build-logs --command spine -v' - echo '- nix develop' - echo ' nix develop --build -f derivation.nix -I .envrc --print-build-logs' - echo ' nix develop ; eval "$buildPhase"' - echo 'spine -v' - echo 'nix-instantiate | nix show-derivation | jq' - echo `ls -la $out/bin/spine` - echo "built:" - $out/bin/spine -v - ''; - nativeBuildInputs = with pkgs; [ ldc dub ]; - buildInputs = with pkgs; [ sqlite ]; - }; - packages.x86_64-linux.default = self.packages.x86_64-linux.spine; - }; -} - -#nix flake update -#nix flake check -#nix flake show -#nix develop -#nix build .#default --print-build-logs +packages.x86_64-linux.spine = + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + }; + #targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}"; + in + pkgs.stdenv.mkDerivation { + pname = "spine"; + version = "<>"; + description = "a sisu like parser and document generator"; + inherit self; + src = self; + shell = ./shell.nix; + <> + buildInputs = [ sqlite ]; + nativeBuildInputs = with pkgs; [ dub ldc ]; + }; #+END_SRC +***** flake misc + #+BEGIN_SRC nix src = fetchTarball { url = "file:///[path]/$(pname)-$(version).tar.gz"; sha256 = "sha256:0000000000000000000000000000000000000000000000000000"; }; #+END_SRC + #+HEADER: :noweb yes #+BEGIN_SRC nix { @@ -700,7 +616,7 @@ mkShell { # ### i18n translation related # perl534Packages.Po4a ### candy - starship + #starship ]; shellHook = '' #if [[ -f ".envrc" ]]; then @@ -730,7 +646,7 @@ mkShell { nix build .#default --print-build-logs |& nom - nix run - nix run .#spine --print-build-logs + nix run .#default --print-build-logs nix run default.nix --print-build-logs - nix shell @@ -747,7 +663,7 @@ mkShell { nix-instantiate | nix show-derivation | jq nix-build . --no-out-link | xargs -o nix-tree - nix-tree --derivation .#spine + nix-tree --derivation .#default " #echo "ldc `${pkgs.ldc}/bin/ldc2 -v`" @@ -765,19 +681,19 @@ mkShell { # [ 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 -I nixpkgs=/srv/nix/nixpkgs --pure + # - nix-shell -p "with import /srv/nix/nixpkgs {}; ldc" --pure + # - nix-shell -p "with import /srv/nix/nixpkgs {}; [dub ldc]" --pure # - nix-shell -p nixVersions.unstable #nixFlakes # - nix-shell -p nixFlakes --pure - # - nix-shell -p nixFlakes --pure -p "with import /nixpkgs-ra/nixpkgs {}; [nix dub ldc git ps]" + # - nix-shell -p nixFlakes --pure -p "with import /srv/nix/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 nixpkgs=/srv/nix/nixpkgs # --pure # - nix-build -I .envrc --pure # - nix-build default.nix -I .envrc && result/bin/spine -v @@ -805,18 +721,18 @@ mkShell { # - 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 build .#spine + # - nix build .#default # [ nix run ] # - nix run default.nix --print-build-logs # - nix run -I .envrc default.nix --print-build-logs - # - nix run .#spine + # - nix run .#default # - 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-shell -p nixFlakes --pure -p "with import /srv/nix/nixpkgs {}; [nix dub ldc git ps]" # - nix-build # - nix build `nix-instantiate -I .envrc` @@ -838,13 +754,13 @@ mkShell { - nix-shell --pure -I nixpkgs=<> - nix-shell --pure -p "with import <> {}; ldc" -- nix-shell --pure -p "with import /nixpkgs-ra/nixpkgs {}; [dub ldc]" +- nix-shell --pure -p "with import /srv/nix/nixpkgs {}; [dub ldc]" - shell.nix direnv: export +IN_NIX_SHELL - nix-shell -p nixFlakes - nix-shell -p nixFlakes --pure -- nix-shell -p nixFlakes --pure -p "with import /nixpkgs-ra/nixpkgs {}; [dub ldc]" +- nix-shell -p nixFlakes --pure -p "with import /srv/nix/nixpkgs {}; [dub ldc]" - shell.nix -I .envrc - nix-shell -I nixpkgs= @@ -877,7 +793,7 @@ mkShell { ./result/bin/spine #+END_SRC -**** parts +**** shell parts (packages) ***** packages nix related #+NAME: shell_packages_nix_related @@ -971,32 +887,10 @@ foliate perl534Packages.Po4a #+END_SRC -**** misc - -#+HEADER: :NO-tangle ../shell.nix -#+HEADER: :tangle-mode (identity #o755) -#+HEADER: :shebang "#!/usr/bin/env -S nix-shell" -#+BEGIN_SRC nix -{ pkgs ? import {} }: -pkgs.mkShell { - buildInputs = with pkgs; [ - (import ./nix/pkglst/shell-pkgs.nix { inherit pkgs; }) - ]; - buildPhase = "nix build -f default.nix"; - shellHook = '' - echo "built spine @ ./result/bin/spine" - if [[ -f ".envrc" ]]; then - source .envrc - fi - nix-instantiate | nix show-derivation | jq - ''; -} -#+END_SRC - *** default.nix :default: - default.nix -I nixpkgs= - e.g. default.nix -I nixpkgs=/nixpkgs-ra/nixpkgs + e.g. default.nix -I nixpkgs=/srv/nix/nixpkgs - nix-build -I nixpkgs= e.g. nix-build -I nixpkgs=<> @@ -1023,32 +917,105 @@ nix develop --build -f derivation.nix -I .envrc --print-build-logs #+HEADER: :shebang "#!/usr/bin/env -S nix-build" #+BEGIN_SRC nix { pkgs ? import {} }: -pkgs.callPackage ./derivation.nix {} +pkgs.callPackage ./devenv.nix {} #+END_SRC -*** derivation.nix :default: +* devEnv -#+HEADER: :tangle ../derivation.nix +nix profile install . + +#+HEADER: :tangle ../devenv.nix #+HEADER: :tangle-mode (identity #o644) #+HEADER: :noweb yes #+BEGIN_SRC nix -{ pkgs ? import {}, - stdenv ? pkgs.stdenv, - lib ? pkgs.lib, - ldc ? null, - dcompiler ? pkgs.ldc, - dub ? pkgs.dub -}: -assert dcompiler != null; -with ( - 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 ]; +# profile.nix +{ pkgs ? import { }, name ? "user-env" }: with pkgs; +buildEnv { + inherit name; + extraOutputsToInstall = [ "out" "man" "lib" ]; # to get all needed symlinks + paths = [ + #nix # if not on NixOS, this is needed + direnv + nixVersions.unstable #nixFlakes + nix-prefetch-git + validatePkgConfig + nix-tree jq nix-output-monitor + git + ps + ### d_build_related + dub + ## compiler + dmd + ldc + #gdc + #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 + # this will create a script that will rebuild and upgrade your setup; using shell script syntax + (writeScriptBin "nix-rebuild" '' + #!${stdenv.shell} + cd || exit 1 + nix flake update + nix profile upgrade '.*' + '') + # puts in your root the nixpkgs version + (writeTextFile { + name = "nixpkgs-version"; + destination = "/nixpkgs-version"; + text = lib.version; + }) + ]; +} +#+END_SRC + +*** derivation.nix :default: + +#+HEADER: :tangle ../derivation.nix +#+HEADER: :tangle-mode (identity #o644) +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ pkgs ? import {}, + stdenv ? pkgs.stdenv, + lib ? pkgs.lib, + ldc ? null, + dcompiler ? pkgs.ldc, + dub ? pkgs.dub +}: +assert dcompiler != null; +with ( + 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 ({ @@ -1119,7 +1086,7 @@ mkDubDerivation rec { meta = with pkgs.lib; { description = "A sisu like parser and document generator"; longDescription = '' - A sisu like parser and document generator + a sisu like parser and document generator ''; homepage = "https://sisudoc.org"; license = licenses.agpl3Plus; @@ -1370,7 +1337,7 @@ github:nixos/nixpkgs #+NAME: nixpkgs_path_local #+BEGIN_SRC nix -/nixpkgs-ra/nixpkgs +/srv/nix/nixpkgs #+END_SRC **** project path options @@ -1452,3 +1419,329 @@ fc-query DejaVuSans.ttf | grep '^\s\+family:' | cut -d'"' -f2 $XDG_DATA_HOME/fonts ~/.local/share/fonts #+END_SRC + +** NOTES +*** nix-shell + +- default.nix + +#+BEGIN_SRC sh +nix-shell +nix-build +#+END_SRC + +- project.nix + +#+BEGIN_SRC sh +nix-shell +nix-build project.nix +#+END_SRC + +*** nix-shell --pure + +- default.nix + +#+HEADER: :noweb yes +#+BEGIN_SRC sh +nix-shell --pure +nix-build -I nixpkgs=<> +nix-build -I .envrc +#+END_SRC + +#+BEGIN_SRC sh +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 build -f project.nix +# nix build -f spine.nix +nix develop --build -f derivation.nix -I .envrc --print-build-logs +nix develop --profile .#default --print-build-logs --command spine -v +#+END_SRC + +*** derivation .drv + +#+BEGIN_SRC sh +nix show-derivation /nix/store/q7n14bm8j5vzm62qaraczdb4bpyf59vv-spine-0.11.1.drv +#+END_SRC + +**** .env/echo-nixNote CHECK MODIFY + +#+HEADER: :tangle ../.env/echo-nixNote +#+BEGIN_SRC sh +echo '-*- mode: org -*- + +,* nixpkgs path? + + # eval "$(nix print-dev-env)" +' > nixNote_.org + +echo " == `nix-instantiate --find-file nixpkgs`" >> nixNote_.org + +echo ' +,* nix build and show derivation + +,#+BEGIN_SRC sh +nix-shell --pure + +nix-build +nix build -f default.nix --print-build-logs +nix shell -f default.nix --print-build-logs +nix develop --build -f derivation.nix -I .envrc --print-build-logs + +nix-instantiate | nix-build + +nix-instantiate -I .envrc | nix-build -I .envrc +nix build `nix-instantiate` +nix build `nix-instantiate -I .envrc` + +nix develop + +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 search --json 2>/dev/null |jq +,#+END_SRC + +,* version and build info + +,#+BEGIN_SRC sh' >> nixNote_.org + +echo 'spine version (git) == $SpineVER' >> nixNote_.org +echo "spine version (git) == $SpineVER" >> nixNote_.org +echo 'nix-instantiate == `nix-instantiate`' >> nixNote_.org +echo "nix-instantiate == `nix-instantiate`" >> nixNote_.org + +echo "#+END_SRC + +,* initialised shell variables + +,#+BEGIN_SRC sh +SpineSRC=$SpineSRC +SpineDOC=$SpineDOC +SpinePOD=$SpinePOD +SpineOUTversioned=$SpineOUTversioned +SpineOUT=$SpineOUT +,#+END_SRC +" >> nixNote_.org + +echo '* spine run instruction examples +,** parallelized tasks +,*** doc source + +,#+BEGIN_SRC sh +$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" $SpinePOD/* +,#+END_SRC + +,*** sqlite db for each document - populate each db + +,#+BEGIN_SRC sh +$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" $SpinePOD/* +,#+END_SRC + +,*** curate (authors topics) + +,#+BEGIN_SRC sh +$SpineBIN/spine --very-verbose --curate --output="$SpineOUTversioned" $SpinePOD/* +,#+END_SRC + +,*** html, curate + +,#+BEGIN_SRC sh +$SpineBIN/spine --verbose --dark --html --html-link-curate --curate --output="$SpineOUTversioned" $SpinePOD/* +$SpineBIN/spine --very-verbose --html --html-link-curate --curate --output="$SpineOUTversioned" $SpinePOD/* +,#+END_SRC + +,*** composite command: source pod, html, epub, curate, sqlite + +,#+BEGIN_SRC sh +$SpineBIN/spine --verbose --dark --pod --epub --html --html-link-curate --curate --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/* +,#+END_SRC + +,** sequential tasks +,*** sqlite db (shared) - create db + +,#+BEGIN_SRC sh +$SpineBIN/spine --very-verbose --sqlite-db-create --output="$SpineOUTversioned" +,#+END_SRC + +,*** sqlite db (shared) - populate db + +,#+BEGIN_SRC sh +$SpineBIN/spine --very-verbose --sqlite-update --output="$SpineOUTversioned" $SpineDOC/spine-markup-samples/markup/pod/* +,#+END_SRC + +,*** sqlite db (shared) - drop db + +,#+BEGIN_SRC sh +$SpineBIN/spine --very-verbose --sqlite-db-drop --output="$SpineOUTversioned" +,#+END_SRC + +,*** sqlite db (shared) - create & populate db (single step) + +,#+BEGIN_SRC sh +$SpineBIN/spine --very-verbose --sqlite-db-create --sqlite-update --output="$SpineOUTversioned" $SpinePOD/* +,#+END_SRC + +,*** composite command: source pod, html, epub, curate, sqlite + +,#+BEGIN_SRC sh +$SpineBIN/spine --verbose --no-parallel --dark --pod --epub --html --html-link-curate --curate --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/* +,#+END_SRC + +,** config [./pod/].dr/config_local_site + +,#+BEGIN_SRC sh +cat $SpinePOD/.dr/config_local_site +$SpineBIN/spine --show-config $SpinePOD +$SpineBIN/spine --show-config --output="$SpineOUTversioned" $SpinePOD +,#+END_SRC + +,** cgi operations (output to $SpineOUT /var/www) + +,#+BEGIN_SRC sh +$SpineBIN/spine --very-verbose --sqlite-db-create --output="$SpineOUT" $SpinePOD/* + +$SpineBIN/spine -v --cgi-search-form-codegen --output=$SpineOUT $SpinePOD/* + +$SpineBIN/spine -v --show-config --config=$SpinePOD/.dr + +$SpineBIN/spine --html $SpinePOD/* + + +$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-curate --curate --output=$SpineOUT $SpinePOD/* +,#+END_SRC + +,*** create or re-create sql db (--sqlite-db-create or --sqlite-db-recreate) + +,#+BEGIN_SRC sh +$SpineBIN/spine -v --sqlite-db-create --sqlite-db-filename="<>" --sqlite-db-path="$SpineDBpath" +$SpineBIN/spine -v --sqlite-db-recreate --sqlite-db-filename="<>" --sqlite-db-path="$SpineDBpath" +,#+END_SRC + +,*** populate sqlite db + +,#+BEGIN_SRC sh +$SpineBIN/spine -v --sqlite-update --sqlite-db-filename="<>" --output=$SpineOUT $SpinePOD/* +,#+END_SRC + +,*** generate html (linked to search form), sql output, curate COMPOSITE + +,#+BEGIN_SRC sh +$SpineBIN/spine -v --html --html-link-search --html-link-curate --curate --sqlite-update --sqlite-db-filename="<>" --cgi-sqlite-search-filename="<>" --sqlite-db-path="$SpineDBpath" --output="$SpineOUT" $SpinePOD/* +$SpineBIN/spine --epub --html --html-link-search --html-link-curate --curate --sqlite-update --sqlite-db-filename="spine.search.db" --cgi-sqlite-search-filename="spine_search" --cgi-url-action="https://sisudoc.org/spine_search" --ouput="$SpineOUT" $SpinePOD/* +,#+END_SRC + +,*** generate html (linked to search form), sql output, curate COMPOSITE with resource configuration + +if names and paths are configured in resource configuration file, e.g. $SpinePOD/.rc/config_local_site + +,#+BEGIN_SRC sh +$SpineBIN/spine -v --html --html-link-search --html-link-curate --curate --sqlite-update $SpinePOD/* +,#+END_SRC + +,#+BEGIN_SRC yaml +# sample resource configuration file ( $SpinePOD/.rc/config_local_site ) +output: + path: "/srv/www/spine" +default: + language: "en" + papersize: "a4" + text_wrap: "80" + digest: "sha256" +webserv: + http: "http" + domain: "localhost" + data_http: "http" + data_domain: "localhost" + data_root_url: "https://sisudoc.org" + data_root_path: "/srv/www/spine" + images_root_part: "image" + cgi_search_form_title: "≅ SiSU Spine search" + cgi_http: "https" + cgi_domain: "sisudoc.org" + cgi_bin_url: "http://sisudoc.org/cgi-bin" + cgi_bin_part: "cgi-bin" + cgi_bin_path: "/var/www/cgi/cgi-bin" + cgi_search_script: "<>" + cgi_action: "https://sisudoc.org/spine_search" + db_sqlite_filename: "<>" + db_sqlite_path: "/var/www/sqlite" +,#+END_SRC + +,*** make search form + +,#+BEGIN_SRC sh +$SpineBIN/spine -v --cgi-search-form-codegen --config=$SpinePOD/.dr/config_local_site +,#+END_SRC + +,*** latex + +,#+BEGIN_SRC sh +$SpineBIN/spine --latex --serial --output="$SpineOUT" $SpinePOD/* +ls $SpineOutstatic/latex/*.tex +,#+END_SRC +' >> nixNote_.org + +#cat nixNote_.org + +#echo "emacs nixNote_.org" +#echo "cat nixNote_.org" +#+END_SRC + +*** makefile + +#+HEADER: :tangle ../makefile_ +#+BEGIN_SRC make +buildPhase: + HOME=$${PWD}; \ + for DC_ in dmd ldmd2 gdmd; do \ + echo "- check for D compiler $${DC_}"; \ + DC=$$(type -P $${DC_} || echo ""); \ + if [ ! "$${DC}" == "" ]; then \ + break; \ + fi; \ + done; \ + echo "D compiler = $${DC}"; \ + if [ "$${DC}" == "" ]; then \ + echo "Error: could not find D compiler"; \ + exit 1; \ + fi; \ + echo "$${DC_} used as D compiler to build $${pname}"; \ + export DFLAGS="-O2 -inline"; \ + dub build --compiler=$${DC} --build=release --combined --skip-registry=all; +checkPhase: + runHook preCheck; \ + HOME=$${PWD}; \ + dub test --combined --skip-registry=all; \ + runHook postCheck +installPhase: + runHook preInstall; \ + mkdir -p $${out}/bin; \ + install -m755 ./bin/spine $${out}/bin/spine; \ + runHook postInstall + #cp -r bin/spine $out/bin/. +postInstall: + echo "$${out}/share/cgi-bin"; \ + echo `ls -la $${out}/bin/spine` +#+END_SRC -- cgit v1.2.3