about summary refs log tree commit diff
path: root/users/Profpatsch/omega.nix
blob: 39d27628c4a97570831b88fa63cdbd195800a5af (plain) (blame)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
{ depot, pkgs, lib, ... }:
let

  # fix: https://github.com/NixOS/nixpkgs/pull/352144
  omega-templates = pkgs.stdenv.mkDerivation {
    name = "omega-templates";
    phases = [ "unpackPhase" "installPhase" ];
    src = pkgs.xapian-omega.src;
    installPhase = ''
      mkdir -p $out/share/omega
      mv templates $out/share/omega
    '';
  };

  omega-test = pkgs.stdenv.mkDerivation {
    name = "omega-test";
    phases = [ "installPhase" ];
    installPhase = ''
        mkdir localhost
        ln -sT localhost localhost:8080
        mkdir ./default
        cp -r ${lib.getOutput "doc" pkgs.tipidee}/share/doc/tipidee ./default/tipidee
        cp -r ${lib.getOutput "doc" pkgs.tipidee}/share/doc/tipidee ./localhost/tipidee

        ln -sT ${pkgs.writers.writeText "omega.conf" ''
          database_dir ./omega.db
          log_dir /tmp/omega.log
          template_dir ${omega-templates}/share/omega/templates
        ''} omega.conf

        ${pkgs.tipidee}/bin/tipidee-config -o tipidee.cdb -i ${pkgs.writers.writeText "tipidee.conf" ''
          domain localhost
          cgi /omega
        ''}

      cp ${pkgs.xapian-omega}/lib/xapian-omega/bin/omega ./localhost

      mkdir omega.db
      ${pkgs.xapian-omega}/bin/omindex --db ./omega.db/default --url / ./default

      mkdir -p $out
      cp -r ./* $out
    '';
  };

  run-omega = pkgs.writers.writeBash "run-omega" ''
    cd ${omega-test}
    emptyenv -p \
      ${pkgs.s6-networking}/bin/s6-tcpserver 127.0.0.1 8080 \
      ${pkgs.s6-networking}/bin/s6-tcpserver-access \
      ${pkgs.tipidee}/bin/tipideed -f tipidee.cdb
  '';


in
{
  inherit
    run-omega
    omega-test
    ;
}