aboutsummaryrefslogtreecommitdiffstats
path: root/flake.nix
blob: 22ca0e68ec2674c1099d4c59c0148d651e5d2e32 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{
  inputs = {
    nixpkgs.url = "https://flakehub.com/f/NixOs/nixpkgs/*.tar.gz";
    flake-utils.url = "https://flakehub.com/f/numtide/flake-utils/0.1.88.tar.gz";
    libtmi8 = {
      url = "path:./lib/libtmi8";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.flake-utils.follows = "flake-utils";
    };
  };

  outputs = { self, nixpkgs, flake-utils, libtmi8, ... }@inputs:
    {
      nixosModules = rec {
        oeuf = import ./module self;
        default = oeuf;
      };
    } // flake-utils.lib.eachDefaultSystem
      (system:
        let
          libtmi8Overlay = final: prev: { oeuf-libtmi8 = libtmi8.packages.${system}.oeuf-libtmi8; };

          pkgs = import nixpkgs {
            inherit system;
            overlays = [ libtmi8Overlay ];
          };
          boostPkg = pkgs.boost182;

          inherit (pkgs.gcc13) stdenv;

          oeuf-augmentkv6 = stdenv.mkDerivation {
            name = "oeuf-augmentkv6";
            src = ./.;

            nativeBuildInputs = with pkgs; [ gcc13 boostPkg ];
            buildInputs = with pkgs; [ arrow-cpp oeuf-libtmi8 ];
            buildPhase = ''
              cd src/augmentkv6
              make augmentkv6
            '';

            installPhase = ''
              mkdir -p $out/bin
              cp augmentkv6 $out/bin/oeuf-augmentkv6
            '';
          };

          oeuf-filterkv6 = stdenv.mkDerivation {
            name = "oeuf-filterkv6";
            src = ./.;

            nativeBuildInputs = with pkgs; [ gcc13 ];
            buildInputs = with pkgs; [ arrow-cpp oeuf-libtmi8 ];
            buildPhase = ''
              cd src/filterkv6
              make filterkv6
            '';

            installPhase = ''
              mkdir -p $out/bin
              cp filterkv6 $out/bin/oeuf-filterkv6
            '';
          };

          oeuf-bundleparquet = stdenv.mkDerivation {
            name = "oeuf-bundleparquet";
            src = ./.;

            nativeBuildInputs = with pkgs; [ gcc13 ];
            buildInputs = with pkgs; [ arrow-cpp curl nlohmann_json prometheus-cpp zlib oeuf-libtmi8 ];
            buildPhase = ''
              cd src/bundleparquet
              make bundleparquet
            '';

            installPhase = ''
              mkdir -p $out/bin
              cp bundleparquet $out/bin/oeuf-bundleparquet
            '';
          };

          oeuf-querykv1 = stdenv.mkDerivation {
            name = "oeuf-querykv1";
            src = ./.;

            nativeBuildInputs = with pkgs; [ gcc13 ];
            buildInputs = with pkgs; [ oeuf-libtmi8 boostPkg ];
            buildPhase = ''
              cd src/querykv1
              make querykv1
            '';

            installPhase = ''
              mkdir -p $out/bin
              cp querykv1 $out/bin/oeuf-querykv1
            '';
          };

          oeuf-recvkv6 = stdenv.mkDerivation {
            name = "oeuf-recvkv6";
            src = ./.;

            nativeBuildInputs = with pkgs; [ gcc13 ];
            buildInputs = with pkgs; [ zeromq zlib arrow-cpp nlohmann_json prometheus-cpp rapidxml oeuf-libtmi8 ];
            buildPhase = ''
              cd src/recvkv6
              make recvkv6
            '';

            installPhase = ''
              mkdir -p $out/bin
              cp recvkv6 $out/bin/oeuf-recvkv6
            '';
          };

          oeuf-archiver = import ./script/archiver {
            pkgs = pkgs // { inherit oeuf-bundleparquet; };
          };

          oeuf-synckv6 = import ./script/synckv6 { inherit pkgs; };
        in
        {
          packages.oeuf-archiver = oeuf-archiver;
          packages.oeuf-augmentkv6 = oeuf-augmentkv6;
          packages.oeuf-synckv6 = oeuf-synckv6;
          packages.oeuf-filterkv6 = oeuf-filterkv6;
          packages.oeuf-bundleparquet = oeuf-bundleparquet;
          packages.oeuf-querykv1 = oeuf-querykv1;
          packages.oeuf-recvkv6 = oeuf-recvkv6;

          devShells.default = pkgs.mkShell {
            inputsFrom = [ oeuf-bundleparquet oeuf-querykv1 oeuf-recvkv6 ];
            buildInputs = with pkgs; [ xercesc xsd ];
          };

          formatter = pkgs.nixpkgs-fmt;
        });
}