From 2dd7bcc4e0a068ab2ad56b38775b2fe7d094e724 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 27 Jan 2023 14:02:44 -0500 Subject: nix flake & build, devShells etc. --- flake.nix | 77 ++++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 25 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 72a8e05..6c6c331 100644 --- a/flake.nix +++ b/flake.nix @@ -2,12 +2,12 @@ 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 = "0.12.0"; 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. @@ -24,24 +24,6 @@ ''; postInstall = '' echo `ls -la $out/share/cgi-bin/spine_search` - 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 - nix-instantiate | nix show-derivation | jq - " ''; in { packages = forAllSystems (system: @@ -130,12 +112,57 @@ inherit postInstall; }; #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; - }); + }); devShells = forAllSystems (system: - let pkgs = nixpkgsFor.${system}; + let + 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 { }; - #devShell = mkShell { buildInputs = [ git dub dmd ldc gdc sqlite ]; }; - }); + 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; + }; + }); }; } -- cgit v1.2.3