Skip to content

Instantly share code, notes, and snippets.

@hawkw
Created November 2, 2021 17:52
Show Gist options
  • Save hawkw/95375a1dc3cb1e740c323f25a00476ce to your computer and use it in GitHub Desktop.
Save hawkw/95375a1dc3cb1e740c323f25a00476ce to your computer and use it in GitHub Desktop.
nix-env to build cloudflare/boring
{ pkgs ? import <nixos-unstable> { } }:
with pkgs;
buildEnv {
name = "boring";
paths = [
binutils
cacert
clang
git
glibc
(glibcLocales.override { locales = [ "en_US.UTF-8" ]; })
openssl
pkg-config
rustup
stdenv
cmake
];
buildInputs = [ clang libclang ];
passthru = with pkgs; {
LC_ALL = "en_US.UTF-8";
LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive";
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
OPENSSL_DIR = "${openssl.dev}";
OPENSSL_LIB_DIR = "${openssl.out}/lib";
};
}
{ pkgs ? import <nixos-unstable> { } }:
with pkgs;
let env = (import ./default.nix scope);
in mkShell {
name = "boring-shell";
LC_ALL = "en_US.UTF-8";
LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive";
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
OPENSSL_DIR = "${openssl.dev}";
OPENSSL_LIB_DIR = "${openssl.out}/lib";
CARGO_TERM_COLOR = "always";
RUST_BACKTRACE = "1";
buildInputs = [ (import ./default.nix { inherit pkgs; }) ];
# XXX(eliza): blergh, this part kinda sucks...
shellHook = ''
export BINDGEN_EXTRA_CLANG_ARGS="$(< ${stdenv.cc}/nix-support/libc-crt1-cflags) \
$(< ${stdenv.cc}/nix-support/libc-cflags) \
$(< ${stdenv.cc}/nix-support/cc-cflags) \
$(< ${stdenv.cc}/nix-support/libcxx-cxxflags) \
${
lib.optionalString stdenv.cc.isClang
"-idirafter ${stdenv.cc.cc}/lib/clang/${
lib.getVersion stdenv.cc.cc
}/include"
} \
${
lib.optionalString stdenv.cc.isGNU
"-isystem ${stdenv.cc.cc}/include/c++/${
lib.getVersion stdenv.cc.cc
} -isystem ${stdenv.cc.cc}/include/c++/${
lib.getVersion stdenv.cc.cc
}/${stdenv.hostPlatform.config} -idirafter ${stdenv.cc.cc}/lib/gcc/${stdenv.hostPlatform.config}/${
lib.getVersion stdenv.cc.cc
}/include"
} \
"
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment