|
47 | 47 | bcc |
48 | 48 | ]); |
49 | 49 |
|
50 | | - # Will only exist in the build environment |
51 | | - nativeBuildInputs = with pkgs; |
| 50 | + # USDT is only supported on linux |
| 51 | + usdtPkgs = with pkgs; |
| 52 | + platformPkgs isLinux [ |
| 53 | + libsystemtap |
| 54 | + linuxPackages.bcc |
| 55 | + linuxPackages.bpftrace |
| 56 | + ]; |
| 57 | + |
| 58 | + # Will only exist in the build environment and includes everything needed |
| 59 | + # for a depends build |
| 60 | + dependsNativeBuildInputs = with pkgs; |
52 | 61 | [ |
53 | 62 | bison |
54 | 63 | ccache |
|
59 | 68 | llvmTools.clang-tools |
60 | 69 | ninja |
61 | 70 | pkg-config |
62 | | - qt6.wrapQtAppsHook # https://nixos.org/manual/nixpkgs/stable/#sec-language-qt |
63 | 71 | xz |
64 | 72 | ] |
65 | | - ++ platformPkgs isLinux [ |
66 | | - libsystemtap |
67 | | - linuxPackages.bcc |
68 | | - linuxPackages.bpftrace |
| 73 | + ++ usdtPkgs; |
| 74 | + nativeBuildInputs = with pkgs; |
| 75 | + dependsNativeBuildInputs |
| 76 | + ++ [ |
| 77 | + qt6.wrapQtAppsHook # https://nixos.org/manual/nixpkgs/stable/#sec-language-qt |
69 | 78 | ]; |
70 | 79 |
|
71 | | - # Will exist in the runtime environment |
| 80 | + # Will exist in the runtime environment - not needed for a depends build |
72 | 81 | buildInputs = with pkgs; |
73 | 82 | [ |
74 | 83 | boost |
|
80 | 89 | sqlite.dev |
81 | 90 | zeromq |
82 | 91 | ] |
83 | | - ++ platformPkgs isLinux [ |
84 | | - libsystemtap |
85 | | - linuxPackages.bcc |
86 | | - linuxPackages.bpftrace |
87 | | - ]; |
| 92 | + ++ usdtPkgs; |
88 | 93 |
|
89 | 94 | env = { |
90 | 95 | CMAKE_GENERATOR = "Ninja"; |
|
93 | 98 | }; |
94 | 99 | in { |
95 | 100 | # We use mkShelNoCC to avoid having Nix set up a gcc-based build environment |
96 | | - devShells.default = pkgs.mkShellNoCC { |
97 | | - inherit nativeBuildInputs buildInputs; |
98 | | - packages = |
99 | | - [ |
100 | | - pythonEnv |
101 | | - pkgs.codespell |
102 | | - pkgs.hexdump |
103 | | - ] |
104 | | - ++ platformPkgs isLinux [pkgs.gdb] |
105 | | - ++ platformPkgs isDarwin [llvmTools.lldb]; |
106 | | - |
107 | | - shellHook = '' |
108 | | - # This can likely be removed if https://github.com/bitcoin/bitcoin/pull/32678 is merged |
109 | | - unset SOURCE_DATE_EPOCH |
110 | | - ''; |
111 | | - inherit (env) CMAKE_GENERATOR LD_LIBRARY_PATH LOCALE_ARCHIVE; |
| 101 | + devShells = { |
| 102 | + default = pkgs.mkShellNoCC { |
| 103 | + inherit nativeBuildInputs buildInputs; |
| 104 | + packages = |
| 105 | + [ |
| 106 | + pythonEnv |
| 107 | + pkgs.codespell |
| 108 | + pkgs.hexdump |
| 109 | + ] |
| 110 | + ++ platformPkgs isLinux [pkgs.gdb] |
| 111 | + ++ platformPkgs isDarwin [llvmTools.lldb]; |
| 112 | + |
| 113 | + inherit (env) CMAKE_GENERATOR LD_LIBRARY_PATH LOCALE_ARCHIVE; |
| 114 | + }; |
| 115 | + # TODO: this could be ported to a gcc shell in the future to bring this closer in line |
| 116 | + # with our guix depends build. This would allow us to remove the shellHook hack that shims |
| 117 | + # in clang to masquerade as gcc |
| 118 | + depends = pkgs.mkShellNoCC { |
| 119 | + nativeBuildInputs = dependsNativeBuildInputs; |
| 120 | + buildInputs = usdtPkgs; |
| 121 | + shellHook = '' |
| 122 | + # having SOURCE_DATE_EPOCH set can interfere with the guix |
| 123 | + # build system, so we unset this in the depends devshell |
| 124 | + unset SOURCE_DATE_EPOCH |
| 125 | +
|
| 126 | + # its not super easy to override compiler defaults in |
| 127 | + # depends, so as a hack we just shim in clang and pretend |
| 128 | + # its gcc. this is done in a tmp dir to avoid polluting the |
| 129 | + # users shell and is cleaned up when the shell is exited. |
| 130 | + TMP_GCC_SHIM=$(mktemp -d "$TMPDIR/clang-shim.XXXXXX") |
| 131 | +
|
| 132 | + ln -sf $(command -v clang++) "$TMP_GCC_SHIM/g++" |
| 133 | + ln -sf $(command -v clang) "$TMP_GCC_SHIM/gcc" |
| 134 | +
|
| 135 | + export PATH="$TMP_GCC_SHIM:$PATH" |
| 136 | + echo "Using fake gcc/g++ -> clang in: $TMP_GCC_SHIM" |
| 137 | +
|
| 138 | + trap "rm -rf $TMP_GCC_SHIM" EXIT |
| 139 | + ''; |
| 140 | + inherit (env) CMAKE_GENERATOR LOCALE_ARCHIVE; |
| 141 | + }; |
112 | 142 | }; |
113 | 143 |
|
114 | 144 | formatter = pkgs.alejandra; |
|
0 commit comments