From e7a326c688dd6b945c7d8a6ecf293320e9a13065 Mon Sep 17 00:00:00 2001 From: Bauke Date: Wed, 31 Jan 2024 12:39:56 +0100 Subject: [PATCH] Add Nix flake and direnv files. --- .envrc | 3 + .gitignore | 8 +-- Makefile.toml | 47 +++++++--------- flake.lock | 128 ++++++++++++++++++++++++++++++++++++++++++ flake.nix | 17 ++++++ rustup-toolchain.toml | 3 + shell.nix | 18 ++++++ 7 files changed, 192 insertions(+), 32 deletions(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 rustup-toolchain.toml create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..b9238c3 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +use flake diff --git a/.gitignore b/.gitignore index c31fef4..45b4b45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ -# Generated by Cargo -Cargo.lock +.direnv/ +coverage/ debug/ target/ - -# Code coverage results -coverage/ +Cargo.lock diff --git a/Makefile.toml b/Makefile.toml index d640ca1..600e25d 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1,33 +1,21 @@ -[tasks.fmt] -command = "cargo" -args = ["fmt", "${@}"] - -[tasks.check] -command = "cargo" -args = ["check", "${@}"] - -[tasks.clippy] -command = "cargo" -args = ["clippy", "${@}"] - -[tasks.test] -command = "cargo" -args = ["test", "${@}"] - -[tasks.doc] -command = "cargo" -args = ["doc", "${@}"] - -[tasks.build] -command = "cargo" -args = ["build", "${@}"] - +# Do a full check of everything. [tasks.complete-check] -dependencies = ["fmt", "check", "clippy", "test", "doc", "build"] +dependencies = [ + "format", + "spellcheck", + "check", + "clippy", + "test", + "code-coverage", + "docs", + "build", + "audit-flow", + "outdated-flow", +] +# Run cargo-tarpaulin and output the test coverage. [tasks.code-coverage] workspace = false -install_crate = "cargo-tarpaulin" command = "cargo" args = [ "tarpaulin", @@ -35,5 +23,10 @@ args = [ "--out=html", "--output-dir=coverage", "--skip-clean", - "--target-dir=target/tarpaulin" + "--target-dir=target/tarpaulin", ] + +# Do a source code spellcheck. +[tasks.spellcheck] +clear = true +command = "typos" diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1c5c0de --- /dev/null +++ b/flake.lock @@ -0,0 +1,128 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1706589919, + "narHash": "sha256-pNHnDITxSI3a17GOF1RUF3jBO1OiNYTRH2yV/cJG4m4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "222c1940fafeda4dea161858ffe6ebfc853d3db5", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1706667075, + "narHash": "sha256-KBI5jcOWh9nsOFWj2SRq7vj+fPDf8Do8ceL582kFA70=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "2c993daf3136c6955fd13bfe215d0d4faf6090f1", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b394bb9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,17 @@ +{ + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay.url = "github:oxalica/rust-overlay"; + }; + + outputs = { self, nixpkgs, flake-utils, rust-overlay }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + in + { + devShells.default = import ./shell.nix { inherit pkgs; }; + } + ); +} diff --git a/rustup-toolchain.toml b/rustup-toolchain.toml new file mode 100644 index 0000000..0a15096 --- /dev/null +++ b/rustup-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +components = ["cargo", "clippy", "rustfmt", "rust-src"] diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..a945393 --- /dev/null +++ b/shell.nix @@ -0,0 +1,18 @@ +{ pkgs ? import { } }: + +with pkgs; + +let + rustup-toolchain = rust-bin.fromRustupToolchainFile ./rustup-toolchain.toml; +in +mkShell rec { + packages = [ + cargo-audit + cargo-edit + cargo-make + cargo-outdated + cargo-tarpaulin + rustup-toolchain + typos + ]; +}