Configure nix development shell environment

This gets used by `nix develop`, or automatically by `direnv` if you have it
installed.

The binary versions are pinned to the versions recommended by `contributing.md`.

```
>> cargo --version
cargo 1.60.0 (d1fd9fe 2022-03-01)

>> rustc --version
rustc 1.60.0 (7737e0b5c 2022-04-04)

>> cargo fmt --version
rustfmt 1.5.1-nightly (3984bc5 2023-01-17)

>> cargo clippy --version
clippy 0.1.60 (7737e0b 2022-04-04)
```
This commit is contained in:
Michael Forster 2023-01-17 12:41:33 +01:00 committed by Mike Forster
parent 0ddf550369
commit 536ac87b11
5 changed files with 77 additions and 4 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

1
.gitignore vendored
View file

@ -3,3 +3,4 @@
result
# generated by the insta crate
*.pending-snap
.direnv

View file

@ -3,7 +3,7 @@ name = "jujutsu"
version = "0.6.1"
authors = ["Martin von Zweigbergk <martinvonz@google.com>"]
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"

39
flake.lock generated
View file

@ -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"
}
}
},

View file

@ -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
];
};
}));
}