diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b3ae7f9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "levers": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1687557470, + "narHash": "sha256-T0TAGZPiI5cwWR2OMLVYW7aj3Aco7v8qIVF7JoEgO9Y=", + "owner": "kquick", + "repo": "nix-levers", + "rev": "0e31d80978a9fb6a96df0722aa298d008a57c53e", + "type": "github" + }, + "original": { + "owner": "kquick", + "repo": "nix-levers", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1685566663, + "narHash": "sha256-btHN1czJ6rzteeCuE/PNrdssqYD2nIA4w48miQAFloM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4ecab3273592f27479a583fb6d975d4aba3486fe", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "levers": "levers", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ae90ac4 --- /dev/null +++ b/flake.nix @@ -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" ]; + }; + }); + }; +}