Skip to content

Commit

Permalink
Switch to nix-community nixfmt + nixd tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
CathalMullan committed Sep 4, 2024
1 parent 0c49426 commit 8b6626a
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 157 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ result-bin

# Dir Env
.direnv
g
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@
// Nix
"mkhl.direnv",
"jnoortheen.nix-ide",
"kamadorueda.alejandra",
]
}
18 changes: 11 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},

// kamadorueda.alejandra
"alejandra.program": "alejandra",
// jnoortheen.nix-ide
"nix.enableLanguageServer": true,
"nix.serverPath": "nixd",
"nix.serverSettings": {
"nixd": {
"formatting": {
"command": ["nixfmt", "--width=120"]
}
}
},

"[nix]": {
"editor.defaultFormatter": "kamadorueda.alejandra"
"editor.defaultFormatter": "jnoortheen.nix-ide"
},

// jnoortheen.nix-ide
"nix.enableLanguageServer": true,
"nix.serverPath": "nil"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![crates.io](https://img.shields.io/crates/v/wayfind)](https://crates.io/crates/wayfind)
[![documentation](https://docs.rs/wayfind/badge.svg)](https://docs.rs/wayfind)
[![rust: 1.66+](https://img.shields.io/badge/rust-1.66-orange.svg)](https://img.shields.io/badge/rust-1.66-orange.svg)
[![rust: 1.66+](https://img.shields.io/badge/rust-1.66+-orange.svg)](https://img.shields.io/badge/rust-1.66-orange.svg)
![unsafe: forbidden](https://img.shields.io/badge/unsafe-forbidden-brightgreen.svg)
![license: MIT/Apache-2.0](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)

Expand Down
289 changes: 145 additions & 144 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,152 +20,153 @@
};

# nix flake show --all-systems
outputs = {
self,
nixpkgs,
flake-utils,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;

overlays = [
(import rust-overlay)

(self: super: {
cargo-codspeed = pkgs.callPackage ./nix/pkgs/cargo-codspeed {};
cargo-insta = pkgs.callPackage ./nix/pkgs/cargo-insta {};
})
];
};
in {
devShells = {
# nix develop
default = pkgs.mkShell {
name = "wayfind-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
# Rust
(pkgs.rust-bin.stable."1.80.1".minimal.override {
extensions = [
"clippy"
"rust-analyzer"
"rust-docs"
"rust-src"
"rustfmt"
];
})
sccache
cargo-insta
cargo-watch

# Benchmarking
cargo-codspeed
gnuplot

# Release
cargo-semver-checks

# Nix
alejandra
statix
nil
];
};

# nix develop .#benchmarks
benchmarks = pkgs.mkShell {
name = "wayfind-benchmarks-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(pkgs.rust-bin.stable."1.80.1".minimal)
sccache
cargo-codspeed
];
};

# nix develop .#ci
ci = pkgs.mkShell {
name = "wayfind-ci-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(pkgs.rust-bin.stable."1.80.1".minimal.override {
extensions = [
"clippy"
"rustfmt"
];
})
sccache
];
};

# nix develop .#coverage
coverage = pkgs.mkShell {
name = "wayfind-coverage-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(pkgs.rust-bin.nightly."2024-07-25".minimal.override {
extensions = [
"llvm-tools"
];
outputs =
{
nixpkgs,
flake-utils,
rust-overlay,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;

overlays = [
(import rust-overlay)

(self: super: {
cargo-codspeed = pkgs.callPackage ./nix/pkgs/cargo-codspeed { };
cargo-insta = pkgs.callPackage ./nix/pkgs/cargo-insta { };
})
sccache
cargo-llvm-cov
];
};

# nix develop .#docs
docs = pkgs.mkShell {
name = "wayfind-docs-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(pkgs.rust-bin.stable."1.80.1".minimal)
sccache
];
};

# nix develop .#fuzz
fuzz = pkgs.mkShell {
name = "wayfind-fuzz-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(pkgs.rust-bin.nightly."2024-07-25".minimal)
sccache
cargo-fuzz
];
};

# nix develop .#msrv
msrv = pkgs.mkShell {
name = "wayfind-msrv-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(pkgs.rust-bin.stable."1.66.0".minimal)
sccache
];
in
{
devShells = {
# nix develop
default = pkgs.mkShell {
name = "wayfind-shell";

NIX_PATH = "nixpkgs=${nixpkgs.outPath}";
RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
# Rust
(rust-bin.stable."1.80.1".minimal.override {
extensions = [
"clippy"
"rust-analyzer"
"rust-docs"
"rust-src"
"rustfmt"
];
})
sccache
cargo-insta
cargo-watch

# Benchmarking
cargo-codspeed
gnuplot

# Release
cargo-semver-checks

# Nix
nixfmt-rfc-style
nixd
];
};

# nix develop .#benchmarks
benchmarks = pkgs.mkShell {
name = "wayfind-benchmarks-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(rust-bin.stable."1.80.1".minimal)
sccache
cargo-codspeed
];
};

# nix develop .#ci
ci = pkgs.mkShell {
name = "wayfind-ci-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(rust-bin.stable."1.80.1".minimal.override {
extensions = [
"clippy"
"rustfmt"
];
})
sccache
];
};

# nix develop .#coverage
coverage = pkgs.mkShell {
name = "wayfind-coverage-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(rust-bin.nightly."2024-07-25".minimal.override { extensions = [ "llvm-tools" ]; })
sccache
cargo-llvm-cov
];
};

# nix develop .#docs
docs = pkgs.mkShell {
name = "wayfind-docs-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(rust-bin.stable."1.80.1".minimal)
sccache
];
};

# nix develop .#fuzz
fuzz = pkgs.mkShell {
name = "wayfind-fuzz-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(rust-bin.nightly."2024-07-25".minimal)
sccache
cargo-fuzz
];
};

# nix develop .#msrv
msrv = pkgs.mkShell {
name = "wayfind-msrv-shell";

RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_INCREMENTAL = "0";

buildInputs = with pkgs; [
(rust-bin.stable."1.66.0".minimal)
sccache
];
};
};
};
});
}
);
}
9 changes: 6 additions & 3 deletions nix/pkgs/cargo-codspeed/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ rustPlatform.buildRustPackage rec {

cargoHash = "sha256-ihkmD48EG1fWJ38AAt4Hy6dpATIgnEb6kApDfsTKxwA=";

nativeBuildInputs = [pkg-config];
nativeBuildInputs = [ pkg-config ];
buildInputs =
[openssl]
[ openssl ]
++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.SystemConfiguration
darwin.apple_sdk.frameworks.CoreServices
Expand All @@ -35,7 +35,10 @@ rustPlatform.buildRustPackage rec {
mainProgram = "cargo-codspeed";
homepage = "https://github.com/CodSpeedHQ/codspeed-rust";
changelog = "https://github.com/CodSpeedHQ/codspeed-rust/releases/tag/v${version}";
license = [licenses.mit licenses.asl20];
license = [
licenses.mit
licenses.asl20
];
platforms = platforms.all;
};
}

0 comments on commit 8b6626a

Please sign in to comment.