diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-04-07 00:18:26 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-04-07 00:18:26 -0400 |
| commit | 5a10ef80aa457078075ef55254ffc5264e6875b3 (patch) | |
| tree | b284aafb8c4d48802cb09a879cefa93d40941fb4 /org | |
| parent | latex minor improvements and fixes, require testing (diff) | |
nix cleanup flake.nix and shell.nix
Diffstat (limited to 'org')
| -rw-r--r-- | org/config_nix.org | 582 |
1 files changed, 191 insertions, 391 deletions
diff --git a/org/config_nix.org b/org/config_nix.org index 59a052b..7d1f6a7 100644 --- a/org/config_nix.org +++ b/org/config_nix.org @@ -24,25 +24,16 @@ { description = "a sisu like parser & document generator"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - #inputs.flake-utils.url = "github:numtide/flake-utils"; outputs = { self, nixpkgs, - #flake-utils, ... }@inputs: let pname = "spine"; version = "<<spine_version>>"; - shell = ./shell.nix; - devEnv = ./nixDevEnv.sh; 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 - checkPhase = '' - runHook preCheck - dub test --combined --skip-registry=all - runHook postCheck - ''; localOverlay = (final: prev: { ldc = prev.callPackage ./nix-overlays/ldc { }; # -> ok <<ldc_version>> dmd = prev.callPackage ./nix-overlays/dmd { }; # -> ok <<dmd_version>> @@ -56,174 +47,108 @@ ]; inherit system; }; - preBuild = '' - export HOME=$TMPDIR - #export HOME=$(pwd) - ''; - installPhase = '' - runHook preInstall - mkdir -p $out/bin - install -m755 ./bin/spine $out/bin/spine - runHook postInstall - ''; - postInstall = '' - echo "❯❯ ./result/bin/spine -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=./OUTPUT_TEST_sisudocSpine ../sisu-spine-samples/markup/pod/*"; - echo `ls -la $out/bin/spine` - echo "❯❯ spine-v${version} (rev: ${self.shortRev or "unknown"})" - $out/bin/spine -v + mkSpine = { pkgs, compilerPkg, compilerBin, buildType }: pkgs.stdenv.mkDerivation { + inherit pname version; + meta.mainProgram = "spine"; + executable = true; # not used + src = self; + buildInputs = [ pkgs.sqlite ]; + nativeBuildInputs = [ pkgs.dub compilerPkg pkgs.gnumake ]; + preBuild = '' + export HOME=$TMPDIR + ''; + buildPhase = '' + runHook preBuild + buildCMD="dub run --cache=local --compiler=$(type -P ${compilerBin}) --build=${buildType} --combined --skip-registry=all" + echo $buildCMD + $buildCMD + echo $buildCMD + runHook postBuild + ''; + checkPhase = '' + runHook preCheck + 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 "❯❯ ./result/bin/spine -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=./OUTPUT_TEST_sisudocSpine ../sisu-spine-samples/markup/pod/*"; + echo `ls -la $out/bin/spine` + echo "❯❯ spine-v${version} (rev: ${self.shortRev or "unknown"})" + $out/bin/spine -v + ''; + }; + shellHook = '' + #export Date=`date "+%Y%m%d"` + ## set local values in .envrc-local (or here if you must) + echo '❯❯ nix build'; + ## ImPure Nix environment + SpineGitVer=`git describe | sed "s/^[a-z_-]\+\([0-9.]\+\)/\1/" | sed "s/\([^-]*-g\)/r\1/" | sed "s/-/./g"` && \ + SpineGitBranch=`git branch --show-current` && \ + echo "❯❯ spine-v${version} - ($SpineGitBranch: $SpineGitVer)" + ## Pure Nix environment - version info from flake inputs + #echo "❯❯ spine-v${version} (rev: ${self.shortRev or "unknown"})" + echo '❯❯ $SpineBIN -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=$SpineOUT $SpinePOD/*'; + echo "❯❯ $SpineBIN -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=$SpineOUT $SpinePOD/*"; + echo '❯❯ nix flake update && nix flake check && nix flake show'; ''; + mkDevShell = { pkgs, name, compiler, extraPackages ? [] }: pkgs.mkShell { + inherit name shellHook; + packages = [ + pkgs.direnv + pkgs.nix-direnv + compiler + pkgs.dub + pkgs.dtools + pkgs.gnumake + pkgs.sqlite + pkgs.gnugrep + pkgs.gnused + pkgs.ripgrep + ] ++ extraPackages; + }; in { packages = forAllSystems (system: let pkgs-ovl = pkgsForSystem system; pkgs-nix = nixpkgsFor.${system}; - in - with pkgs-nix; { - default = stdenv.mkDerivation { - inherit pname; - inherit version; - meta.mainProgram = "spine"; - executable = true; - src = self; - inherit shell; - inherit devEnv; - buildInputs = [sqlite]; - nativeBuildInputs = [dub ldc gnumake]; - buildPhase = '' - runHook preBuild - 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" - buildCMD="dub run --cache=local --compiler=$DC --build=$DC_ --combined --skip-registry=all" - echo $buildCMD - $buildCMD - echo $buildCMD - runHook postBuild - ''; - inherit preBuild; - inherit checkPhase; - inherit installPhase; - inherit postInstall; - }; - spine-nixpkgs-dmd = stdenv.mkDerivation { - inherit pname; - inherit version; - meta.mainProgram = "spine-dmd"; - executable = true; - src = self; - inherit shell; - inherit devEnv; - buildInputs = with pkgs-nix; [sqlite]; - nativeBuildInputs = with pkgs-nix; [dub dmd gnumake]; - buildPhase = '' - runHook preBuild - buildCMD="dub run --cache=local --compiler=$(type -P dmd) --build=dmd --combined --skip-registry=all" - echo $buildCMD - $buildCMD - echo $buildCMD - runHook postBuild - ''; - inherit preBuild; - inherit checkPhase; - inherit installPhase; - inherit postInstall; - }; - spine-nixpkgs-ldc = stdenv.mkDerivation { - inherit pname; - inherit version; - meta.mainProgram = "spine-ldc"; - executable = true; - src = self; - inherit shell; - inherit devEnv; - buildInputs = with pkgs-nix; [sqlite]; - nativeBuildInputs = with pkgs-nix; [dub ldc gnumake]; - buildPhase = '' - runHook preBuild - buildCMD="dub run --cache=local --compiler=$(type -P ldmd2) --build=ldmd2 --combined --skip-registry=all" - echo $buildCMD - $buildCMD - echo $buildCMD - runHook postBuild - ''; - inherit preBuild; - inherit checkPhase; - inherit installPhase; - inherit postInstall; - }; - spine-overlay-dmd = stdenv.mkDerivation { - inherit pname; - inherit version; - #name = "spine-<<spine_version>> dmd-<<dmd_version>> dub-<<dub_version>>"; - meta.mainProgram = "spine-dmd"; - executable = true; - src = self; - inherit shell; - inherit devEnv; - buildInputs = with pkgs-ovl; [sqlite]; - nativeBuildInputs = with pkgs-ovl; [dub dmd gnumake]; - buildPhase = '' - runHook preBuild - buildCMD="dub run --cache=local --compiler=$(type -P dmd) --build=dmd --combined --skip-registry=all" - echo $buildCMD - $buildCMD - echo $buildCMD - runHook postBuild - ''; - inherit preBuild; - inherit checkPhase; - inherit installPhase; - inherit postInstall; - }; - spine-overlay-ldc = stdenv.mkDerivation { - inherit pname; - inherit version; - #name = "spine-<<spine_version>> ldc-<<ldc_version>> dub-<<dub_version>>"; - meta.mainProgram = "spine-ldc"; - executable = true; - src = self; - inherit shell; - inherit devEnv; - buildInputs = with pkgs-ovl; [sqlite]; - nativeBuildInputs = with pkgs-ovl; [dub ldc gnumake]; - buildPhase = '' - runHook preBuild - buildCMD="dub run --cache=local --compiler=$(type -P ldmd2) --build=ldmd2 --combined --skip-registry=all" - echo $buildCMD - $buildCMD - echo $buildCMD - runHook postBuild - ''; - inherit preBuild; - inherit checkPhase; - inherit installPhase; - inherit postInstall; - }; - #spine-overlay-gdc = stdenv.mkDerivation { - # inherit pname; - # inherit version; - # meta.mainProgram = "spine-gdc"; - # executable = true; - # src = self; - # inherit shell; - # inherit devEnv; - # buildInputs = with pkgs-ovl; [ sqlite ]; - # nativeBuildInputs = with pkgs-ovl; [ dub gdc gnumake ]; - # buildPhase = '' - # runHook preBuild - # dub run --cache=local --compiler=$(type -P gdc) --build=gdc --combined --skip-registry=all - # runHook postBuild - # ''; - # inherit preBuild; - # inherit checkPhase; - # inherit installPhase; - # inherit postInstall; - #}; - #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; - }); + in { + default = self.packages.${system}.spine-nixpkgs-ldc; + spine-nixpkgs-dmd = mkSpine { + pkgs = pkgs-nix; + compilerPkg = pkgs-nix.dmd; + compilerBin = "dmd"; + buildType = "dmd"; + }; + spine-nixpkgs-ldc = mkSpine { + pkgs = pkgs-nix; + compilerPkg = pkgs-nix.ldc; + compilerBin = "ldmd2"; + buildType = "ldmd2"; + }; + spine-overlay-dmd = mkSpine { + pkgs = pkgs-ovl; + compilerPkg = pkgs-ovl.dmd; + compilerBin = "dmd"; + buildType = "dmd"; + }; + spine-overlay-ldc = mkSpine { + pkgs = pkgs-ovl; + compilerPkg = pkgs-ovl.ldc; + compilerBin = "ldmd2"; + buildType = "ldmd2"; + }; + #spine-overlay-gdc = mkSpine { + # pkgs = pkgs-ovl; + # compilerPkg = pkgs-ovl.gdc; + # compilerBin = "gdc"; + # buildType = "gdc"; + #}; + }); apps = forAllSystems (system: { default = { type = "app"; @@ -233,224 +158,92 @@ devShells = forAllSystems (system: let pkgs-ovl = pkgsForSystem system; pkgs-nix = nixpkgsFor.${system}; - shellHook = '' - #export Date=`date "+%Y%m%d"` - ## set local values in .envrc-local (or here if you must) - echo '❯❯ nix build'; - ## ImPure Nix environment - SpineGitVer=`git describe | sed "s/^[a-z_-]\+\([0-9.]\+\)/\1/" | sed "s/\([^-]*-g\)/r\1/" | sed "s/-/./g"` && \ - SpineGitBranch=`git branch --show-current` && \ - echo "❯❯ spine-v${version} - ($SpineGitBranch: $SpineGitVer)" - ## Pure Nix environment - version info from flake inputs - #echo "❯❯ spine-v${version} (rev: ${self.shortRev or "unknown"})" - echo '❯❯ $SpineBIN -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=$SpineOUT $SpinePOD/*'; - echo "❯❯ $SpineBIN -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=$SpineOUT $SpinePOD/*"; - echo '❯❯ nix flake update && nix flake check && nix flake show'; - ''; - in - with pkgs-nix; { - dsh-overlay = mkShell { - name = "spine-<<spine_version>> base dev shell, ldc-<<ldc_version>>, dub-<<dub_version>> - dtools-<<dtools_version>>"; - inherit shell; - inherit devEnv; - packages = with pkgs-ovl; [ - direnv - nix-direnv - ldc - #dmd - dub - dtools - gnumake - sqlite - gnugrep gnused - ripgrep - ]; - inherit shellHook; - }; - dsh-nixpkgs-dmd = mkShell { - name = "spine-<<spine_version>> base dev shell"; - inherit shell; - inherit devEnv; - packages = [ - direnv - nix-direnv - dmd - dub - dtools - gnumake - sqlite - gnugrep gnused - ripgrep - ]; - inherit shellHook; - }; - dsh-nixpkgs-ldc = mkShell { - name = "spine-<<spine_version>> base dev shell"; - inherit shell; - inherit devEnv; - packages = [ - direnv - nix-direnv - ldc - dub - dtools - gnumake - sqlite - gnugrep gnused - ripgrep - ]; - inherit shellHook; - }; - dsh-overlay-dmd = mkShell { - name = "spine-<<spine_version>> base dev shell, dmd-<<dmd_version>>, dub-<<dub_version>> - dtools-<<dtools_version>>"; - inherit shell; - inherit devEnv; - packages = with pkgs-ovl; [ - direnv - nix-direnv - dmd - dub - dtools - gnumake - sqlite - gnugrep gnused - ripgrep - ]; - inherit shellHook; - }; - dsh-overlay-ldc = mkShell { - name = "spine-<<spine_version>> base dev shell, ldc-<<ldc_version>>, dub-<<dub_version>> - dtools-<<dtools_version>>"; - inherit shell; - inherit devEnv; - packages = with pkgs-ovl; [ - direnv - nix-direnv - ldc - dub - dtools - gnumake - sqlite - ]; - inherit shellHook; - }; - dsh-epub = mkShell { - name = "spine-<<spine_version>> dev shell for epub output"; - inherit shell; - inherit devEnv; - packages = [ - direnv - nix-direnv - ldc - #dmd - dub - dtools - gnumake - sqlite - libxml2 - html-tidy - xmlstarlet - epubcheck - ebook_tools - libxml2 - html-tidy - xmlstarlet - epubcheck - ebook_tools - epr - sigil - calibre #(suite includes: ebook-viewer) - koreader - foliate - gnugrep gnused - ripgrep - ]; - inherit shellHook; - }; - dsh-html = mkShell { - name = "spine-<<spine_version>> dev shell for html output"; - inherit shell; - inherit devEnv; - packages = [ - direnv - nix-direnv - ldc - #dmd - dub - dtools - gnumake - sqlite - # ❯❯ text-mode web browsers - elinks - links2 - lynx - w3m - # ❯❯ light graphical - #dillo - gnugrep gnused - ripgrep - ]; - inherit shellHook; - }; - dsh-latex-pdf = mkShell { - name = "spine-<<spine_version>> dev shell for latex & pdf output"; - inherit shell; - inherit devEnv; - packages = [ - direnv - nix-direnv - ldc - #dmd - dub - dtools - gnumake - source-sans-pro - source-serif-pro - source-code-pro - texlive.combined.scheme-full - gnugrep gnused - ripgrep - ]; - inherit shellHook; - }; - dsh-sqlite = mkShell { - name = "spine-<<spine_version>> dev shell for sqlite3 output"; - inherit shell; - inherit devEnv; - packages = [ - direnv - nix-direnv - ldc - #dmd - dub - dtools - gnumake - sqlite - gnugrep gnused - ripgrep - ]; - inherit shellHook; - }; - dsh-i18n = mkShell { - name = "spine-<<spine_version>> dev shell for internationalization, po4a"; - inherit shell; - inherit devEnv; - packages = [ - direnv - nix-direnv - ldc - #dmd - dub - dtools - gnumake - sqlite - perlPackages.Po4a - gnugrep gnused - ripgrep - ]; - inherit shellHook; - }; - default = import ./shell.nix {inherit pkgs-nix;}; - }); + in { + default = import ./shell.nix {inherit pkgs-nix;}; + dsh-overlay = mkDevShell { + pkgs = pkgs-ovl; + # "spine-<<spine_version>> base dev shell, ldc-<<ldc_version>>, dub-<<dub_version>> - dtools-<<dtools_version>>"; + name = "spine-${version} dev shell (overlay ldc)"; + compiler = pkgs-ovl.ldc; + }; + dsh-nixpkgs-dmd = mkDevShell { + pkgs = pkgs-nix; + name = "spine-${version} dev shell (nixpkgs dmd)"; + compiler = pkgs-nix.dmd; + }; + dsh-nixpkgs-ldc = mkDevShell { + pkgs = pkgs-nix; + name = "spine-${version} dev shell (nixpkgs ldc)"; + compiler = pkgs-nix.ldc; + }; + dsh-overlay-dmd = mkDevShell { + pkgs = pkgs-ovl; + # "spine-<<spine_version>> base dev shell, dmd-<<dmd_version>>, dub-<<dub_version>> - dtools-<<dtools_version>>"; + name = "spine-${version} dev shell (overlay dmd)"; + compiler = pkgs-ovl.dmd; + }; + dsh-overlay-ldc = mkDevShell { + pkgs = pkgs-ovl; + # "spine-<<spine_version>> base dev shell, ldc-<<ldc_version>>, dub-<<dub_version>> - dtools-<<dtools_version>>"; + name = "spine-${version} dev shell (overlay ldc)"; + compiler = pkgs-ovl.ldc; + }; + dsh-epub = mkDevShell { + pkgs = pkgs-nix; + name = "spine-${version} dev shell for epub output"; + compiler = pkgs-nix.ldc; + extraPackages = with pkgs-nix; [ + libxml2 + html-tidy + xmlstarlet + epubcheck + ebook_tools + epr + sigil + calibre #(suite includes: ebook-viewer) + koreader + foliate + ]; + }; + dsh-html = mkDevShell { + pkgs = pkgs-nix; + name = "spine-${version} dev shell for html output"; + compiler = pkgs-nix.ldc; + extraPackages = with pkgs-nix; [ + # ❯❯ text-mode web browsers + elinks + links2 + lynx + w3m + # ❯❯ light graphical + #dillo + ]; + }; + dsh-latex-pdf = mkDevShell { + pkgs = pkgs-nix; + name = "spine-${version} dev shell for latex & pdf output"; + compiler = pkgs-nix.ldc; + extraPackages = with pkgs-nix; [ + source-sans-pro + source-serif-pro + source-code-pro + texlive.combined.scheme-full + ]; + }; + dsh-sqlite = mkDevShell { + pkgs = pkgs-nix; + name = "spine-${version} dev shell for sqlite3 output"; + compiler = pkgs-nix.ldc; + }; + dsh-i18n = mkDevShell { + pkgs = pkgs-nix; + name = "spine-${version} dev shell for internationalization, po4a"; + compiler = pkgs-nix.ldc; + extraPackages = with pkgs-nix; [ + perlPackages.Po4a + ]; + }; + }); }; } #+END_SRC @@ -480,7 +273,7 @@ with pkgs-nix; git # ❯❯❯ dev gnumake - ps + #ps # ❯❯❯ d_build_related # ❯❯ package manager #dub @@ -518,6 +311,13 @@ with pkgs-nix; # openssl_3_3 ]; shellHook = '' + echo '❯❯ nix build'; + SpineGitVer=`git describe | sed "s/^[a-z_-]\+\([0-9.]\+\)/\1/" | sed "s/\([^-]*-g\)/r\1/" | sed "s/-/./g"` && \ + SpineGitBranch=`git branch --show-current` && \ + echo "❯❯ spine - ($SpineGitBranch: $SpineGitVer)" + echo '❯❯ $SpineBIN -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=$SpineOUT $SpinePOD/*'; + echo "❯❯ $SpineBIN -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=$SpineOUT $SpinePOD/*"; + echo '❯❯ nix flake update && nix flake check && nix flake show'; ''; } #+END_SRC |
