{ description = "ocda-write: sample writers over the object-centric document abstraction, in D"; inputs.nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.zst"; /* The library this is built on, as a source tree rather than a flake: the build compiles its modules alongside these, which is what a dub path dependency does and avoids a second build product for a library of five modules. flake.lock pins the commit of the library this writer was built and checked against. To build against a working copy of it instead: nix build --override-input ocda-lib path:../../sisudoc-ocda-lib */ inputs.ocda-lib = { url = "git+git://git.sisudoc.org/tools/sisudoc-ocda-lib"; flake = false; }; outputs = { self, nixpkgs, ocda-lib }: let system = "x86_64-linux"; # adjust for aarch64-linux / darwin pkgs = import nixpkgs { inherit system; }; mkWrite = { compiler, compilerBin }: pkgs.stdenv.mkDerivation { pname = "ocda-write"; version = "2.0.0"; src = self; nativeBuildInputs = [ compiler ]; buildInputs = [ pkgs.sqlite pkgs.zstd ]; buildPhase = '' runHook preBuild export HOME=$TMPDIR ${compilerBin} -I=src -I=${ocda-lib}/dlang/src -of=ocda-write \ ${ocda-lib}/dlang/src/ocda/*.d src/write/*.d src/main.d \ -L-lsqlite3 -L-lzstd runHook postBuild ''; installPhase = '' runHook preInstall mkdir -p $out/bin install -m755 ocda-write $out/bin/ocda-write runHook postInstall ''; meta = { description = "writes a document out from either serialisation of its abstraction"; mainProgram = "ocda-write"; }; }; in { packages.${system} = { default = self.packages.${system}.ocda-write; ocda-write = mkWrite { compiler = pkgs.ldc; compilerBin = "ldmd2"; }; ocda-write-dmd = mkWrite { compiler = pkgs.dmd; compilerBin = "dmd"; }; }; devShells.${system}.default = pkgs.mkShell { packages = [ pkgs.ldc pkgs.dub pkgs.dtools pkgs.sqlite pkgs.zstd ]; }; }; }