summaryrefslogtreecommitdiffstats
path: root/flake.nix
blob: 6756eeded2743c29a73722c5fb5e8eca953c4c02 (about) (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
{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils, ... }@inputs:
    flake-utils.lib.eachDefaultSystem
      (system:
        let
          pkgs = import nixpkgs { inherit system; };
          boost = pkgs.boost191;
          llvmVersion = "22";
          llvmPackages = pkgs."llvmPackages_${llvmVersion}";
          libstdcxxGcc = pkgs.gcc16.cc;
          clang = llvmPackages.clang.override {
            gccForLibs = libstdcxxGcc;
          };
          inherit (clang) stdenv;

          routemon = stdenv.mkDerivation {
            name = "routemon";
            src = ./server;

            buildInputs = with pkgs; [ boost pugixml expat icu openssl sqlite ];
            nativeBuildInputs = with pkgs; [ pkgs."llvmPackages_${llvmVersion}".clang-tools pkgs."clang_${llvmVersion}" boost cmake ninja gettext ];

            hardeningDisable = [
              # Disable here because this breaks C++ modules (I suspect because it sets -D_FORTIFY_SOURCE=3)
              # We set plenty of hardening options in CMakeLists.txt anyway.
              "all"
            ];

            env.NIX_CFLAGS_COMPILE = toString [
              "-DLOCALEDIR=${builtins.placeholder "out"}/share/locale"
              "-Wno-reserved-module-identifier"
              "-isystem ${libstdcxxGcc}/include/c++/${libstdcxxGcc.version}/backward"
            ];

            cmakeFlags = [
              "--preset=nix-derivation"
              "-DCMAKE_CXX_STDLIB_MODULES_JSON=${libstdcxxGcc}/lib/libstdc++.modules.json"
            ];
          };
        in
        {
          packages.routemon = routemon;

          devShells.default = pkgs.mkShell.override { inherit stdenv; } {
            buildInputs = [ pkgs.nix-index pkgs.nix-tree ];
            inputsFrom = [ routemon ];
          };

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