Skip to content

Commit

Permalink
add: nix stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kymppi committed Oct 7, 2022
1 parent 659045f commit 363fa73
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use nix
40 changes: 40 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix"
}
52 changes: 52 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -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 = []
3 changes: 3 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
edition = "2021"
use_field_init_shorthand = true
use_try_shorthand = true
22 changes: 22 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ pkgs ? import <nixpkgs> { } }:

let
rust-overlay = (import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"));
pkgs = (import <nixpkgs> {
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
];
}

0 comments on commit 363fa73

Please sign in to comment.