summaryrefslogtreecommitdiffhomepage
path: root/dlang/flake.nix
blob: 954cad920250865a7f72adeef46db0e342252b6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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 ];
      };
    };
}