summaryrefslogtreecommitdiffhomepage
path: root/org/config_nix.org
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2023-01-27 14:02:44 -0500
committerRalph Amissah <ralph.amissah@gmail.com>2023-01-27 23:23:32 -0500
commit2dd7bcc4e0a068ab2ad56b38775b2fe7d094e724 (patch)
tree98833e184c204e3d4b9bf87f139a50e7a7d787d8 /org/config_nix.org
parentnix & build housekeeping (diff)
nix flake & build, devShells etc.
Diffstat (limited to 'org/config_nix.org')
-rw-r--r--org/config_nix.org207
1 files changed, 96 insertions, 111 deletions
diff --git a/org/config_nix.org b/org/config_nix.org
index 9af553c..5950ee9 100644
--- a/org/config_nix.org
+++ b/org/config_nix.org
@@ -81,37 +81,37 @@ nix show-derivation /nix/store/q7n14bm8j5vzm62qaraczdb4bpyf59vv-spine-0.11.1.drv
use flake .
#use flake .#default
NIX_ENFORCE_PURITY=1
-NixDirEnvVersion="2.2.0"
+NixDirEnvVersion="2.2.1"
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="
+ source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi
watch_file flake.lock
watch_file flake.nix
-nix flake update && nix flake check --show-trace && nix flake show
+#nix flake update && nix flake check --show-trace && nix flake show
if [ -f .envrc-local ]; then
source_env_if_exists .envrc-local || source .envrc-local
fi
-echo "
-
-- nix flake update && nix flake check --show-trace && nix flake show && nix develop .#devShell
-
-- nix build .#default --print-build-logs
-- nix build .#spine-search-ldc --print-build-logs
-- nix build .#spine-search-dmd --print-build-logs
-- nix build .#spine-search-gdc --print-build-logs
-
-nix-shell '<nixpkgs>' -A nix --pure
-
-nix run .#default --print-build-logs
-
-nix develop --build .#default --print-build-logs
-
-nix shell .#default --print-build-logs --command spine -v
-nix shell .#default --print-build-logs --command spine --very-verbose --epub --html --html-link-search --html-link-curate --curate --output=\"\$SpineOUT\" ./markup/pod
-nix shell .#default --print-build-logs --command spine --very-verbose --html --html-link-search --html-link-curate --curate --sqlite-update --sqlite-db-filename=\"spine.search.db\" --cgi-sqlite-search-filename=\"spine_search\" --sqlite-db-path=\"\$SpineDBpath\" --output=\"\$SpineOUT\" ./markup/pod
-"
+# echo "
+#
+# - nix flake update && nix flake check --show-trace && nix flake show && nix develop .#devShell
+#
+# - nix build .#default --print-build-logs
+# - nix build .#spine-search-ldc --print-build-logs
+# - nix build .#spine-search-dmd --print-build-logs
+# - nix build .#spine-search-gdc --print-build-logs
+#
+# nix-shell '<nixpkgs>' -A nix --pure
+#
+# nix run .#default --print-build-logs
+#
+# nix develop --build .#default --print-build-logs
+#
+# nix shell .#default --print-build-logs --command spine -v
+# nix shell .#default --print-build-logs --command spine --very-verbose --epub --html --html-link-search --html-link-curate --curate --output=\"\$SpineOUT\" ./markup/pod
+# nix shell .#default --print-build-logs --command spine --very-verbose --html --html-link-search --html-link-curate --curate --sqlite-update --sqlite-db-filename=\"spine.search.db\" --cgi-sqlite-search-filename=\"spine_search\" --sqlite-db-path=\"\$SpineDBpath\" --output=\"\$SpineOUT\" ./markup/pod
+# "
#+END_SRC
**** .envrc-local CHECK MODIFY
@@ -121,23 +121,19 @@ nix shell .#default --print-build-logs --command spine --very-verbose --html --h
#+HEADER: :tangle ../.envrc-local_
#+HEADER: :noweb yes
#+BEGIN_SRC sh
-export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos
+#export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos
+#export NIX_PATH=/srv/nix/nixpkgs
#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 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/doc-reform/code/software/spine-search
-export SpineSRC=$SpinePROJ/src
-#export SpineBIN=$SpinePROJ/result/bin
export SpineDOC=~/grotto/repo/git.repo/projects/project-spine/doc-reform-markup/spine-markup-samples
-export SpinePOD=$SpineDOC/markup/pod
-#export SpineOUTversioned=/srv/www/spine/$SpineVER
export SpineOUT=/srv/www/spine
export SpineDBpath=/var/www/sqlite
-export SpineCgiBIN=/var/www/cgi/cgi-bin
+#export SpineDBpath=/srv/www/spine/sqlite
+export SpineCGIbin=/var/www/cgi/cgi-bin
+export SpineCGIform='spine_search'
+export SpineSQLdb='spine.search.db'
#+END_SRC
*** makefile
@@ -188,16 +184,29 @@ postInstall:
description = "a sisu like document parser search form";
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 }:
+ outputs = { self, nixpkgs, flake-utils } @inputs:
let
pname = "spine_search";
version = "<<spine_version_set>>";
shell = ./shell.nix; # ./default.nix;
- devEnv = ./shell.nix; # ./default.nix;
+ devEnv = ./.envrc; # ./shell.nix; # ./default.nix;
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.
- <<flake_phases_other_than_buildPhase>>
+ checkPhase = ''
+ runHook preCheck
+ dub test --combined --skip-registry=all
+ runHook postCheck
+ '';
+ installPhase = ''
+ runHook preInstall
+ mkdir -p $out/share/cgi-bin
+ install -m755 -D ./cgi-bin/spine_search $out/share/cgi-bin/spine_search
+ runHook postInstall
+ '';
+ postInstall = ''
+ echo `ls -la $out/share/cgi-bin/spine_search`
+ '';
in {
packages = forAllSystems (system:
let pkgs = nixpkgsFor.${system};
@@ -285,81 +294,57 @@ postInstall:
inherit postInstall;
};
#vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000=";
- });
+ });
devShells = forAllSystems (system:
- let pkgs = nixpkgsFor.${system};
- in with pkgs; {
- devShell = mkShell { };
- #devShell = mkShell { buildInputs = [ git dub dmd ldc gdc sqlite ]; };
- });
- };
-}
-#+END_SRC
-
-**** flakes
-***** flake single system
-
-#+NAME: flake_single_sytem
-#+HEADER: :noweb yes
-#+BEGIN_SRC nix
-{
- description = "a sisu like document parser search form";
- inputs.<<flake_inputs_nix>>
- outputs = { <<flake_outputs>> }: {
- packages.x86_64-linux.spine_search =
- let
- pkgs = import nixpkgs {
- system = "x86_64-linux";
- };
- #targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}";
- in pkgs.stdenv.mkDerivation {
- <<flake_metadata>>
- inherit self;
- src = self;
- #shell = ./shell.nix;
- shell = ./default.nix;
- devEnv = ./devenv.nix;
- <<flake_phases>>
- buildInputs = [ sqlite ];
- nativeBuildInputs = with pkgs; [ dub ldc ];
- };
- packages.x86_64-linux.default = self.packages.x86_64-linux.spine_search;
- };
-}
-#+END_SRC
-
-***** flake (multi-system)
-
-#+NAME: flake_multi_system_possible
-#+HEADER: :noweb yes
-#+BEGIN_SRC nix
-{
- description = "a sisu like document parser search form";
- inputs.<<flake_inputs_nix>>
- outputs = { <<flake_outputs>> }:
- let
- version = "<<spine_version_set>>";
- 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.
- <<flake_devshells>>
- in {
- packages = forAllSystems (system:
let
- pkgs = nixpkgsFor.${system};
- in {
- default = pkgs.stdenv.mkDerivation {
- pname = "spine_search";
- inherit version;
- src = self;
- shell = ./default.nix;
- devEnv = ./devenv.nix;
- buildInputs = [ sqlite ];
- nativeBuildInputs = with pkgs; [ dub ldc ]; # [ dub dmd ]; [ dub ldc ]; [ dub gdc ];
- <<flake_phases>>
+ pkgs = nixpkgsFor.${system};
+ shellHook = ''
+ export DFLAGS="-O2 -inline -boundscheck=on -color=on"
+ 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')
+ ### set local values in .envrc-local (or modify here if you must)
+ # export SpinePROJ=~/grotto/repo/git.repo/projects/doc-reform/code/software/spine
+ # export SpineDOC=~/grotto/repo/git.repo/projects/project-spine/doc-reform-markup/spine-markup-samples
+ # export SpineOUT=/srv/www/spine
+ export SpineDBpath=/var/www/sqlite
+ # export SpineDBpath=/srv/www/spine/sqlite
+ export SpineSRC=$SpinePROJ/src
+ export SpineBIN=$SpinePROJ/result/bin
+ export SpinePOD=$SpineDOC/markup/pod
+ 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_GIT="`git describe --long --tags | sed -e 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g'`"
+ export spineNixHelp="cat ./.env/nix-commands"
+ export spineHtml="spine --very-verbose --html --html-link-search --html-link-curate --curate --sqlite-update --sqlite-db-filename=\"spine.search.db\" --cgi-sqlite-search-filename=\"spine_search\" --sqlite-db-path=\"\$SpineDBpath\" --output=\"\$SpineOUT\" $SpinePOD/*"
+ export spineSqliteCreateDB="spine --very-verbose --sqlite-db-recreate --sqlite-db-path=\"$SpineDBpath\" --sqlite-db-filename=\"spine.search.db\""
+ export spineSqlite="spine --very-verbose --sqlite-discrete --sqlite-db-path=\"$SpineDBpath\" --sqlite-db-filename=\"spine.search.db\" --output=\"\$SpineOUT\" $SpinePOD/*"
+ #export spineSqlite="spine --very-verbose --sqlite-update --sqlite-db-path=\"$SpineDBpath\" --sqlite-db-filename=\"spine.search.db\" --output=\"\$SpineOUT\" $SpinePOD/*"
+ '';
+ in with pkgs; {
+ devShell = mkShell rec {
+ name = "spine dev shell default";
+ inherit shell;
+ inherit devEnv;
+ #buildInputs = [ sqlite ];
+ #nativeBuildInputs = [ dub dmd ldc gdc gnumake ];
+ packages = [
+ sqlite
+ dub dmd ldc gdc gnumake
+ ];
+ inherit shellHook;
+ };
+ devShell-sqlite = mkShell rec {
+ name = "spine dev shell for latex & pdf output";
+ inherit shell;
+ inherit devEnv;
+ packages = [
+ sqlite
+ dub dmd ldc gdc gnumake
+ ];
+ inherit shellHook;
};
- #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000=";
});
};
}
@@ -403,7 +388,6 @@ postInstall:
#nix develop
#nix build .#default --print-build-logs
-
#+BEGIN_SRC nix
src = fetchTarball {
url = "file:///[path]/$(pname)-$(version).tar.gz";
@@ -446,11 +430,11 @@ self, nixpkgs, flake-utils
#+NAME: flake_devshells
#+HEADER: :noweb yes
#+BEGIN_SRC nix
-devShells = forAllSystems (system:
- let pkgs = nixpkgsFor.${system};
+devShells = forAllSystems (system:
+ let pkgs = nixpkgsFor.${system};
in {
default = pkgs.mkShell {
- buildInputs = with pkgs; [ git dub dmd ldc sqlite ];
+ buildInputs = with pkgs; [ git dub dmd ldc sqlite ];
};
});
#+END_SRC
@@ -531,6 +515,7 @@ mkShell {
validatePkgConfig
nix-tree jq nix-output-monitor
git
+ gnumake
ps
### d_build_related
dub