Reproducible builds for Verus with Nix#2054
Reproducible builds for Verus with Nix#2054JakeGinesin wants to merge 15 commits intoverus-lang:mainfrom
Conversation
parno
left a comment
There was a problem hiding this comment.
Generally looks sane to me, but I don't really speak nix. Maybe we should find someone who does to look it over.
flake.nix
Outdated
| inherit version; | ||
| srcs = [ ./source ./tools ./dependencies ]; | ||
| sourceRoot = "source"; | ||
| # cargoHash = "sha256-hxEH8qurjEDiXX2GGfZF4FTKaMz2e7O1rKHsb+ywnvc="; |
There was a problem hiding this comment.
Should we remove this old hash?
flake.nix
Outdated
| tag = "z3-${finalAttrs.version}"; | ||
| sha256 = "sha256-Qj9w5s02OSMQ2qA7HG7xNqQGaUacA1d4zbOHynq5k+A="; | ||
| }; | ||
| # NIX_CFLAGS_COMPILE = "-Wno-error=maybe-uninitialized -Wno-error=uninitialized"; |
flake.nix
Outdated
| runtimeInputs = [ verusfmt ] ++ lib.singleton formatter; | ||
| text = '' | ||
| nixpkgs-fmt "$@" | ||
| find vstd -name \*.rs -print0 | xargs -0 -n1 verusfmt |
There was a problem hiding this comment.
Why the custom command to format vstd? Usually we use vargo fmt to format all of the Verus + vstd code.
There was a problem hiding this comment.
I don't remember now why I went with this command (which I got from CONTRIBUTING.md; I agree it can safely be changed.
| find vstd -name \*.rs -print0 | xargs -0 -n1 verusfmt | |
| vargo fmt |
| nativeCheckInputs = linters ++ lib.singleton formatter; | ||
| checkPhase = '' | ||
| nixpkgs-fmt --check . | ||
| statix check |
There was a problem hiding this comment.
In line with #2054 (comment), could add this here.
| statix check | |
| statix check | |
| vargo fmt -- --check |
|
Thank you for your work! As a Nix user, I can confirm this works. With this PR, how would the process of updating the flake look like, to keep track of the current developments? Of course, every time the fixed-version dependencies are raised, one needs to manually adjust them here as well, which is probably fine. But how about the main verus cargo hash, does that need a manual update on every weekly release? Or can it be specified / overwritten somehow when using this flake? This is the minimal flake I came up with to be able to use this branch of verus in a verification project: # cf. https://github.com/stephen-huan/verus-flake/issues/1
# cf. https://github.com/verus-lang/verus/pull/2054
{
description = "verus verification environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
# branch of verus including a flake
# https://github.com/verus-lang/verus/pull/2054
verus.url = "github:JakeGinesin/verus/flake";
};
outputs = { self, nixpkgs, flake-utils, verus, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
devShells.default = pkgs.mkShell {
packages = [
# package default is just verus binary itself, without cargo etc
# verus.packages.${system}.default
verus.packages.${system}.verus
verus.packages.${system}.rust-bin
verus.packages.${system}.vargo
verus.packages.${system}.verusfmt
verus.packages.${system}.z3
];
};
}
);
} |
|
This new iteration of the flake makes the following changes:
@florianjacob with these changes, only the |
|
@florianjacob to answer your question on usage, your flake looks reasonable to me. Until this gets merged, my suggestion to stay up-to-date with the latest Verus changes is to create a fork of my Verus fork, set the upstream to the main Verus repo, and continually sync your fork with the main Verus repo whenever you want the most up-to-date changes. With my flake changes you'll most likely not need to update any of the hashes, but you might need to run Also pinging @stephen-huan, who might have a better solution here. |
This PR adds a
flake.nixto provide a fully reproducible development environment and build process for Verus, usingnix developandnix build.We pin specific versions of
rustc,z3(4.12.5) andcvc5(1.1.2) to match Verus requirements.vargodependencies are derived fromtools/vargo/Cargo.lock, andverusdependencies are pinned viacargoHash.We also spoof
rustupsincevargoinvokesrustupto verify toolchain version and execute commands. Since Nix provides the toolchain explicitly (withoutrustup), a Python shim is added that mocksrustup show(reporting the Nix-providedrustcversion) andrustup run(passing commands through to system$PATH).Pinging @stephen-huan here as he played a large part in authoring this PR :D
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.