Skip to content

Instantly share code, notes, and snippets.

@shiryel
Created June 16, 2022 07:00
Show Gist options
  • Save shiryel/ce1b5320424661ed6c9572453a462c7e to your computer and use it in GitHub Desktop.
Save shiryel/ce1b5320424661ed6c9572453a462c7e to your computer and use it in GitHub Desktop.
Nix flake for Clang
{
description = "Clang Template";
inputs = {
nixpkgs_stable.url = "github:NixOS/nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils/v1.0.0";
};
outputs = { self, nixpkgs_stable, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs_stable { system = system; };
llvm = pkgs.llvmPackages_13;
packages = with pkgs; [
# XXX: the order of include matters
pkgs.clang-tools
llvm.clang # clangd
# debugger
llvm.lldb
];
in
rec {
devShell = pkgs.mkShell {
nativeBuildInputs = [ pkgs.pkg-config ];
packages = packages;
CPATH = builtins.concatStringsSep ":" [
(pkgs.lib.makeSearchPathOutput "dev" "include" ([ llvm.libcxx llvm.libcxxabi ]))
(pkgs.lib.makeSearchPath "resource-root/include" ([ llvm.clang ]))
];
};
defaultPackage = llvm.stdenv.mkDerivation rec {
pname = "Clang Template";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = packages;
sconsFlags = "";
enableParallelBuilding = true;
};
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment