aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2026-04-11 01:04:08 +0000
committerRalph Amissah <ralph.amissah@gmail.com>2026-04-11 01:18:49 +0000
commit0abf018794e7d32e5b9f670b9458033aa38c04e1 (patch)
tree323268c1c195a7a24032a31b1934bff1a335f2f4
parentflake.nix dmd build fix overlay: revert to GCC14 (diff)
nix keeping: nix-shell, nix-build derivation.nix
-rwxr-xr-xdefault.nix3
-rwxr-xr-x[-rw-r--r--]derivation.nix1
-rw-r--r--devenv.nix48
-rw-r--r--flake.lock6
-rw-r--r--flake.nix3
-rw-r--r--org/config_misc.org2
-rw-r--r--org/config_nix.org230
-rw-r--r--package.nix68
-rwxr-xr-xshell.nix96
-rwxr-xr-xtangle25
10 files changed, 260 insertions, 222 deletions
diff --git a/default.nix b/default.nix
deleted file mode 100755
index 922b291..0000000
--- a/default.nix
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env -S nix-build
-{pkgs ? import <nixpkgs> {}}:
-pkgs.callPackage ./devenv.nix {}
diff --git a/derivation.nix b/derivation.nix
index 90e549e..7e95843 100644..100755
--- a/derivation.nix
+++ b/derivation.nix
@@ -1,3 +1,4 @@
+#!/usr/bin/env -S nix-build derivation.nix
{
pkgs ? import <nixpkgs> {},
stdenv ? pkgs.stdenv,
diff --git a/devenv.nix b/devenv.nix
deleted file mode 100644
index 6d1754c..0000000
--- a/devenv.nix
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- pkgs ? import <nixpkgs> {},
- name ? "user-env",
-}:
-with pkgs;
- buildEnv {
- inherit name;
- extraOutputsToInstall = ["out" "man" "lib"]; # to get all needed symlinks
- paths = [
- # ❯❯❯ nix_related
- #nix # if not on NixOS, this is needed
- direnv
- nix-direnv
- nixVersions.latest #nixVersions.latest #nixVersions.git
- nix-prefetch-git
- validatePkgConfig
- nix-output-monitor
- nix-tree
- jq #gx
- #nixfmt-rfc-style
- git
- # ❯❯❯ dev
- gnumake
- ps
- dtools
- # ❯❯❯ d_build_related
- # ❯❯ package manager
- dub
- # ❯❯ compiler
- #dmd
- ldc
- # ❯❯❯ sqlite search related
- sqlite
- # this will create a script that will rebuild and upgrade your setup; using shell script syntax
- (writeScriptBin "nix-rebuild" ''
- #!${stdenv.shell}
- #cd <path-to-flake> || 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;
- })
- ];
- }
diff --git a/flake.lock b/flake.lock
index 02cec2f..aeaac22 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
- "lastModified": 1775701739,
- "narHash": "sha256-2FWWY1rr/+pGUJK1npcVcsWNEblzmKs6VxD3VEvwJSs=",
+ "lastModified": 1775793324,
+ "narHash": "sha256-omax7atcZbol+6HJ2RLpP+ZCFcPa5bZ65Hn71RufeWQ=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "0f7663154ff2fec150f9dbf5f81ec2785dc1e0db",
+ "rev": "9d29d5f667d7467f98efc31881e824fa586c927e",
"type": "github"
},
"original": {
diff --git a/flake.nix b/flake.nix
index a172369..fa1aa5a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -139,7 +139,8 @@
pkgs-ovl = pkgsForSystem system;
pkgs-nix = nixpkgsFor.${system};
in {
- default = import ./shell.nix {inherit pkgs-nix;};
+ default = self.devShells.${system}.dsh-overlay;
+ #default = import ./shell.nix {pkgs = pkgs-nix; flake = self;};
dsh-overlay = mkDevShell {
pkgs = pkgs-ovl;
# "spine-0.18.0 base dev shell, ldc-1.42.0, dub-1.40.0 - dtools-2.110.0";
diff --git a/org/config_misc.org b/org/config_misc.org
index 24eda02..675ac75 100644
--- a/org/config_misc.org
+++ b/org/config_misc.org
@@ -23,7 +23,7 @@ babel tangle) org files in ./org/ to create .d source files in ./src/sisudoc/
(similar functionality is contained within the "makefile" created by this
"dr_build_scaffold.org" file make tangle)
-#+HEADER: :tangle ../tangle
+#+HEADER: :tangle-NO ../tangle
#+HEADER: :tangle-mode (identity #o755)
#+HEADER: :shebang "#!/bin/sh"
#+BEGIN_SRC shell
diff --git a/org/config_nix.org b/org/config_nix.org
index eba0917..a7206e2 100644
--- a/org/config_nix.org
+++ b/org/config_nix.org
@@ -162,7 +162,8 @@
pkgs-ovl = pkgsForSystem system;
pkgs-nix = nixpkgsFor.${system};
in {
- default = import ./shell.nix {inherit pkgs-nix;};
+ default = self.devShells.${system}.dsh-overlay;
+ #default = import ./shell.nix {pkgs = pkgs-nix; flake = self;};
dsh-overlay = mkDevShell {
pkgs = pkgs-ovl;
# "spine-<<spine_version>> base dev shell, ldc-<<ldc_version>>, dub-<<dub_version>> - dtools-<<dtools_version>>";
@@ -260,45 +261,44 @@
#+HEADER: :shebang "#!/usr/bin/env -S nix-shell --pure\n#!nix-shell -i bash"
#+HEADER: :noweb yes
#+BEGIN_SRC nix
-{pkgs-nix ? import <nixpkgs> {}}:
-with pkgs-nix;
+# Development environment for sisudoc-spine.
+# Builds the spine binary via ./package.nix and puts it on PATH.
+#
+# Build logic for the spine derivation lives in ./package.nix
+# this file only describes the dev shell.
+#
+# Usage:
+# nix-shell # enters shell, builds spine
+# nix-shell --run 'spine --version' # runs spine after build
+{
+ pkgs ? import <nixpkgs> {},
+ spine ? pkgs.callPackage ./package.nix {},
+ # captured at eval time - nix-shell rewrites $SHELL at runtime,
+ # so we must remember the user's real login shell here.
+ userShell ? builtins.getEnv "SHELL",
+}:
+with pkgs;
mkShell {
- buildInputs = [
+ name = "spine base dev shell";
+ packages = [
+ # ❯❯❯ spine binary built from ./package.nix
+ spine
+ # ❯❯❯ d_build_related
+ ldc
+ #dmd
+ dub
+ # ❯❯❯ dev
+ gnumake
+ git
# ❯❯❯ nix_related
- #nix
direnv
nix-direnv
- nixVersions.latest #nixVersions.latest #nixVersions.git
nix-prefetch-git
- validatePkgConfig
nix-output-monitor
nix-tree
- jq #gx
- #nixfmt-rfc-style
- git
- # ❯❯❯ dev
- gnumake
- #ps
- # ❯❯❯ d_build_related
- # ❯❯ package manager
- #dub
- # ❯❯ compiler
- #dmd
- #ldc
- #rund
- # ❯❯ linker
- #lld
- #mold
- # ❯❯ builder
- #ninja
- #meson
+ jq
# ❯❯❯ sqlite search related
- #sqlite
- # ❯❯❯ pdf_latex_related
- # source-sans-pro
- # source-serif-pro
- # source-code-pro
- # texlive.combined.scheme-full
+ sqlite
# ❯❯❯ xml_and_epub_related
# libxml2
# html-tidy
@@ -310,93 +310,121 @@ with pkgs-nix;
# calibre #(suite includes: ebook-viewer)
# koreader
# foliate
+ # ❯❯❯ pdf reader
+ # evince
+ # ❯❯❯ pdf_latex_related
+ # source-sans-pro
+ # source-serif-pro
+ # source-code-pro
+ # texlive.combined.scheme-full
# ❯❯❯ i18n translation related
# perlPackages.Po4a
- # ❯❯❯ dev
- # 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';
+ export DFLAGS="-O2 -boundscheck=on"
+ export Date=$(date "+%Y%m%d")
+ ## set local values in .envrc-local (or here if you must)
+ echo "spine: $(command -v spine)"
+ ## hand off to the user's login shell (e.g. zsh) only when this is
+ ## an interactive nix-shell entry - not under `nix-shell --run` or
+ ## `--command`, where exec would swallow the command. Guard env var
+ ## prevents re-entry loops.
+ __spine_user_shell=${if userShell == "" then "" else "\"" + userShell + "\""}
+ if [ -z "$__SPINE_SHELL_HANDOFF" ] \
+ && [ -n "$__spine_user_shell" ] \
+ && [ "$(basename "$__spine_user_shell")" != "bash" ] \
+ && [[ $- == *i* ]]; then
+ export __SPINE_SHELL_HANDOFF=1
+ spine --version
+ exec "$__spine_user_shell"
+ fi
+ unset __spine_user_shell
+ spine --version
'';
}
#+END_SRC
-** default.nix :default:
-
-#+HEADER: :tangle ../default.nix
-#+HEADER: :tangle-mode (identity #o755)
-#+HEADER: :shebang "#!/usr/bin/env -S nix-build"
-#+BEGIN_SRC nix
-{pkgs ? import <nixpkgs> {}}:
-pkgs.callPackage ./devenv.nix {}
-#+END_SRC
-
-* devEnv
-** devenv.nix :default:devenv:
+** package.nix :default:
-#+HEADER: :tangle ../devenv.nix
+#+HEADER: :tangle ../package.nix
#+HEADER: :tangle-mode (identity #o644)
+#+HEADER: :noweb yes
#+BEGIN_SRC nix
+# package.nix - spine derivation (build logic)
+#
+# Standalone, callPackage-style derivation for the spine binary. Used by
+# shell.nix to put a freshly-built spine on PATH inside the dev shell.
+# May also be consumed via:
+# nix-build ./package.nix
+# pkgs.callPackage ./package.nix {}
+#
+# Compiler defaults to ldc/ldmd2 (matching the flake's default package
+# `spine-nixpkgs-ldc`). Override to build with dmd:
+# pkgs.callPackage ./package.nix {
+# compilerPkg = pkgs.dmd;
+# compilerBin = "dmd";
+# buildType = "dmd";
+# }
{
- pkgs ? import <nixpkgs> {},
- name ? "user-env",
+ lib,
+ stdenv,
+ dub,
+ ldc,
+ gnumake,
+ sqlite,
+ compilerPkg ? ldc,
+ compilerBin ? "ldmd2",
+ buildType ? "ldmd2",
+ rev ? "unknown",
}:
-with pkgs;
- buildEnv {
- inherit name;
- extraOutputsToInstall = ["out" "man" "lib"]; # to get all needed symlinks
- paths = [
- # ❯❯❯ nix_related
- #nix # if not on NixOS, this is needed
- direnv
- nix-direnv
- nixVersions.latest #nixVersions.latest #nixVersions.git
- nix-prefetch-git
- validatePkgConfig
- nix-output-monitor
- nix-tree
- jq #gx
- #nixfmt-rfc-style
- git
- # ❯❯❯ dev
- gnumake
- ps
- dtools
- # ❯❯❯ d_build_related
- # ❯❯ package manager
- dub
- # ❯❯ compiler
- #dmd
- ldc
- # ❯❯❯ sqlite search related
- sqlite
- # this will create a script that will rebuild and upgrade your setup; using shell script syntax
- (writeScriptBin "nix-rebuild" ''
- #!${stdenv.shell}
- #cd <path-to-flake> || 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;
- })
- ];
- }
+stdenv.mkDerivation {
+ pname = "spine";
+ version = "<<spine_version>>";
+ src = lib.cleanSource ./.;
+ buildInputs = [ sqlite ];
+ nativeBuildInputs = [ dub compilerPkg 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
+ 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 `ls -la $out/bin/spine`
+ echo "❯❯ spine-v0.18.0 (rev: ${rev})"
+ $out/bin/spine -v
+ '';
+ meta = {
+ description = "A sisu like parser & document generator";
+ longDescription = "a sisu like parser & document generator";
+ homepage = "https://sisudoc.org";
+ license = lib.licenses.agpl3Plus;
+ platforms = lib.platforms.linux;
+ mainProgram = "spine";
+ };
+}
#+END_SRC
** derivation.nix :default:
#+HEADER: :tangle ../derivation.nix
-#+HEADER: :tangle-mode (identity #o644)
+#+HEADER: :tangle-mode (identity #o755)
+#+HEADER: :shebang "#!/usr/bin/env -S nix-build derivation.nix"
#+HEADER: :noweb yes
#+BEGIN_SRC nix
{
diff --git a/package.nix b/package.nix
new file mode 100644
index 0000000..6e6b769
--- /dev/null
+++ b/package.nix
@@ -0,0 +1,68 @@
+# package.nix - spine derivation (build logic)
+#
+# Standalone, callPackage-style derivation for the spine binary. Used by
+# shell.nix to put a freshly-built spine on PATH inside the dev shell.
+# May also be consumed via:
+# nix-build ./package.nix
+# pkgs.callPackage ./package.nix {}
+#
+# Compiler defaults to ldc/ldmd2 (matching the flake's default package
+# `spine-nixpkgs-ldc`). Override to build with dmd:
+# pkgs.callPackage ./package.nix {
+# compilerPkg = pkgs.dmd;
+# compilerBin = "dmd";
+# buildType = "dmd";
+# }
+{
+ lib,
+ stdenv,
+ dub,
+ ldc,
+ gnumake,
+ sqlite,
+ compilerPkg ? ldc,
+ compilerBin ? "ldmd2",
+ buildType ? "ldmd2",
+ rev ? "unknown",
+}:
+stdenv.mkDerivation {
+ pname = "spine";
+ version = "0.18.0";
+ src = lib.cleanSource ./.;
+ buildInputs = [ sqlite ];
+ nativeBuildInputs = [ dub compilerPkg 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
+ 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 `ls -la $out/bin/spine`
+ echo "❯❯ spine-v0.18.0 (rev: ${rev})"
+ $out/bin/spine -v
+ '';
+ meta = {
+ description = "A sisu like parser & document generator";
+ longDescription = "a sisu like parser & document generator";
+ homepage = "https://sisudoc.org";
+ license = lib.licenses.agpl3Plus;
+ platforms = lib.platforms.linux;
+ mainProgram = "spine";
+ };
+}
diff --git a/shell.nix b/shell.nix
index 1974340..29b6577 100755
--- a/shell.nix
+++ b/shell.nix
@@ -1,44 +1,43 @@
#!/usr/bin/env -S nix-shell --pure
#!nix-shell -i bash
-{pkgs-nix ? import <nixpkgs> {}}:
-with pkgs-nix;
+# Development environment for sisudoc-spine.
+# Builds the spine binary via ./package.nix and puts it on PATH.
+#
+# Build logic for the spine derivation lives in ./package.nix
+# this file only describes the dev shell.
+#
+# Usage:
+# nix-shell # enters shell, builds spine
+# nix-shell --run 'spine --version' # runs spine after build
+{
+ pkgs ? import <nixpkgs> {},
+ spine ? pkgs.callPackage ./package.nix {},
+ # captured at eval time - nix-shell rewrites $SHELL at runtime,
+ # so we must remember the user's real login shell here.
+ userShell ? builtins.getEnv "SHELL",
+}:
+with pkgs;
mkShell {
- buildInputs = [
+ name = "spine base dev shell";
+ packages = [
+ # ❯❯❯ spine binary built from ./package.nix
+ spine
+ # ❯❯❯ d_build_related
+ ldc
+ #dmd
+ dub
+ # ❯❯❯ dev
+ gnumake
+ git
# ❯❯❯ nix_related
- #nix
direnv
nix-direnv
- nixVersions.latest #nixVersions.latest #nixVersions.git
nix-prefetch-git
- validatePkgConfig
nix-output-monitor
nix-tree
- jq #gx
- #nixfmt-rfc-style
- git
- # ❯❯❯ dev
- gnumake
- #ps
- # ❯❯❯ d_build_related
- # ❯❯ package manager
- #dub
- # ❯❯ compiler
- #dmd
- #ldc
- #rund
- # ❯❯ linker
- #lld
- #mold
- # ❯❯ builder
- #ninja
- #meson
+ jq
# ❯❯❯ sqlite search related
- #sqlite
- # ❯❯❯ pdf_latex_related
- # source-sans-pro
- # source-serif-pro
- # source-code-pro
- # texlive.combined.scheme-full
+ sqlite
# ❯❯❯ xml_and_epub_related
# libxml2
# html-tidy
@@ -50,18 +49,35 @@ with pkgs-nix;
# calibre #(suite includes: ebook-viewer)
# koreader
# foliate
+ # ❯❯❯ pdf reader
+ # evince
+ # ❯❯❯ pdf_latex_related
+ # source-sans-pro
+ # source-serif-pro
+ # source-code-pro
+ # texlive.combined.scheme-full
# ❯❯❯ i18n translation related
# perlPackages.Po4a
- # ❯❯❯ dev
- # 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';
+ export DFLAGS="-O2 -boundscheck=on"
+ export Date=$(date "+%Y%m%d")
+ ## set local values in .envrc-local (or here if you must)
+ echo "spine: $(command -v spine)"
+ ## hand off to the user's login shell (e.g. zsh) only when this is
+ ## an interactive nix-shell entry - not under `nix-shell --run` or
+ ## `--command`, where exec would swallow the command. Guard env var
+ ## prevents re-entry loops.
+ __spine_user_shell=${if userShell == "" then "" else "\"" + userShell + "\""}
+ if [ -z "$__SPINE_SHELL_HANDOFF" ] \
+ && [ -n "$__spine_user_shell" ] \
+ && [ "$(basename "$__spine_user_shell")" != "bash" ] \
+ && [[ $- == *i* ]]; then
+ export __SPINE_SHELL_HANDOFF=1
+ spine --version
+ exec "$__spine_user_shell"
+ fi
+ unset __spine_user_shell
+ spine --version
'';
}
diff --git a/tangle b/tangle
deleted file mode 100755
index ff290c2..0000000
--- a/tangle
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-# -*- mode: shell-script -*-
-# tangle files with org-mode
-DIR=`pwd`
-ORGFILES=""
-EMACSLISP=/usr/share/emacs/site-lisp
-ORG_VER_AVAILABLE=$(shell echo `ls -d ~/.emacs.d/elpa/org-???????? | cut -d '-' -f2`)
-EMACSLISP_ORG=~/.emacs.d/elpa/org-$($(shell echo $(ORG_VER_AVAILABLE)))
-ORG_CONTRIB_VER_AVAILABLE=$(shell echo `ls -d ~/.emacs.d/elpa/org-plus-???????? | cut -d '-' -f2`)
-EMACSLISP_ORG_CONTRIB=~/.emacs.d/elpa/org-plus-contrib-$($(shell echo $(ORG_CONTRIB_VER_AVAILABLE)))
-# wrap each argument in the code required to call tangle on it
-for i in $@; do
- ORGFILES="$ORGFILES \"$i\""
-done
-emacs --batch -Q -q \
---eval "(progn
-(add-to-list 'load-path (expand-file-name \"$EMACSLISP\"))
-(add-to-list 'load-path (expand-file-name \"$EMACSLISP_ORG\" t))
-(add-to-list 'load-path (expand-file-name \"$EMACSLISP_ORG_CONTRIB\" t))
-(require 'org)(require 'ob)(require 'ob-tangle)
-(mapc (lambda (file)
- (find-file (expand-file-name file \"$DIR\"))
- (setq-local org-src-preserve-indentation t)
- (org-babel-tangle)
- (kill-buffer)) '($ORGFILES)))" 2>&1 #|grep tangled