diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..3550a30f2 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 72ea9068e..c2ff8e3c4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ result # generated by the insta crate *.pending-snap +.direnv diff --git a/Cargo.toml b/Cargo.toml index 4b8f01d4a..91651f6a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "jujutsu" version = "0.6.1" authors = ["Martin von Zweigbergk "] edition = "2021" -rust-version = "1.60" # Remember to update CI +rust-version = "1.60" # Remember to update CI, contributing.md, and flake.nix license = "Apache-2.0" description = "Jujutsu (an experimental VCS)" homepage = "https://github.com/martinvonz/jj" diff --git a/flake.lock b/flake.lock index 1b6b2c4fa..4b3689739 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1651634615, @@ -16,7 +31,29 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1674008920, + "narHash": "sha256-ugwPxKjvmJ5GpzN/MHg8tuhe8nYi3SbJm5nWNy7CB0Q=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "eecc44934a0f6c02c02856b38bd3b6af3bec0870", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 9e30e2fb5..bc5717a0e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,13 @@ { description = "jujutsu"; - outputs = { self, nixpkgs, ... }: + inputs = { + # For installing non-standard rustc versions + rust-overlay.url = "github:oxalica/rust-overlay"; + rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, rust-overlay, ... }: let lib = nixpkgs.lib; systems = [ @@ -83,7 +89,10 @@ let pkgs = import nixpkgs { inherit system; - overlays = [ self.overlays.default ]; + overlays = [ + self.overlays.default + rust-overlay.overlays.default + ]; }; in { @@ -103,5 +112,30 @@ ''; }); formatter.${system} = pkgs.nixpkgs-fmt; + devShells.${system}.default = pkgs.mkShell { + buildInputs = with pkgs; [ + # Using the minimal profile with explicit "clippy" extension to avoid + # two versions of rustfmt + (rust-bin.stable."1.60.0".minimal.override { + extensions = [ + "rust-src" # for rust-analyzer + "clippy" + ]; + }) + + # The CI checks against the latest nightly rustfmt, so we should too. + (rust-bin.selectLatestNightlyWith (toolchain: toolchain.rustfmt)) + + # Required build dependencies + openssl + pkg-config # to find openssl + + # Additional tools recommended by contributing.md + cargo-deny + cargo-insta + cargo-nextest + cargo-watch + ]; + }; })); }