From 363fa73d91d080e4abb163a81a569647276499a1 Mon Sep 17 00:00:00 2001 From: Midka Date: Fri, 7 Oct 2022 18:42:04 +0300 Subject: [PATCH] add: nix stuff --- .envrc | 1 + .github/workflows/linting.yml | 40 +++++++++++++++++++++++++++ .github/workflows/testing.yml | 23 ++++++++++++++++ .vscode/settings.json | 3 ++ deny.toml | 52 +++++++++++++++++++++++++++++++++++ rustfmt.toml | 3 ++ shell.nix | 22 +++++++++++++++ 7 files changed, 144 insertions(+) create mode 100644 .envrc create mode 100644 .github/workflows/linting.yml create mode 100644 .github/workflows/testing.yml create mode 100644 .vscode/settings.json create mode 100644 deny.toml create mode 100644 rustfmt.toml create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..65326bb --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix \ No newline at end of file diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..058c385 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,40 @@ +name: Linting +on: [push, pull_request] + +jobs: + cargo-deny: + name: Cargo dependency linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: EmbarkStudios/cargo-deny-action@v1 + clippy: + name: Clippy linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + components: clippy + override: true + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features + name: Clippy Output + fmt: + name: Check formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + components: rustfmt + override: true + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..0ffbef1 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,23 @@ +name: Testing +on: [push, pull_request] + +jobs: + test: + name: Run tests + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - nightly + - stable + - 1.60.0 + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + - uses: actions-rs/cargo@v1 + with: + command: test diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..242b7f5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix" +} diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..2beb1a1 --- /dev/null +++ b/deny.toml @@ -0,0 +1,52 @@ +# More information: https://embarkstudios.github.io/cargo-deny/index.html +targets = [ + { triple = "x86_64-unknown-linux-gnu" }, + { triple = "aarch64-unknown-linux-gnu" }, + { triple = "x86_64-unknown-linux-musl" }, + { triple = "aarch64-apple-darwin" }, + { triple = "x86_64-apple-darwin" }, + { triple = "x86_64-pc-windows-msvc" }, +] + +[advisories] +db-path = "~/.cargo/advisory-db" +db-urls = ["https://github.com/rustsec/advisory-db"] + +vulnerability = "deny" +unmaintained = "warn" +yanked = "warn" +notice = "warn" + +[licenses] +allow = [ + "MIT", + "Apache-2.0", + "BSD-3-Clause", + "Unicode-DFS-2016" +] + +# Deny all unlicensed, copyleft and other not explicitly allowed licenses +unlicensed = "deny" +copyleft = "deny" +allow-osi-fsf-free = "neither" +default = "deny" + +# Some crates require weird licenses, exceptions for those crates can be made here +exceptions = [] + +# The confidence threshold for detecting a license from license text. +# The higher the value, the more closely the license text must be to the +# canonical license text of a valid SPDX license file. +confidence-threshold = 0.8 + +[bans] +multiple-versions = "warn" +wildcards = "allow" +highlight = "all" + +[sources] +unknown-registry = "deny" +unknown-git = "deny" + +allow-registry = ["https://github.com/rust-lang/crates.io-index"] +allow-git = [] \ No newline at end of file diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..f42fe6a --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,3 @@ +edition = "2021" +use_field_init_shorthand = true +use_try_shorthand = true \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..6ad3be7 --- /dev/null +++ b/shell.nix @@ -0,0 +1,22 @@ +{ pkgs ? import { } }: + +let + rust-overlay = (import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz")); + pkgs = (import { + overlays = [ rust-overlay ]; + }); +in +pkgs.mkShell { + buildInputs = [ + (pkgs.rust-bin.stable.latest.default.override { + extensions = [ "rust-src" ]; + }) + ]; + PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; + # nativeBuildInputs is usually what you want -- tools you need to run + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.rust-analyzer + pkgs.cargo-deny + ]; +}