3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/interpreters/acl2/default.nix

146 lines
5.1 KiB
Nix
Raw Normal View History

2021-08-15 01:00:27 +01:00
{ lib, stdenv, callPackage, fetchFromGitHub, runCommandLocal, makeWrapper, substituteAll
, sbcl, bash, which, perl, nettools
2021-08-15 01:00:27 +01:00
, openssl, glucose, minisat, abc-verifier, z3, python
, certifyBooks ? true
} @ args:
let
2021-08-15 01:00:27 +01:00
# Disable immobile space so we don't run out of memory on large books, and
# supply 2GB of dynamic space to avoid exhausting the heap while building the
# ACL2 system itself; see
# https://www.cs.utexas.edu/users/moore/acl2/current/HTML/installation/requirements.html#Obtaining-SBCL
2021-08-15 01:00:27 +01:00
sbcl' = args.sbcl.override { disableImmobileSpace = true; };
sbcl = runCommandLocal args.sbcl.name { buildInputs = [ makeWrapper ]; } ''
makeWrapper ${sbcl'}/bin/sbcl $out/bin/sbcl \
--add-flags "--dynamic-space-size 2000"
'';
in stdenv.mkDerivation rec {
pname = "acl2";
2021-08-15 01:00:27 +01:00
version = "8.4";
src = fetchFromGitHub {
owner = "acl2-devel";
repo = "acl2-devel";
rev = version;
2021-08-15 01:00:27 +01:00
sha256 = "16rr9zqmd3y1sd6zxff2f9gdd84l99pr7mdp1sjwmh427h661c68";
};
2021-08-15 01:00:27 +01:00
# You can swap this out with any other IPASIR implementation at
# build time by using overrideAttrs (make sure the derivation you
# use has a "libname" attribute so we can plug it into the patch
# below). Or, you can override it at runtime by setting the
# $IPASIR_SHARED_LIBRARY environment variable.
libipasir = callPackage ./libipasirglucose4 { };
2021-08-15 01:00:27 +01:00
patches = [(substituteAll {
src = ./0001-Fix-some-paths-for-Nix-build.patch;
libipasir = "${libipasir}/lib/${libipasir.libname}";
openssl = openssl.out;
})];
buildInputs = [
# ACL2 itself only needs a Common Lisp compiler/interpreter:
sbcl
] ++ lib.optionals certifyBooks [
# To build community books, we need Perl and a couple of utilities:
2021-08-15 01:00:27 +01:00
which perl nettools makeWrapper
# Some of the books require one or more of these external tools:
2021-08-15 01:00:27 +01:00
openssl.out glucose minisat abc-verifier libipasir
z3 (python.withPackages (ps: [ ps.z3 ]))
];
# NOTE: Parallel building can be memory-intensive depending on the number of
# concurrent jobs. For example, this build has been seen to use >120GB of
# RAM on an 85 core machine.
enableParallelBuilding = true;
preConfigure = ''
# When certifying books, ACL2 doesn't like $HOME not existing.
export HOME=$(pwd)/fake-home
'' + lib.optionalString certifyBooks ''
# Some books also care about $USER being nonempty.
export USER=nobody
'';
postConfigure = ''
# ACL2 and its books need to be built in place in the out directory because
# the proof artifacts are not relocatable. Since ACL2 mostly expects
# everything to exist in the original source tree layout, we put it in
# $out/share/${pname} and create symlinks in $out/bin as necessary.
mkdir -p $out/share/${pname}
cp -pR . $out/share/${pname}
cd $out/share/${pname}
'';
preBuild = "mkdir -p $HOME";
2021-08-15 01:00:27 +01:00
makeFlags = "LISP=${sbcl}/bin/sbcl ACL2_MAKE_LOG=NONE";
doCheck = true;
checkTarget = "mini-proveall";
2016-01-24 12:49:33 +00:00
installPhase = ''
mkdir -p $out/bin
ln -s $out/share/${pname}/saved_acl2 $out/bin/${pname}
'' + lib.optionalString certifyBooks ''
ln -s $out/share/${pname}/books/build/cert.pl $out/bin/${pname}-cert
ln -s $out/share/${pname}/books/build/clean.pl $out/bin/${pname}-clean
'';
preDistPhases = [ (if certifyBooks then "certifyBooksPhase" else "removeBooksPhase") ];
certifyBooksPhase = ''
# Certify the community books
pushd $out/share/${pname}/books
makeFlags="ACL2=$out/share/${pname}/saved_acl2"
2021-08-15 01:00:27 +01:00
buildFlags="all"
buildPhase
2021-08-15 01:00:27 +01:00
# Clean up some stuff to save space
find -name '*@useless-runes.lsp' -execdir rm {} + # saves ~1GB of space
2021-08-15 22:05:37 +01:00
find -name '*.cert.out' -execdir gzip {} + # saves ~400MB of space
2021-08-15 01:00:27 +01:00
popd
'';
removeBooksPhase = ''
# Delete the community books
rm -rf $out/share/${pname}/books
2016-01-24 12:49:33 +00:00
'';
meta = with lib; {
description = "An interpreter and a prover for a Lisp dialect";
longDescription = ''
ACL2 is a logic and programming language in which you can model computer
systems, together with a tool to help you prove properties of those
models. "ACL2" denotes "A Computational Logic for Applicative Common
Lisp".
ACL2 is part of the Boyer-Moore family of provers, for which its authors
have received the 2005 ACM Software System Award.
This package installs the main ACL2 executable ${pname}, as well as the
build tools cert.pl and clean.pl, renamed to ${pname}-cert and
${pname}-clean.
'' + (if certifyBooks then ''
The community books are also included and certified with the `make
everything` target.
'' else ''
The community books are not included in this package.
'');
homepage = "https://www.cs.utexas.edu/users/moore/acl2/";
downloadPage = "https://github.com/acl2-devel/acl2-devel/releases";
license = with licenses; [
# ACL2 itself is bsd3
bsd3
] ++ optionals certifyBooks [
# The community books are mostly bsd3 or mit but with a few
# other things thrown in.
mit gpl2 llgpl21 cc0 publicDomain unfreeRedistributable
];
maintainers = with maintainers; [ kini raskin ];
platforms = platforms.all;
};
}