Compare commits
2 Commits
5237226018
...
2379281532
Author | SHA1 | Date |
---|---|---|
Nathan McCarty | 2379281532 | |
Nathan McCarty | f8a7b1e5e8 |
|
@ -0,0 +1,59 @@
|
||||||
|
# Nix Flakes Rust Helper
|
||||||
|
|
||||||
|
A helper flake for automatically generating flake contents for rust projects, including building,
|
||||||
|
testing, documenting, auditing, and linting of rust projects, as well as other useful toolchain
|
||||||
|
packages
|
||||||
|
|
||||||
|
## Provided toolchain
|
||||||
|
|
||||||
|
### DevShell
|
||||||
|
|
||||||
|
The provided devShell includes the following rust specific packages, in addition to the usual rust
|
||||||
|
toolchain (including rust-analyzer):
|
||||||
|
|
||||||
|
- [`cargo-llvm-cov`](https://crates.io/crates/cargo-llvm-cov)
|
||||||
|
- [`cargo-nextest`](https://crates.io/crates/cargo-nextest)
|
||||||
|
- [`cargo-udeps`](https://crates.io/crates/cargo-udeps)
|
||||||
|
- [`cargo-audit`](https://crates.io/crates/cargo-audit)
|
||||||
|
- [`cargo-release`](https://crates.io/crates/cargo-release)
|
||||||
|
- [`cargo-deny`](https://crates.io/crates/cargo-deny)
|
||||||
|
|
||||||
|
These general workflow utilities are provided:
|
||||||
|
- [`gnuplot`](http://www.gnuplot.info/)
|
||||||
|
- [`pre-commit`](https://pre-commit.com/)
|
||||||
|
- [`git-lfs`](https://git-lfs.com/)
|
||||||
|
- [`git-cliff`](https://git-cliff.org/)
|
||||||
|
- [`nixfmt`](https://github.com/serokell/nixfmt)
|
||||||
|
- [`mdformat`](https://mdformat.readthedocs.io/en/stable/)
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
The following dependencies are provided by default:
|
||||||
|
- `cmake`
|
||||||
|
- `openssl`
|
||||||
|
- `pkg-config`
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Repository with a single crate (not a workspace)
|
||||||
|
|
||||||
|
Create a `flake.nix` in the root of the repository with the following contents:
|
||||||
|
|
||||||
|
``` nix
|
||||||
|
{
|
||||||
|
inputs = { rust = { url = "./.."; }; };
|
||||||
|
description = "Simple Test Package";
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, rust }:
|
||||||
|
rust.single {
|
||||||
|
crateName = "CRATE_NAME";
|
||||||
|
src = ./.;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Optionally create a `.envrc` in the root of the repository with the following contents:
|
||||||
|
|
||||||
|
``` nix
|
||||||
|
use flake
|
||||||
|
```
|
17
flake.lock
17
flake.lock
|
@ -1,5 +1,21 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"advisory-db": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1683272394,
|
||||||
|
"narHash": "sha256-4XQZbSZ8XYAeASpr0Er8mNPnjbYLJwvaB+VyH+bt6DE=",
|
||||||
|
"owner": "RustSec",
|
||||||
|
"repo": "advisory-db",
|
||||||
|
"rev": "50bed3ba4066e6255dab434dc845e7f655812ce1",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "RustSec",
|
||||||
|
"repo": "advisory-db",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
|
@ -56,6 +72,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"advisory-db": "advisory-db",
|
||||||
"naersk": "naersk",
|
"naersk": "naersk",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"rust-overlay": "rust-overlay",
|
"rust-overlay": "rust-overlay",
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eou pipefail
|
||||||
|
|
||||||
|
DIRECTORY=$(dirname "$0")
|
||||||
|
pushd $DIRECTORY
|
||||||
|
|
||||||
|
# Update our sources first
|
||||||
|
$DIRECTORY/sources/update-sources.sh
|
||||||
|
|
||||||
|
# Then update the flake
|
||||||
|
nix flake update
|
||||||
|
|
||||||
|
# Make sure the update worked
|
||||||
|
pushd $DIRECTORY/test-crate
|
||||||
|
./ci.sh
|
||||||
|
rm flake.lock
|
Loading…
Reference in New Issue