From 970eea0a508d3a0a1f8c9e01c3667ceedaa5fb0f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 26 Jan 2023 21:16:47 -0500 Subject: nix flake & build, devShells etc. --- flake.nix | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 116 insertions(+), 25 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 73321ae..9e132d5 100644 --- a/flake.nix +++ b/flake.nix @@ -2,12 +2,12 @@ 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 }: + outputs = { self, nixpkgs, flake-utils } @inputs: let pname = "spine"; 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,25 +24,6 @@ ''; 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 ''; in { @@ -133,7 +114,7 @@ inherit postInstall; }; #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; - }); + }); apps = forAllSystems (system: { default = { type = "app"; @@ -141,9 +122,119 @@ }; }); 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 SpineOUTversioned=$SpineOUT/$SpineVER + 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 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'`" + export spineNixHelp="cat ./.env/nix-commands" + export spineTest="nix shell .#default --print-build-logs --command spine --very-verbose --epub --html --html-link-search --html-link-curate --curate --output=\"\$SpineOUT\" $SpinePOD/*" + 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 spineEpub="spine --very-verbose --epub --output=\"\$SpineOUT\" $SpinePOD/*" + export spineLatex="spine --very-verbose --latex --output=\"\$SpineOUT\" $SpinePOD/*" + export spinePdf="spine --very-verbose --pdf --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 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-epub = mkShell rec { + name = "spine dev shell for epub output"; + inherit shell; + inherit devEnv; + packages = [ + dub dmd ldc gdc gnumake + sqlite + libxml2 + html-tidy + xmlstarlet + epubcheck + ebook_tools + libxml2 + html-tidy + xmlstarlet + epubcheck + ebook_tools + epr + sigil + calibre #(suite includes: ebook-viewer) + foliate + ]; + inherit shellHook; + }; + devShell-html = mkShell rec { + name = "spine dev shell for latex & pdf output"; + inherit shell; + inherit devEnv; + packages = [ + dub dmd ldc gdc gnumake + sqlite + ]; + inherit shellHook; + }; + devShell-latex-pdf = mkShell rec { + name = "spine dev shell for latex & pdf output"; + inherit shell; + inherit devEnv; + packages = [ + dub dmd ldc gdc gnumake + sqlite + source-sans-pro + source-serif-pro + source-code-pro + texlive.combined.scheme-full + ]; + inherit shellHook; + }; + devShell-sqlite = mkShell rec { + name = "spine dev shell for latex & pdf output"; + inherit shell; + inherit devEnv; + packages = [ + dub dmd ldc gdc gnumake + sqlite + ]; + inherit shellHook; + }; + devShell-i18n = mkShell { + inherit shell; + inherit devEnv; + packages = [ + dub dmd ldc gdc gnumake + sqlite + perl534Packages.Po4a + ]; + inherit shellHook; + }; + }); }; } -- cgit v1.2.3