base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / da / dafny / package.nix
blob3f97765e6c1808c41ea3c6185589fcdbdec3634b
1 { lib
2 , buildDotnetModule
3 , fetchFromGitHub
4 , writeScript
5 , jdk11
6 , z3
7 }:
9 buildDotnetModule rec {
10   pname = "Dafny";
11   version = "4.8.0";
13   src = fetchFromGitHub {
14     owner = "dafny-lang";
15     repo = "dafny";
16     rev = "v${version}";
17     hash = "sha256-x/fX4o+R72Pl02u1Zsr80Rh/4Wb/aKw90fhAGmsfFUI=";
18   };
20   postPatch =
21     let
22       # This file wasn't updated between 4.6.0 and 4.7.0.
23       runtimeJarVersion = "4.6.0";
24     in
25     ''
26       cp ${
27         writeScript "fake-gradlew-for-dafny" ''
28           mkdir -p build/libs/
29           javac $(find -name "*.java" | grep "^./src/main") -d classes
30           jar cf build/libs/DafnyRuntime-${runtimeJarVersion}.jar -C classes dafny
31         ''} Source/DafnyRuntime/DafnyRuntimeJava/gradlew
33       # Needed to fix
34       # "error NETSDK1129: The 'Publish' target is not supported without
35       # specifying a target framework. The current project targets multiple
36       # frameworks, you must specify the framework for the published
37       # application."
38       substituteInPlace Source/DafnyRuntime/DafnyRuntime.csproj \
39         --replace-warn TargetFrameworks TargetFramework \
40         --replace-warn "netstandard2.0;net452" net6.0
41     '';
43   buildInputs = [ jdk11 ];
44   nugetDeps = ./deps.nix;
46   # Build just these projects. Building Source/Dafny.sln includes a bunch of
47   # unnecessary components like tests.
48   projectFile = [
49     "Source/Dafny/Dafny.csproj"
50     "Source/DafnyRuntime/DafnyRuntime.csproj"
51     "Source/DafnyLanguageServer/DafnyLanguageServer.csproj"
52   ];
54   executables = [ "Dafny" ];
56   # Help Dafny find z3
57   makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ z3 ]}" ];
59   postFixup = ''
60     ln -s "$out/bin/Dafny" "$out/bin/dafny" || true
61   '';
63   meta = with lib; {
64     description = "Programming language with built-in specification constructs";
65     homepage = "https://research.microsoft.com/dafny";
66     maintainers = with maintainers; [ layus ];
67     license = licenses.mit;
68     platforms = with platforms; (linux ++ darwin);
69   };