Skip to content

Commit

Permalink
Merge pull request #44 from GaloisInc/add_nix_flake
Browse files Browse the repository at this point in the history
Add flake to support building via nix.
  • Loading branch information
kquick authored Aug 30, 2023
2 parents a5d2661 + 6271c58 commit 40a66cc
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
48 changes: 48 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
description = "Yet Another Pointer Analysis for LLVM";

inputs = {
nixpkgs.url = github:nixos/nixpkgs/23.05;
levers = {
url = "github:kquick/nix-levers";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, levers }:
{
apps = levers.eachSystem (system: rec
{
default = yapall;
yapall = {
type = "app";
program = "${self.packages.${system}.yapall}/bin/yapall";
};
});
packages = levers.eachSystem (system:
let pkgs = import nixpkgs { inherit system; };
in rec {
default = yapall;
yapall = pkgs.rustPlatform.buildRustPackage {
pname = "yapall";
version = "0.0.0";
src = self;
cargoLock = {
lockFile = ./Cargo.lock;
};
LLVM_SYS_140_PREFIX = "${pkgs.llvm_14.dev}/";
RUSTC_LLVM_14 = "${pkgs.rustc}/bin/rustc";
buildInputs = [
pkgs.llvm_14.dev
pkgs.libxml2
pkgs.zlib
];
# Disable nix default of hardening, which will cause compilation of
# various tests at -O0 to fail because _FORTIFY_SOURCE requires some
# level of optimization.
hardeningDisable = [ "all" ];
nativeCheckInputs = [
pkgs.clang_14
];
meta = with pkgs.lib; {
description = "Yet Another Pointer Analysis for LLVM";
license = licenses.bsd3;
homepage = "https://github.com/GaloisInc/yapall";
};
};
});
devShells = levers.eachSystem (system:
let pkgs = import nixpkgs { inherit system; };
in
{
# buildRustPackage doesn't provide assistance here, so simply
# manually create a shell.
default = pkgs.mkShell {
packages = [
pkgs.rustc
pkgs.cargo
pkgs.llvm_14
pkgs.clang_14
pkgs.llvm_14.dev
pkgs.libxml2
pkgs.zlib
pkgs.lit
pkgs.rust-analyzer
];
LLVM_SYS_140_PREFIX = "${pkgs.llvm_14.dev}/";
RUSTC_LLVM_14 = "${pkgs.rustc}/bin/rustc";
hardeningDisable = [ "all" ];
};
});
};
}

0 comments on commit 40a66cc

Please sign in to comment.