summaryrefslogtreecommitdiffhomepage
path: root/dlang/flake.nix
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2026-09-25 16:34:44 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2026-09-25 16:34:44 -0400
commit0e2c9fa40ed98ceb7a26c2af69807cf577b6e32a (patch)
treec9422586349ffbcafb93aad5a4e5f57f15ddf091 /dlang/flake.nix
the abstraction as a library, and a defect it found at once
The readers each read one serialisation and print. A writer needs neither: it needs the document. So the model and both loaders live here, and a writer cannot tell which serialisation it was handed, exactly as spine own writers cannot. ocda.model imports nothing, which is the property that makes writers possible: they depend on the model and on neither loader. The model and the .ssp loader are the ssp-reader code, moved and renamed to the level they belong to: the model is neither the .ssp nor the .ocda.db. ocda.load_db is new, and returns the same value from sqlite that load_ssp returns from text. ocda.load is the one place that decides what a path is. The claim is only true if the two loaders agree, so test/agree.d asks: load a document both ways and compare the models object by object. It found a real defect on its first run. Eight of thirty-six disagreed, and the cause was the .ssp loader, not the formats: an object whose first text line is blank lost it, the loader having decided whether to start a new line by asking whether the accumulated text was empty, which is a different question from whether a line has been seen. Seven documents of the sample set have verse opening on a blank line and every one of them was wrong. Nothing else had caught it: the two .ssp readers were compared on section counts, which the bug does not disturb. It took loading one document two ways and comparing the objects. Fixed here, and in ssp-reader/dlang which carried the same code. 36 of 36 now agree. (assisted by Claude-Code) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'dlang/flake.nix')
-rw-r--r--dlang/flake.nix49
1 files changed, 49 insertions, 0 deletions
diff --git a/dlang/flake.nix b/dlang/flake.nix
new file mode 100644
index 0000000..954cad9
--- /dev/null
+++ b/dlang/flake.nix
@@ -0,0 +1,49 @@
+{
+ description = "ocda-lib: the object-centric document abstraction as a D library";
+
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+
+ outputs = { self, nixpkgs }:
+ let
+ system = "x86_64-linux"; # adjust for aarch64-linux / darwin
+ pkgs = import nixpkgs { inherit system; };
+
+ /* A library, so there is nothing to install as a binary. What is
+ built here is the agreement check, which is the library's own
+ reason to exist put to the question: load a document's .ssp and
+ its .ocda.db and compare the two models.
+ */
+ mkAgree = { compiler, compilerBin }: pkgs.stdenv.mkDerivation {
+ pname = "ocda-lib-agree";
+ version = "0.1.0";
+ src = self;
+ nativeBuildInputs = [ compiler ];
+ buildInputs = [ pkgs.sqlite ];
+ buildPhase = ''
+ runHook preBuild
+ export HOME=$TMPDIR
+ ${compilerBin} -I=src -of=agree src/ocda/*.d test/agree.d -L-lsqlite3
+ runHook postBuild
+ '';
+ installPhase = ''
+ runHook preInstall
+ mkdir -p $out/bin
+ install -m755 agree $out/bin/ocda-agree
+ runHook postInstall
+ '';
+ meta = {
+ description = "checks that the .ssp and .ocda.db loaders give one model";
+ mainProgram = "ocda-agree";
+ };
+ };
+ in {
+ packages.${system} = {
+ default = self.packages.${system}.ocda-agree;
+ ocda-agree = mkAgree { compiler = pkgs.ldc; compilerBin = "ldmd2"; };
+ };
+
+ devShells.${system}.default = pkgs.mkShell {
+ packages = [ pkgs.ldc pkgs.dub pkgs.dtools pkgs.sqlite ];
+ };
+ };
+}