flake: Added workbench files_handling derivation

This commit is contained in:
Giulio De Pasquale 2023-03-28 17:16:53 -07:00
parent 559e0432e8
commit 0fa919ef2d
2 changed files with 43 additions and 2 deletions

View File

@ -1,10 +1,11 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
cclyzerpp.url = "github:peperunas/cclyzerpp/flake";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
outputs = { self, nixpkgs, flake-utils, cclyzerpp }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
@ -15,9 +16,20 @@
shellWithPkgs = packages: pkgs.mkShell {
inherit packages;
};
cclyzer = cclyzerpp.defaultPackage.${system};
shell = with pkgs; shellWithPkgs [ codeql klee souffle cclyzer ];
in
{
devShells.default = shellWithPkgs [ pkgs.codeql ];
packages = rec {
workbench = {
files_handling = pkgs.callPackage ./workbench/files_handling/default.nix { cclyzerpp = cclyzer; };
};
default = workbench.files_handling;
};
devShell = shell;
});
}

View File

@ -0,0 +1,29 @@
{ stdenv, clang, cclyzerpp }:
stdenv.mkDerivation {
pname = "example";
version = "1.0.0";
src = ./main.c;
dontUnpack = true;
nativeBuildInputs = [ clang cclyzerpp ];
buildPhase = ''
name=`basename ''${src//\.c/}`
clang -c -emit-llvm $src
clang $src -o $name
'';
installPhase = ''
mkdir -p $out/{bin,facts,bitcode}
${cclyzerpp}/bin/factgen-exe $name.bc --out-dir $out/facts
mv $name $out/bin
mv $name.bc $out/bitcode
'';
}